TrimCodepoints
Short summary
This function removes whitespace both from the start and the end of a unicode character sequence. It returns the new character count.
- Return type:
UDINT
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| codepoints | POINTER TO UnicodeCodePoint | pointer to the codepoint sequence | input |
| codepointCount | UDINT | number of codepoints in the sequence | input |
| newCodepointCount | UDINT | number of codepoints after trimming | output |
Code
Declaration
FUNCTION TrimCodepoints :UDINT
VAR_INPUT
(* pointer to the codepoint sequence *)
codepoints :POINTER TO UnicodeCodePoint;
(* number of codepoints in the sequence *)
codepointCount :UDINT;
END_VAR
VAR_OUTPUT
(* number of codepoints after trimming *)
newCodepointCount :UDINT;
END_VAR
VAR
index, whitespaceCount :UDINT;
END_VAR
Implementation
newCodepointCount := codepointCount;
TrimCodepoints := codepointCount;
RETURN ((codepoints = 0) OR_ELSE (codepointcount = 0));
newCodepointCount := TrimRightCodepoints(
codepoints := codepoints,
codepointCount := codepointCount
);
newCodepointCount := TrimLeftCodepoints(
codepoints := codepoints,
codepointCount := newCodepointCount
);
TrimCodepoints := newCodepointCount;