class System::Text::WideString

A wide character string for unicode support.

To initialize this string class with unicode characters, save your script file in UTF-8 format. JewelScript allows UTF-8 characters in string literals, but not in source code. This class is meant to be used to reliably perform string operations on unicode strings. When passing a wstring object to a function expecting a string reference, the wide character string is automatically converted back to UTF-8.

Global Functions

WideString format (const WideString, const var)Formats the specified array or value into a string.
WideString join (const WideString[], const WideString)Concatenates all strings in the specified array into one string.

Constructors

WideString ()Creates a new, empty wide character string.
WideString (const WideString)Copy-constructs a wide character string from another wide character string.
WideString (const string)Constructs a wide character string from an ANSI or UTF-8 string.
WideString (const int, const int)Constructs a string of the specified length, filled with the specified unicode character.

Convertors

string convertor ()Converts the wide character string back to an UTF-8 string.

Methods

WideString append (const WideString)Appends the given string to this string and returns a new string.
int charAt (const int)Returns the character at the specified index position.
int compare (const WideString)Compares the two strings.
int compare (const WideString, const int)Compares the first 'length' characters of the two strings.
int compareNoCase (const WideString)Compares the two strings, disregarding character case.
int compareNoCase (const WideString, const int)Compares the first 'length' characters of the two strings, disregarding character case.
int containsOneOf (const WideString)Returns true if this string contains one of the characters specified in the character set.
int containsOnly (const WideString)Returns true if this string contains only characters specified in the character set.
int indexOf (const int, const int)Returns the index of the first occurrence of the specified character.
int indexOf (const WideString, const int)Returns the index of the first occurrence of the specified sub-string.
WideString insert (const WideString, const int)Inserts the given string into this string at the given index position and returns a new string.
int lastIndexOf (const int, const int)Returns the index of the last occurrence of the specified character.
WideString remove (const int, const int)Removes the specified range of characters from this string and returns a new string.
WideString replace (const WideString, const WideString)Replaces all occurrences of 'search' by 'repl' and returns a new string.
WideString reverse ()Reverses the order of characters and returns a new string.
WideString spanExcluding (const WideString, const int)Starting from index, returns all characters that are NOT included in the specified character set.
WideString spanIncluding (const WideString, const int)Starting from index, returns all characters that are included in the specified character set.
WideString[] split (const WideString, const int)Splits this string into an array of tokens based on the given set of delimiter characters.
WideString subString (const int)Extracts all characters from the given position to the end and returns a new string.
WideString subString (const int, const int)Extracts the given range of characters and returns a new string.
WideString toLower ()Converts the string to lower case and returns a new string.
string toString (const int)Converts the string back to an 8 bit string.
WideString toUpper ()Converts the string to upper case and returns a new string.

Properties

int ansiCodePage ()Returns the ANSI code page for this system.
int isEmpty ()Returns true if this string is currently empty.
int lastChar ()Returns the last character in this string.
int length ()Returns the length of this string in characters.
int oemCodePage ()Returns the OEM code page for this system.

Type Declaration

