utf8 ¶ Functions DecodeLastRune (Function) DecodeRune (Function) DecodeRune2 (Function) EncodeRune (Function) EncodeRune2 (Function) IsFullRune (Function) IsRuneStart (Function) IsValid (Function) IsValidRune (Function) ReduceSegment (Function) RuneCount (Function) RuneLen (Function) Globals Constants (GVL) Types RUNE (Alias)
Functions ¶ DecodeLastRune (Function) DecodeRune (Function) DecodeRune2 (Function) EncodeRune (Function) EncodeRune2 (Function) IsFullRune (Function) IsRuneStart (Function) IsValid (Function) IsValidRune (Function) ReduceSegment (Function) RuneCount (Function) RuneLen (Function)
DecodeRune (FUN) ¶ FUNCTION DecodeRune : RUNE Unpacks the first UTF-8 encoding in pbyData and returns the rune and its length in bytes. If pbyData is empty it returns ( c_diRuneError , udiLength=0 ). Otherwise, if the encoding is invalid, it returns ( c_diRuneError , udiLength=1` ). Both are impossible results for correct, non-empty UTF-8. An encoding is invalid if it is incorrect UTF-8, encodes a rune that is out of range, or is not the shortest possible UTF-8 encoding for the value. No other validation is performed. InOut: Scope Name Type Comment Return DecodeRune RUNE Input pbyData POINTER TO BYTE Pointer to the first byte in memory udiSize UDINT Memory size in byte Output udiLength UDINT Lenght of the rune in bytes
DecodeLastRune (FUN) ¶ FUNCTION DecodeLastRune : RUNE Unpacks the last UTF-8 encoding in pbyData and returns the rune and its position ( udiIndex ) and length ( udiLength ) in bytes. If pbyData is empty it returns ( c_diRuneError , udiLength=0 ). Otherwise, if the encoding is invalid, it returns ( c_diRuneError , udiLength=1` ). Both are impossible results for correct, non-empty UTF-8. An encoding is invalid if it is incorrect UTF-8, encodes a rune that is out of range, or is not the shortest possible UTF-8 encoding for the value. No other validation is performed. InOut: Scope Name Type Comment Return DecodeLastRune RUNE Input pbyData POINTER TO BYTE Pointer to the first byte in memory udiSize UDINT Size of the memory in bytes Output udiLength UDINT Length of the rune in bytes udiIndex UDINT Index of the last rune (depending to the bytes in memory)
DecodeRune2 (FUN) ¶ FUNCTION DecodeRune2 : RUNE Decodes a rune out of two segments and returns its length and offset. If rune is complete in the first segment, than no offset is returned. An encoding is invalid if it is incorrect UTF-8, encodes a rune that is out of range, or is not the shortest possible UTF-8 encoding for the value. No other validation is performed. InOut: Scope Name Type Comment Return DecodeRune2 RUNE Input pbyData POINTER TO BYTE Pointer to the first byte of the first segment udiSize UDINT Size of the first segment in bytes pbyData2 POINTER TO BYTE Pointer to the first byte of the second segment udiSize2 UDINT Size of the second segment in bytes Output udiLength UDINT Lenght of the rune in bytes udiOffset UDINT Offset of the second segment needed bytes
EncodeRune (FUN) ¶ FUNCTION EncodeRune : UDINT Writes into pbyData (which must be large enough) the UTF-8 encoding of diRune . It returns the number of bytes written. InOut: Scope Name Type Comment Return EncodeRune UDINT Input diRune RUNE Rune to be encoded pbyData POINTER TO BYTE Pointer to the first byte of memory udiSize UDINT Size of the memory in bytes
EncodeRune2 (FUN) ¶ FUNCTION EncodeRune2 : UDINT Encodes a rune in memory segments, if it doesn’t fit in the first segment than the second segment is used. The rune has to be valid, otherwise nothing is returned. The function returns the number of written bytes as well as the offset of the second memory segment. InOut: Scope Name Type Comment Return EncodeRune2 UDINT Input diRune RUNE The rune to be encoded pbyData POINTER TO BYTE Pointer to the first byte of the first segment udiSize UDINT Size of the first segment in bytes pbyData2 POINTER TO BYTE Pointer to the first byte of the second segment udiSize2 UDINT Size of the second segment in bytes Output udiOffset UDINT Offset of the second segment needed bytes
IsFullRune (FUN) ¶ FUNCTION IsFullRune : BOOL Reports whether the bytes in pbyData begin with a full UTF-8 encoding of a rune. An invalid encoding is considered a full rune since it will convert as a error rune. InOut: Scope Name Type Comment Return IsFullRune BOOL Input pbyData POINTER TO BYTE Pointer to the first byte of the memory udiSize UDINT Size of the memory in bytes
IsRuneStart (FUN) ¶ FUNCTION IsRuneStart : BOOL Reports whether byData could be the first byte of an encoded, possibly invalid rune. Second and subsequent bytes always have the top two bits set to 2#10xxxxxx . InOut: Scope Name Type Comment Return IsRuneStart BOOL Input byData BYTE Input value to be analyzed
IsValid (FUN) ¶ FUNCTION IsValid : BOOL Reports whether pbyData consists entirely of valid UTF-8-encoded runes. InOut: Scope Name Type Comment Return IsValid BOOL Input pbyData POINTER TO BYTE Pointer to the first byte of the memory udiSize UDINT Size of the memory in bytes