This abstract provides consistent cross-target unicode support for characters of any width.

Due to differing internal representations of strings across targets, only the basic multilingual plane (BMP) is supported consistently by String class.

This abstract provides API to consistently handle all characters even beyond BMP.

See also:

Static variables

staticread onlylength:Int

Available on cs, cpp, flash, js, hl, java

The number of characters in this String.

Static methods

staticcharAt(this:String, index:Int):String

Available on cs, cpp, flash, js, hl, java

Returns the character at position index of this String.

If index is negative or exceeds this.length, the empty String "" is returned.

staticcharCodeAt(this:String, index:Int):Null<Int>

Available on cs, cpp, flash, js, hl, java

Returns the character code at position index of this String.

If index is negative or exceeds this.length, null is returned.

staticindexOf(this:String, str:String, ?startIndex:Int):Int

Available on cs, cpp, flash, js, hl, java

Returns the position of the leftmost occurrence of str within this String.

If startIndex is given, the search is performed within the substring of this String starting from startIndex (if startIndex is posivite or 0) or max(this.length + startIndex, 0) (if startIndex is negative).

If startIndex exceeds this.length, -1 is returned.

Otherwise the search is performed within this String. In either case, the returned position is relative to the beginning of this String.

If str cannot be found, -1 is returned.

staticinlineiterator(this:String):StringIteratorUnicode

Available on cs, cpp, flash, php, js, macro, hl, lua, java, python

Returns an iterator of the unicode code points.

staticinlinekeyValueIterator(this:String):StringKeyValueIteratorUnicode

Available on cs, cpp, flash, php, js, macro, hl, lua, java, python

Returns an iterator of the code point indices and unicode code points.

staticlastIndexOf(this:String, str:String, ?startIndex:Int):Int

Available on cs, cpp, flash, js, hl, java

Returns the position of the rightmost occurrence of str within this String.

If startIndex is given, the search is performed within the substring of this String from 0 to startIndex + str.length. Otherwise the search is performed within this String. In either case, the returned position is relative to the beginning of this String.

If str cannot be found, -1 is returned.

staticsubstr(this:String, pos:Int, ?len:Int):String

Available on cs, cpp, flash, js, hl, java

Returns len characters of this String, starting at position pos.

If len is omitted, all characters from position pos to the end of this String are included.

If pos is negative, its value is calculated from the end of this String by this.length + pos. If this yields a negative value, 0 is used instead.

If the calculated position + len exceeds this.length, the characters from that position to the end of this String are returned.

If len is negative, the result is unspecified.

staticsubstring(this:String, startIndex:Int, ?endIndex:Int):String

Available on cs, cpp, flash, js, hl, java

Returns the part of this String from startIndex to but not including endIndex.

If startIndex or endIndex are negative, 0 is used instead.

If startIndex exceeds endIndex, they are swapped.

If the (possibly swapped) endIndex is omitted or exceeds this.length, this.length is used instead.

If the (possibly swapped) startIndex exceeds this.length, the empty String "" is returned.

staticvalidate(b:Bytes, encoding:Encoding):Bool

Tells if b is a correctly encoded UTF8 byte sequence.