A Scripting Language for Web, Linux and Windows

A Scripting Language for Web, Linux and Windows

String functions

The following string functions are supported. The string functions are compatible with theire PHP pendants. Note: String functions work byte orientated. UTF8 and Unicode characters can contain more than one byte. You have to be careful with fix positions when splitting a string. See also Datatypes.

Function/Arguments Return Description
strlen (string string) string Return the length of the given string in bytes.
strcmp (string string1, string string2) number Compare string1 and string2. Return values: 1 = string1 > string2, -1 = string1 < string2, 0 = string1 equal to string2
strpos (string searchIn, string seachFor) number Return the position of searchFor in seachIn as number beginning from 0. If searchFor was not found then false is returned.
substr (string string, number start [, number length]) string Return a part of a given string beginning from start with optional length. If length is not set then the end of the string will be returned. If start is negative then it counts from the end of the string.
strtoupper (string string) string Return a string in upper case. Only Ascii characters are converted to upper case.
strtolower (string string) string Return a string in lower case. Only Ascii characters are converted to lower case.
trim (string string [, string chars]) string Remove leading and endig spaces, line feeds and tabulators from string. If parameter chars is given then only the specified characters will be removed. The cleaned string will be returned.
rtrim (string string [, string chars]) string Same as trim() but only remove ending spaces from right side of the string.
ltrim (string string [, string chars]) string Same as trim() but only remove leading spaces from left side of the string.
str_replace (mixed searchFor, mixed replaceWith, string inString ) string Replace one ore more parts in a string. searchFor and replaceWith can be strings or arrays. For example: str_replace (array("programming", "I"), array ("coding", "You"), "I love V1 programming.") will replace multiple parts and produce the returned string "You love V1 coding".
explode (string delimiter, string string) array Return an array of splitted parts of a string. The string will be splitted in parts separated by the delimiter.
chr (number asciiNumber) string Return the character of a given asciiNumber. For example chr(32) will return space ' '.
utf8_encode (string string) string Convert Latin2 formatted string to UTF8 and return.
utf8_decode (string string) string Convert UTF8 formatted string to Latin2 and return.
bin2hex (string string) string Convert binary content of a string to hexadecimal format. For examle bin2hex ("V1") will return string "5631".
hex2bin (string string) string Convert hexadecimal string to binary string. For examle hex2bin ("5631") will return string "V1".
crc32 (string string) number Return the CRC32 checksum of a string.

Binary strings

A string can contain binary data (also zero byte). The length of a string is always detected with strlen() function.

The following functions can be used to parse and format binary data.

Function/Arguments Return Description
binparse (string string, number format [, number pos=0, bool signed=0, number nbo=0] ) number Parse a binary string and return the parsed number. format can be following: 1 = 8 Bit (char), 2 = 16 Bit (short), 3 = 32 Bit (int), 4 = 64 Bit (long long), 5 = 32 Bit (float), 6 = 64 Bit (double). Optional parameter pos set the position where parsing will start. If signed is true, then the number will returned signed, default is unsigned. If nbo is 1, then 32 Bit and 16 Bit will be converted from network byte order to host byte order. If nbo is 2, then 32 Bit and 16 Bit will be converted from host byte order to network byte order. If nbo is 0, then 32 Bit and 16 Bit are parsed in native machine format.
binformat (number number, number format [, number nbo=0] ) string Convert a number into a binary format and return the binary string. format can be following: 1 = 8 Bit (char), 2 = 16 Bit (short), 3 = 32 Bit (int), 4 = 64 Bit (long long), 5 = 32 Bit (float), 6 = 64 Bit (double). If optional parameter nbo is 1, then 32 Bit and 16 Bit will be converted from network byte order to host byte order. If nbo is 2, then 32 Bit and 16 Bit will be converted from host byte order to network byte order. If nbo is 0, then 32 Bit and 16 Bit are formatted in native machine format.

Note that 64 Bit integer numbers cannot be loaded completely into internal floating point representation. See datatypes.

back to Home

V1 Version 0.95 - Documentation generated Sun, 02 Dec 2018 16:29