String functions

These functions read and edit strings or parts of strings. Individual characters within a character string (for instance the string variable word) can be read in the form word[i]. The smallest index is zero. A string cannot be written or overwritten on a character-by-character basis, however.

Whereas word is of type string, word[i] is of type char.

WinCC OA string functions work Byte-oriented and independent of the coding type of the used characters. Comparisons of character strings (for example >,< ) are always done Byte by Byte. Due to this reason you might get unexpected results when you for example compare two strings, one using ISO standard coding and the other using UTF-8 coding.

For example, when processing a string using UTF-8 coding in the format of "%10s" into Cyrillic characters (one character is coded with 2 Bytes), then a string with 5 Cyrillic characters (each being 2 Bytes long) is the result.

For more information please refer to list with all available languages and coding and fonts in WinCC OA.

ISO projects cannot be created anymore. Create UTF-8 projects instead.

String Methods

The String object provides following methods:

Method Description
"at" Returns the character at the given index idx in the string.
"chop" Removes n characters from the end of the string.
"clear" Empties the string.
"contains" Returns true if this string contains an occurrence of the string s, otherwise false.
"count" Returns the number of (potentially overlapping) occurrences of the string s in this string.
"endsWith" Returns true if the string ends with s, otherwise false.
"indexOf" Returns the index position of the first occurrence of the string s in this string.
"insert" Inserts the string s at the given index pos.
"isEmpty" Returns true if the string is empty.
"lastIndexOf" Returns the index position of the last occurrence of the string s in this string.
"left" Returns a substring that contains the n leftmost characters of the string.
"length" Returns the number of Unicode characters.
"mid" Returns a string that contains n characters of this string, starting at the specified pos index.
"remove" Removes n characters from the string, starting at the given pos index.
"replace" Replaces n characters beginning at index pos with the string after.
"right" Returns a substring that contains the n rightmost characters of the string.
"split" Splits the string into substrings wherever a separator occurs, and returns the list of those strings.
"startsWith" Returns true if the string starts with s, otherwise false.
"toLower" Returns a lowercase copy of the string.
"toUpper" Returns an uppercase copy of the string.
"trim" Removes whitespace from the start and the end.
"trimmed" Produces a trimmed, new instance of the string.

String Functions

The following functions are available for strings:

You can find the Unicode string functions in the following table:

The uni string functions return characters, NOT bytes.