Functions - lang.string

codePointCompare

Lexicographically compare strings using their Unicode code points. This will allow strings to be ordered in a consistent and well-defined way, but the ordering will not typically be consistent with cultural expectations for sorted order.

concat

Concatenate all the strs. Empty string if empty.

endsWith

Returns true if str end with substr.

fromBytes

Convert back to a string from its UTF-8 representation in bytes.

fromCodePointInts

Creates a string from an array of ints representing its code points. Returns an error if any member of codePoints is negative or greater than 0x10FFFF or is a surrogate (i.e. in the range 0xD800 or 0xDFFF inclusive).

getCodePoint

Returns the unicode codepoint at index i.

indexOf

Returns the index of the first occurrence of substr in the part of the str starting at startIndex or nil if it does not occur.

iterator

Returns an iterator over the string The iterator will return the substrings of length 1 in order.

join

Returns a new string composed of strs elements joined together with separator.

length

Returns the length of the string.

startsWith

Returns true if str starts with substr.

substring

Returns a string that is a substring of this string.

toBytes

Represents str as an array of bytes using UTF-8.

toCodePointInts

Returns an array with an int for each code point in str.

toLowerAscii

Return A-Z into a-z and leave other characters unchanged.

toUpperAscii

Return a-z into A-Z and leave other characters unchanged.

trim

Remove ASCII white space characters (0x9...0xD, 0x20) from start and end of str.

codePointCompare

(string str1, string str2)

returns int

Lexicographically compare strings using their Unicode code points. This will allow strings to be ordered in a consistent and well-defined way, but the ordering will not typically be consistent with cultural expectations for sorted order.

Parameters

  • str1 string
  • string to compare

  • str2 string
  • string to compare

  • Return Type

    (int)
  • whether str1 is greater than str2

concat

(string[] strs)

returns string

Concatenate all the strs. Empty string if empty.

Parameters

  • strs string[]
  • strings to concat

  • Return Type

    (string)
  • concatanated string

endsWith

(string str, string substr)

returns boolean

Returns true if str end with substr.

Parameters

  • Return Type

    (boolean)
  • whether str ends with substr

fromBytes

(byte[] bytes)

returns string | error

Convert back to a string from its UTF-8 representation in bytes.

Parameters

  • bytes byte[]
  • UTF-8 byte array

  • Return Type

    (string | error)
  • bytes converted to string or error

fromCodePointInts

(int[] codePoints)

returns string | error

Creates a string from an array of ints representing its code points. Returns an error if any member of codePoints is negative or greater than 0x10FFFF or is a surrogate (i.e. in the range 0xD800 or 0xDFFF inclusive).

Parameters

  • codePoints int[]

getCodePoint

(string str, int i)

returns int

Returns the unicode codepoint at index i.

Parameters

  • i int
  • code point index

  • Return Type

    (int)
  • code point

indexOf

(string str, string substr, int startIndx)

returns int?

Returns the index of the first occurrence of substr in the part of the str starting at startIndex or nil if it does not occur.

Parameters

  • substr string
  • sub string to search for

  • startIndx int - 0
  • Return Type

    (int?)
  • index of first substr occurrence or nil

iterator

(string str)

returns $anonType$2

Returns an iterator over the string The iterator will return the substrings of length 1 in order.

Parameters

join

(string separator, string[] strs)

returns string

Returns a new string composed of strs elements joined together with separator.

Parameters

  • strs string[]
  • strings to join

  • Return Type

    (string)
  • joined string

length

(string str)

returns int

Returns the length of the string.

Parameters

  • Return Type

    (int)
  • length of the str

startsWith

(string str, string substr)

returns boolean

Returns true if str starts with substr.

Parameters

  • Return Type

    (boolean)
  • whether str starts with substr

substring

(string str, int startIndex, int endIndex)

returns string

Returns a string that is a substring of this string.

Parameters

  • startIndex int
  • the beginning index, inclusive.

  • endIndex int
  • the ending index, exclusive.

  • Return Type

    (string)
  • specified substring.

toBytes

(string str)

returns byte[]

Represents str as an array of bytes using UTF-8.

Parameters

  • Return Type

    (byte[])
  • UTF-8 byte array

toCodePointInts

(string str)

returns int[]

Returns an array with an int for each code point in str.

Parameters

  • Return Type

    (int[])
  • CodePoint array

toLowerAscii

(string str)

returns string

Return A-Z into a-z and leave other characters unchanged.

Parameters

  • Return Type

    (string)
  • lower Ascii cased string

toUpperAscii

(string str)

returns string

Return a-z into A-Z and leave other characters unchanged.

Parameters

  • Return Type

    (string)
  • Ascii upper cased string

trim

(string str)

returns string

Remove ASCII white space characters (0x9...0xD, 0x20) from start and end of str.

Parameters

  • Return Type

    (string)
  • trimmed string