|
@@ -55,6 +55,8 @@ var
|
|
ucol_setStrength: procedure (coll: PUCollator; strength: int32_t); cdecl;
|
|
ucol_setStrength: procedure (coll: PUCollator; strength: int32_t); cdecl;
|
|
u_errorName: function (code: UErrorCode): PAnsiChar; cdecl;
|
|
u_errorName: function (code: UErrorCode): PAnsiChar; cdecl;
|
|
|
|
|
|
|
|
+threadvar
|
|
|
|
+ ThreadDataInited: boolean;
|
|
DefConv, LastConv: PUConverter;
|
|
DefConv, LastConv: PUConverter;
|
|
LastCP: TSystemCodePage;
|
|
LastCP: TSystemCodePage;
|
|
DefColl: PUCollator;
|
|
DefColl: PUCollator;
|
|
@@ -71,6 +73,22 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure InitThreadData;
|
|
|
|
+var
|
|
|
|
+ err: UErrorCode;
|
|
|
|
+ col: PUCollator;
|
|
|
|
+begin
|
|
|
|
+ if (hlibICU = 0) or ThreadDataInited then
|
|
|
|
+ exit;
|
|
|
|
+ ThreadDataInited:=True;
|
|
|
|
+ DefConv:=OpenConverter('utf8');
|
|
|
|
+ err:=0;
|
|
|
|
+ col:=ucol_open(nil, err);
|
|
|
|
+ if col <> nil then
|
|
|
|
+ ucol_setStrength(col, 2);
|
|
|
|
+ DefColl:=col;
|
|
|
|
+end;
|
|
|
|
+
|
|
function GetConverter(cp: TSystemCodePage): PUConverter;
|
|
function GetConverter(cp: TSystemCodePage): PUConverter;
|
|
var
|
|
var
|
|
s: ansistring;
|
|
s: ansistring;
|
|
@@ -79,6 +97,7 @@ begin
|
|
Result:=nil;
|
|
Result:=nil;
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
+ InitThreadData;
|
|
if (cp = DefaultSystemCodePage) or (cp = CP_ACP) then
|
|
if (cp = DefaultSystemCodePage) or (cp = CP_ACP) then
|
|
Result:=DefConv
|
|
Result:=DefConv
|
|
else begin
|
|
else begin
|
|
@@ -219,6 +238,7 @@ begin
|
|
Result:=_CompareStr(s1, s2);
|
|
Result:=_CompareStr(s1, s2);
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
+ InitThreadData;
|
|
if DefColl <> nil then
|
|
if DefColl <> nil then
|
|
Result:=ucol_strcoll(DefColl, PUnicodeChar(s1), Length(s1), PUnicodeChar(s2), Length(s2))
|
|
Result:=ucol_strcoll(DefColl, PUnicodeChar(s1), Length(s1), PUnicodeChar(s2), Length(s2))
|
|
else
|
|
else
|
|
@@ -470,7 +490,6 @@ const
|
|
TestProcName = 'ucnv_open';
|
|
TestProcName = 'ucnv_open';
|
|
|
|
|
|
var
|
|
var
|
|
- err: UErrorCode;
|
|
|
|
i: longint;
|
|
i: longint;
|
|
s: ansistring;
|
|
s: ansistring;
|
|
begin
|
|
begin
|
|
@@ -528,12 +547,6 @@ begin
|
|
if not _GetProc('ucol_close', ucol_close, hlibICUi18n) then exit;
|
|
if not _GetProc('ucol_close', ucol_close, hlibICUi18n) then exit;
|
|
if not _GetProc('ucol_strcoll', ucol_strcoll, hlibICUi18n) then exit;
|
|
if not _GetProc('ucol_strcoll', ucol_strcoll, hlibICUi18n) then exit;
|
|
if not _GetProc('ucol_setStrength', ucol_setStrength, hlibICUi18n) then exit;
|
|
if not _GetProc('ucol_setStrength', ucol_setStrength, hlibICUi18n) then exit;
|
|
-
|
|
|
|
- DefConv:=OpenConverter('utf8');
|
|
|
|
- err:=0;
|
|
|
|
- DefColl:=ucol_open(nil, err);
|
|
|
|
- if DefColl <> nil then
|
|
|
|
- ucol_setStrength(DefColl, 2);
|
|
|
|
end;
|
|
end;
|
|
|
|
|
|
initialization
|
|
initialization
|