HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How are strings stored?

01-07-2004, 02:05 AM#1
weaaddar
Does anyone know how strings are stored in jass?
01-07-2004, 05:03 AM#2
Vidstige
I am not sure what kind of answer you are looking for. Do you wonder if they are Unicode or ASCII, or where in memory they are stored, or are you really just wondering how to handle them in jass code? Either way, don't expect all natives regarding strings to work from jass code. If you have a specific problem, then there are probably some kind of workaround for it.
01-07-2004, 02:23 PM#3
Peppar
I believe that strings are Unicode encoded in UTF-8.

If you use SubString on a non-english character, for example, "ä", and set the parameters to retrieve a single-character substring from the beginning of the string, you will get an unprintable character. If you set the parameters to retrieve a two-character string though, you will get the entire "ä". In UTF-8, "ä" is encoded as two bytes.

EDIT: The maximum length of a (local) string in Warcraft is 2048 characters, whereof a maximum of 1023 can be displayed by the normal display-functions in-game.
01-07-2004, 02:24 PM#4
KaTTaNa
It's a good question actually. I tried converting a string to integer using the return bug. Typically it will return something in the range of 10 to 200 (maybe it's 0-255).
If you at the start of a map convert an integer to a string (using return bug), it will become null or "". But if you convert a string to a number and then back without restarting the map, it will work.
Strange emote_confused
01-07-2004, 04:01 PM#5
Sage the Mage
I'd say it was in Unicode too, but that's just because I know Java is.
01-07-2004, 06:51 PM#6
jmoritz
They need unicode for the korean and chinese and japanese character sets I believe.
01-07-2004, 07:44 PM#7
weaaddar
Right so your saying I can convert strings to integers using the return bug? And it decodes them to a propper string?
I'm trying to set up where ITems can be equiped but have no place to Define Constants of where each slot item goes. (slot 1 left hand for example).
My current implementation lets the item have its special effect line read string model, string where to attach" But this creates some problem as items can be equiped in multiple slots.

Unfortuantly this means my map now becomes an abuser of the Return bug majorly. (i'll be going udg_Hero[2]=U2I(StringToInt("Left Hand") ).
01-07-2004, 08:01 PM#8
PitzerMike
Some day blizz is going to fix that bug, heh
01-07-2004, 08:07 PM#9
weaaddar
I hope not.
01-07-2004, 09:33 PM#10
jmoritz
I hope they fix it soon. More and more people are starting to "use" the return bug, which is absolutely unnecessary. There is always, ALWAYS, another solution.

People that use the return bug are doing something really stupid, but noone seems to care :(
01-07-2004, 09:49 PM#11
PitzerMike
what's so stupid with it?
01-07-2004, 10:05 PM#12
weaaddar
Its a great debug tool for me. When i wanna check if the hero that trigger is executing for is the same as the one that was revived I type cast them to integers and print them out. Its just alot easier for me.
01-07-2004, 10:53 PM#13
AIAndy
In the b.net map development forum there is a pretty clear statement by Brett Wood that the return bug will not be removed.
01-07-2004, 11:51 PM#14
Cacodemon
See new thread about this:

http://www.wc3campaigns.com/forums/s...691#post405691
01-08-2004, 12:10 AM#15
AIAndy
I am pretty sure that reals are not put on a handle array. It would just be inefficient. What you see when using the return bug on reals is just the real bits interpreted as an integer.
When you use natives that return strings in AI then you sometimes get names of your functions as return value. So I guess on the string handle array there are all the names of the functions in the script.