QuickCheckCodepointsNormalized
Short summary
This function checks if a given codepoint array is already in the requested normalized form. If the result is YES, all codepoints are already normalized. If the result is MAYBE, then further checks or a normalization will be neccesary.
- Return type: NormalizationQuickCheckResult
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| codePoints | POINTER TO UnicodeCodePoint | pointer to the unnormalized codepoint sequence | input |
| codepointCount | UDINT | number of codepoints in the unnormalized codepoint sequence | input |
| formToCheck | NormalizationForm | NFD or NFC quickcheck | input |
| result | NormalizationQuickCheckResult | YES : codepoints are already normalized, NO : codepoints are not normalized | output |
Code
Declaration
FUNCTION INTERNAL QuickCheckCodepointsNormalized :NormalizationQuickCheckResult
VAR_INPUT
(* pointer to the unnormalized codepoint sequence *)
codePoints :POINTER TO UnicodeCodePoint;
(* number of codepoints in the unnormalized codepoint sequence *)
codepointCount :UDINT;
(* NFD or NFC quickcheck *)
formToCheck :NormalizationForm;
END_VAR
VAR_OUTPUT
(* YES : codepoints are already normalized, NO : codepoints are not normalized *)
result :NormalizationQuickCheckResult := NormalizationQuickCheckResult.YES;
END_VAR
VAR
lastCCC :UINT := 0;
currentCCC :UINT;
index :UDINT;
check :NormalizationQuickCheckResult;
END_VAR
Implementation
FOR index := 0 TO codepointCount - 1 DO
CheckCombiningMark( codePoint := ADR(codePoints[index]), canonicalCombiningClass => currentCCC);
IF ( (lastCCC > currentCCC) AND_THEN (currentCCC <> 0) ) THEN
result := NormalizationQuickCheckResult.NO;
QuickCheckCodepointsNormalized := result;
RETURN;
END_IF
CASE formToCheck OF
NormalizationForm.NFD:
result := IsCodepointAllowedNFD(ADR(codePoints[index]));
NormalizationForm.NFC:
result := IsCodepointAllowedNFC(ADR(codePoints[index]));
END_CASE
IF (result = NormalizationQuickCheckResult.NO) THEN
QuickCheckCodepointsNormalized := result;
RETURN;
END_IF
lastCCC := currentCCC;
END_FOR
QuickCheckCodepointsNormalized := result;