IsUTF16CharValid function
Returns True if the specified values are a valid UTF-16 character (codepoint).
Declaration
function IsUTF16CharValid(AChar: WideChar; ANextChar: WideChar)
: BooleanArguments
AChar | First UTF-16 code examined in the method. |
ANextChar | Next UTF-16 code examined in the method. |
Function result
Returns False if AChar is #0 or AChar and ANextChar are unpaired surrogates.
Description
Based on the specification defined by the Unicode consortium, at:
https://unicode.org/faq/utf_bom.html#utf16-7
Q: Are there any 16-bit values that are invalid?
A: Unpaired surrogates are invalid in UTFs. These include any value in the range D800 to DBFF not followed by a value in the range DC00 to DFFF, or any value in the range DC00 to DFFF not preceded by a value in the range D800 to DBFF. [AF]
If ANextChar is set to #0 there is no next character.
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
