UpperCaseUtf8
Short summary
This function converts the lower case characters in the given UTF8 string to upper case
Example:
myString :String(10) := 'Test' ;
------------------
UpperCaseUtf8(
stringAddress := ADR(myString)
);
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| stringAddress | POINTER TO BYTE | pointer to the utf-8 string | input |
| buffersize | UDINT | size of the string variable in bytes | input |
Code
Declaration
FUNCTION UpperCaseUtf8
VAR_INPUT
(*pointer to the utf-8 string*)
stringAddress :POINTER TO BYTE;
(* size of the string variable in bytes *)
buffersize :UDINT := 0;
END_VAR
VAR
stringLength :UDINT;
codepoints :POINTER TO UnicodeCodePoint;
codepointCount :UDINT;
END_VAR
Implementation
stringLength := GetUtf8StringLength(stringAddress);
RETURN (stringLength = 0);
codepoints := __NEW(UnicodeCodepoint, stringLength);
RETURN(codepoints = 0);
GetCodepointsFromUtf8String(
utf8StringAddress := stringAddress,
utf8StringByteCount := stringLength,
codePointBuffer := codepoints,
bufferSize := stringLength*SIZEOF(Unicodecodepoint),
codePointsCount => codepointCount
);
GetUpperCaseForCodepoint(
addressOfCodePoints := codepoints,
codePointCount := codepointCount
);
Tc2_System.MEMSET(stringAddress, 0, MAX(stringLength, buffersize));
(*buffersize is stringLength + 1 as the string terminator is not counted in string length*)
GetUtf8StringFromCodepoints(
addressOfCodePoints := codepoints,
codePointCount := codepointCount,
utf8StringBuffer := stringAddress,
bufferSize := MAX( stringLength+1, buffersize )
);
__DELETE(codepoints);