GetRecompositionFromCodepointsHangul
Short summary
This function looks for a recomposition of two given code points in Hangul.
Even if the used algorithm is able to map 3 jamos in Form <L,V,T> to <LVT>, only two points are alllowed to check,
as it can be called recursivly. (<L,V> => <LV>, <LV,T> => <LVT>)
If no recomposition is possible, the method returns FALSE.
To find out how it works, check out the unicode standard, section 3.12.
- Return type:
BOOL
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| codePointBase | POINTER TO UnicodeCodePoint | base codepoint (starter) ), // base codepoint, , ( combining codepoint | input |
| codePointComb | POINTER TO UnicodeCodePoint | base codepoint// combination mark codepoint, , // combination mark codepoint | input |
| result | UnicodeCodePoint | - | output |
Code
Declaration
FUNCTION INTERNAL GetRecompositionFromCodepointsHangul : BOOL
VAR_INPUT
(* base codepoint (starter) *)
codePointBase: POINTER TO UnicodeCodePoint; // base codepoint
(* combining codepoint *)
codePointComb: POINTER TO UnicodeCodePoint; // combination mark codepoint
END_VAR
VAR_OUTPUT
result: UnicodeCodePoint;
END_VAR
VAR
indexL, indexV, indexT, indexS :UnicodeCodePoint;
END_VAR
Implementation
GetRecompositionFromCodepointsHangul := FALSE;
RETURN((codePointBase = 0) OR_ELSE (codePointComb = 0));
// 1. check to see if two current characters are L and V
indexL := codePointBase^ - HangulCommonConstants.L_BASE;
IF ((indexL >= 0) AND_THEN (indexL < HangulCommonConstants.L_COUNT)) THEN
indexV := codePointComb^ - HangulCommonConstants.V_BASE;
IF ((indexV >= 0) AND_THEN (indexV < HangulCommonConstants.V_COUNT)) THEN
result := HangulCommonConstants.S_BASE + ((indexL * HangulCommonConstants.V_COUNT + indexV) * HangulCommonConstants.T_COUNT);
GetRecompositionFromCodepointsHangul := TRUE;
RETURN;
END_IF
END_IF
// 2. check to see if two current characters are LV and T
indexS := codePointBase^ - HangulCommonConstants.S_BASE;
IF ((indexS >= 0)
AND_THEN (indexS < HangulCommonConstants.S_COUNT)
AND_THEN (indexS MOD HangulCommonConstants.T_COUNT = 0))
THEN
indexT := codePointComb^ - HangulCommonConstants.T_BASE;
IF ((indexT >= 0) AND_THEN (indexT < HangulCommonConstants.T_COUNT)) THEN
result := codePointBase^ + indexT;
GetRecompositionFromCodepointsHangul := TRUE;
RETURN;
END_IF
END_IF