native class System::Text::WideString
{
    ["A wide character string for unicode support. To initialize this string class with unicode characters, save your script file in UTF-8 format. JewelScript allows UTF-8 characters in string literals, but not in source code. This class is meant to be used to reliably perform string operations on unicode strings. When passing a wstring object to a function expecting a string reference, the wide character string is automatically converted back to UTF-8."]
    method WideString (); ["Creates a new, empty wide character string."]
    method WideString (const WideString src); ["Copy-constructs a wide character string from another wide character string."]
    method WideString (const string src); ["Constructs a wide character string from an ANSI or UTF-8 string."]
    method WideString (const int chr, const int length); ["Constructs a string of the specified length, filled with the specified unicode character."]
    method string convertor (); ["Converts the wide character string back to an UTF-8 string."]
    method int charAt (const int index); ["Returns the character at the specified index position."]
    method int compare (const WideString src); ["Compares the two strings. Returns a negative value if this string is smaller than 'src', a positive value if it is larger, and 0 if they are equal."]
    method int compare (const WideString src, const int length); ["Compares the first 'length' characters of the two strings. Returns a negative value if this string is smaller than 'src', a positive value if it is larger, and 0 if they are equal."]
    method int compareNoCase (const WideString src); ["Compares the two strings, disregarding character case. Returns a negative value if this string is smaller than 'src', a positive value if it is larger, and 0 if they are equal."]
    method int compareNoCase (const WideString src, const int length); ["Compares the first 'length' characters of the two strings, disregarding character case. Returns a negative value if this string is smaller than 'src', a positive value if it is larger, and 0 if they are equal."]
    method int containsOnly (const WideString charSet); ["Returns true if this string contains only characters specified in the character set."]
    method int containsOneOf (const WideString charSet); ["Returns true if this string contains one of the characters specified in the character set."]
    method WideString reverse (); ["Reverses the order of characters and returns a new string."]
    method WideString toUpper (); ["Converts the string to upper case and returns a new string."]
    method WideString toLower (); ["Converts the string to lower case and returns a new string."]
    method WideString append (const WideString src); ["Appends the given string to this string and returns a new string."]
    method WideString insert (const WideString src, const int index); ["Inserts the given string into this string at the given index position and returns a new string."]
    method WideString remove (const int index, const int length); ["Removes the specified range of characters from this string and returns a new string."]
    method WideString subString (const int index); ["Extracts all characters from the given position to the end and returns a new string."]
    method WideString subString (const int index, const int length); ["Extracts the given range of characters and returns a new string."]
    method WideString replace (const WideString search, const WideString repl); ["Replaces all occurrences of 'search' by 'repl' and returns a new string."]
    method int indexOf (const int chr, const int index); ["Returns the index of the first occurrence of the specified character. If the character is not found, returns -1."]
    method int indexOf (const WideString src, const int index); ["Returns the index of the first occurrence of the specified sub-string. If the sub-string is not found, returns -1."]
    method int lastIndexOf (const int chr, const int index); ["Returns the index of the last occurrence of the specified character. If the character is not found, returns -1."]
    method WideString spanIncluding (const WideString charSet, const int index); ["Starting from index, returns all characters that are included in the specified character set. The method stops at the first character that is not included in the character set."]
    method WideString spanExcluding (const WideString charSet, const int index); ["Starting from index, returns all characters that are NOT included in the specified character set. The method stops at the first character that is included in the character set."]
    method WideString[] split (const WideString seperators, const int discard); ["Splits this string into an array of tokens based on the given set of delimiter characters. The returned array will contain all text between delimiters, but not the delimiters itself. If 'discard' is 'false', a delimiter directly following another delimiter will produce an empty string element in the array. If set to 'true', empty strings will not be added to the array. If this string does not match any delimiter, the resulting array will contain a single element, which is a copy of this string."]
    method string toString (const int codepage); ["Converts the string back to an 8 bit string. Available modes are WideString::UTF8 and WideString::ANSI. You may also pass any other Windows codepage identifier."]
    accessor int length (); ["Returns the length of this string in characters."]
    accessor int lastChar (); ["Returns the last character in this string."]
    accessor int isEmpty (); ["Returns true if this string is currently empty."]
    function WideString format (const WideString format, const var v); ["Formats the specified array or value into a string."]
    function WideString join (const WideString[] strings, const WideString separator); ["Concatenates all strings in the specified array into one string."]
    accessor int ansiCodePage (); ["Returns the ANSI code page for this system."]
    accessor int oemCodePage (); ["Returns the OEM code page for this system."]
    const int UTF8 = 65001;
    const int ANSI = 20127;
}

Reference

function WideString format (const WideString format, const var v)

Formats the specified array or value into a string.


