Русский   Home

Strings

Strings in JScript and VBScript are of the BSTR type. These are Unicode strings, i.e. the code of each character takes 2 bytes. The last character is followed by a terminator (two zero bytes), and the first character is preceded by a 4-byte number that contains the length of the string in bytes (excluding zero bytes at the end of the string). A script string variable holds a pointer to such a string, which is the address of the string's first character (i.e. the bytes that contain the string length remain "behind-the-scenes").

A string can be passed to a function in three ways:
There are two ways to return a string:
API functions that take string arguments typically exist in two variants — for example, MessageBoxA and MessageBoxW. It appears more reasonable in scripts to use the Unicode versions (those having a 'W' at the end of the name) because this way you avoid conversion to and from Unicode.

Use of strings as memory buffers may or may not be a reliable technique depending on how the scripting engine treats strings internally. So I recommend using MemAlloc instead of Space for that purpose.