![]() SUBSTR_UTF8 |
![]() DEVELOPER |
![]() |
Purpose |
Take a substring from another string treating it as UTF-8 characters. |
Syntax |
#Success = SUBSTR_UTF8(String-Expression, Start, End, Substring-Variable) |
Operation |
Returns one if successful or zero if failure (e.g. encountered invalid UTF-8). The first argument is a string expression that may contain UTF-8 characters. The second argument "Start" is the (one-based) UTF-8 character position in the first argument to start the substring from. The third argument "End" is the (one-based) UTF-8 character position in the first argument to be the end character in the substring. The fourth argument must be a string variable that is overwritten with the substring. |
Remarks |
The same variable may be used for both first and last arguments. The fourth argument cannot be a value variable. If the function fails then the fourth argument may be partially updated with the substring. This function is different to "SUBSTR" which treats the string as bytes and may take part of UTF-8 character leaving the substring invalid. |
Example |
if SUBSTR_UTF8($Entries(#I), 1, 5, $Prefix) then umsg("$Prefix ='" + $Prefix + "'", -1) else umsg("SUBSTR_UTF8 failed - invalid UTF-8?", -1) endif |
Topic ID: 520334