1 2function IsCJK_Unified_Ideographs(ACodePoint : Cardinal) : Boolean;inline; 3begin 4 Result := (ACodePoint >= $4E00) and (ACodePoint <= $9FCC); // $9FFF 5end; 6 7function IsCJK_Compatibility_Ideographs(ACodePoint : Cardinal) : Boolean;inline; 8begin 9 Result := (ACodePoint >= $F900) and (ACodePoint <= $FAFF); 10end; 11 12function IsCJK_Unified_Ideographs_Extension_A(ACodePoint : Cardinal) : Boolean;inline; 13begin 14 Result := (ACodePoint >= $3400) and (ACodePoint <= $4DB5); // $4DBF 15end; 16 17function IsCJK_Unified_Ideographs_Extension_B(ACodePoint : Cardinal) : Boolean;inline; 18begin 19 Result := (ACodePoint >= $20000) and (ACodePoint <= $2A6D6); // $2A6DF 20end; 21 22function IsCJK_Unified_Ideographs_Extension_C(ACodePoint : Cardinal) : Boolean;inline; 23begin 24 Result := (ACodePoint >= $2A700) and (ACodePoint <= $2B734); // $2B73F 25end; 26 27function IsCJK_Unified_Ideographs_Extension_D(ACodePoint : Cardinal) : Boolean;inline; 28begin 29 Result := (ACodePoint >= $2B740) and (ACodePoint <= $2B81D); // $2B81F 30end; 31 32function IsCJK_Compatibility_Ideographs_Supplement(ACodePoint : Cardinal) : Boolean;inline; 33begin 34 Result := (ACodePoint >= $2F800) and (ACodePoint <= $2FA1F); 35end; 36 37procedure DeriveWeight(const ACodePoint : Cardinal; AResult : PUCA_PropWeights); 38const 39 BASE_1 = Word($FB40); 40 BASE_2 = Word($FB80); 41 BASE_3 = Word($FBC0); 42var 43 base : Word; 44begin 45 if IsCJK_Unified_Ideographs(ACodePoint) or IsCJK_Compatibility_Ideographs(ACodePoint) then 46 base := BASE_1 47 else if IsCJK_Unified_Ideographs_Extension_A(ACodePoint) or 48 IsCJK_Unified_Ideographs_Extension_B(ACodePoint) or 49 IsCJK_Unified_Ideographs_Extension_C(ACodePoint) or 50 IsCJK_Unified_Ideographs_Extension_D(ACodePoint) or 51 IsCJK_Compatibility_Ideographs_Supplement(ACodePoint) 52 then begin 53 base := BASE_2; 54 end else begin 55 base := BASE_3; 56 end; 57 58 59 AResult[0].Weights[0] := base + (ACodePoint shr 15); 60 AResult[0].Weights[1] := $20; 61 AResult[0].Weights[2] := $2; 62 63 AResult[1].Weights[0] := (ACodePoint and $7FFF) or $8000; 64 AResult[1].Weights[1] := 0; 65 AResult[1].Weights[2] := 0; 66end; 67