class wstring

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

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

Constructors

wstring ()Creates a new, empty wide character string.
wstring (const wstring)Copy-constructs a wide character string from another wide character string.
wstring (const string)Constructs a wide character string from an ANSI or UTF-8 string.
wstring (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

wstring append (const wstring)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 wstring)Compares the two strings.
int compare (const wstring, const int)Compares the first 'length' characters of the two strings.
int compareNoCase (const wstring)Compares the two strings, disregarding character case.
int compareNoCase (const wstring, const int)Compares the first 'length' characters of the two strings, disregarding character case.
int containsOneOf (const wstring)Returns true if this string contains one of the characters specified in the character set.
int containsOnly (const wstring)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 wstring, const int)Returns the index of the first occurrence of the specified sub-string.
wstring insert (const wstring, 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.
wstring remove (const int, const int)Removes the specified range of characters from this string and returns a new string.
wstring replace (const wstring, const wstring)Replaces all occurrences of 'search' by 'repl' and returns a new string.
wstring reverse ()Reverses the order of characters and returns a new string.
wstring spanExcluding (const wstring, const int)Starting from index, returns all characters that are NOT included in the specified character set.
wstring spanIncluding (const wstring, const int)Starting from index, returns all characters that are included in the specified character set.
wstring[] split (const wstring, const int)Splits this string into an array of tokens based on the given set of delimiter characters.
wstring subString (const int)Extracts all characters from the given position to the end and returns a new string.
wstring subString (const int, const int)Extracts the given range of characters and returns a new string.
wstring 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.
wstring toUpper ()Converts the string to upper case and returns a new string.

Properties

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.

Reference

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

Formats the specified array or value into a string.


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

Concatenates all strings in the specified array into one string.


method wstring ()

Creates a new, empty wide character string.


method wstring (const wstring src)

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


method wstring (const string src)

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


method wstring (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 wstring append (const wstring 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 wstring 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 wstring 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 wstring 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 wstring 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 wstring charSet)

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


method int containsOnly (const wstring 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 wstring 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 wstring insert (const wstring 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 wstring remove (const int index, const int length)

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


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

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


method wstring reverse ()

Reverses the order of characters and returns a new string.


method wstring spanExcluding (const wstring 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 wstring spanIncluding (const wstring 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 wstring[] split (const wstring 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 wstring subString (const int index)

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


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

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


method wstring 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 wstring::UTF8 and wstring::ANSI. You may also pass any other Windows codepage identifier.


method wstring toUpper ()

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


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.