function WideString join (const WideString[] strings, const WideString separator)

Concatenates all strings in the specified array into one string.


method WideString ()

Creates a new, empty wide character string.


method WideString (const WideString src)

Copy-constructs a wide character string from another wide character string.


method WideString (const string src)

Constructs a wide character string from an ANSI or UTF-8 string.


method WideString (const int chr, const int length)

Constructs a string of the specified length, filled with the specified unicode character.


method string convertor ()

Converts the wide character string back to an UTF-8 string.


method WideString append (const WideString src)

Appends the given string to this string and returns a new string.


method int charAt (const int index)

Returns the character at the specified index position.


method int compare (const WideString src)

Compares the two strings.

Returns a negative value if this string is smaller than 'src', a positive value if it is larger, and 0 if they are equal.


method int compare (const WideString src, const int length)

Compares the first 'length' characters of the two strings.

Returns a negative value if this string is smaller than 'src', a positive value if it is larger, and 0 if they are equal.


method int compareNoCase (const WideString src)

Compares the two strings, disregarding character case.

Returns a negative value if this string is smaller than 'src', a positive value if it is larger, and 0 if they are equal.


method int compareNoCase (const WideString src, const int length)

Compares the first 'length' characters of the two strings, disregarding character case.

Returns a negative value if this string is smaller than 'src', a positive value if it is larger, and 0 if they are equal.


method int containsOneOf (const WideString charSet)

Returns true if this string contains one of the characters specified in the character set.


method int containsOnly (const WideString charSet)

Returns true if this string contains only characters specified in the character set.


method int indexOf (const int chr, const int index)

Returns the index of the first occurrence of the specified character.

If the character is not found, returns -1.


method int indexOf (const WideString src, const int index)

Returns the index of the first occurrence of the specified sub-string.

If the sub-string is not found, returns -1.


method WideString insert (const WideString src, const int index)

Inserts the given string into this string at the given index position and returns a new string.


method int lastIndexOf (const int chr, const int index)

Returns the index of the last occurrence of the specified character.

If the character is not found, returns -1.


method WideString remove (const int index, const int length)

Removes the specified range of characters from this string and returns a new string.


method WideString replace (const WideString search, const WideString repl)

Replaces all occurrences of 'search' by 'repl' and returns a new string.


method WideString reverse ()

Reverses the order of characters and returns a new string.


method WideString spanExcluding (const WideString charSet, const int index)

Starting from index, returns all characters that are NOT included in the specified character set.

The method stops at the first character that is included in the character set.


method WideString spanIncluding (const WideString charSet, const int index)

Starting from index, returns all characters that are included in the specified character set.

The method stops at the first character that is not included in the character set.


method WideString[] split (const WideString seperators, const int discard)

Splits this string into an array of tokens based on the given set of delimiter characters.

The returned array will contain all text between delimiters, but not the delimiters itself. If 'discard' is 'false', a delimiter directly following another delimiter will produce an empty string element in the array. If set to 'true', empty strings will not be added to the array. If this string does not match any delimiter, the resulting array will contain a single element, which is a copy of this string.


method WideString subString (const int index)

Extracts all characters from the given position to the end and returns a new string.


method WideString subString (const int index, const int length)

Extracts the given range of characters and returns a new string.


method WideString toLower ()

Converts the string to lower case and returns a new string.


method string toString (const int codepage)

Converts the string back to an 8 bit string.

Available modes are WideString::UTF8 and WideString::ANSI. You may also pass any other Windows codepage identifier.


method WideString toUpper ()

Converts the string to upper case and returns a new string.


accessor int ansiCodePage ()

Returns the ANSI code page for this system.


accessor int isEmpty ()

Returns true if this string is currently empty.


accessor int lastChar ()

Returns the last character in this string.


accessor int length ()

Returns the length of this string in characters.


accessor int oemCodePage ()

Returns the OEM code page for this system.