mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 10:19:19 +02:00
* Set ICU data dir if it is not set by the system. It fixes issues on newer Android versions.
* Added more predefined ICU versions. git-svn-id: trunk@39865 -
This commit is contained in:
parent
46b89f0ef9
commit
212eca24d1
@ -50,12 +50,13 @@ var
|
|||||||
u_strToLower: function (dest: PUnicodeChar; destCapacity: int32_t; src: PUnicodeChar; srcLength: int32_t; locale: PAnsiChar; var pErrorCode: UErrorCode): int32_t; cdecl;
|
u_strToLower: function (dest: PUnicodeChar; destCapacity: int32_t; src: PUnicodeChar; srcLength: int32_t; locale: PAnsiChar; var pErrorCode: UErrorCode): int32_t; cdecl;
|
||||||
u_strCompare: function (s1: PUnicodeChar; length1: int32_t; s2: PUnicodeChar; length2: int32_t; codePointOrder: UBool): int32_t; cdecl;
|
u_strCompare: function (s1: PUnicodeChar; length1: int32_t; s2: PUnicodeChar; length2: int32_t; codePointOrder: UBool): int32_t; cdecl;
|
||||||
u_strCaseCompare: function (s1: PUnicodeChar; length1: int32_t; s2: PUnicodeChar; length2: int32_t; options: uint32_t; var pErrorCode: UErrorCode): int32_t; cdecl;
|
u_strCaseCompare: function (s1: PUnicodeChar; length1: int32_t; s2: PUnicodeChar; length2: int32_t; options: uint32_t; var pErrorCode: UErrorCode): int32_t; cdecl;
|
||||||
|
u_getDataDirectory: function(): PAnsiChar; cdecl;
|
||||||
|
u_setDataDirectory: procedure(directory: PAnsiChar); cdecl;
|
||||||
|
|
||||||
ucol_open: function(loc: PAnsiChar; var status: UErrorCode): PUCollator; cdecl;
|
ucol_open: function(loc: PAnsiChar; var status: UErrorCode): PUCollator; cdecl;
|
||||||
ucol_close: procedure (coll: PUCollator); cdecl;
|
ucol_close: procedure (coll: PUCollator); cdecl;
|
||||||
ucol_strcoll: function (coll: PUCollator; source: PUnicodeChar; sourceLength: int32_t; target: PUnicodeChar; targetLength: int32_t): int32_t; cdecl;
|
ucol_strcoll: function (coll: PUCollator; source: PUnicodeChar; sourceLength: int32_t; target: PUnicodeChar; targetLength: int32_t): int32_t; cdecl;
|
||||||
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;
|
|
||||||
|
|
||||||
threadvar
|
threadvar
|
||||||
ThreadDataInited: boolean;
|
ThreadDataInited: boolean;
|
||||||
@ -496,12 +497,13 @@ end;
|
|||||||
|
|
||||||
function LoadICU: boolean;
|
function LoadICU: boolean;
|
||||||
const
|
const
|
||||||
ICUver: array [1..9] of ansistring = ('3_8', '4_2', '44', '46', '48', '50', '51', '53', '55');
|
ICUver: array [1..12] of ansistring = ('3_8', '4_2', '44', '46', '48', '50', '51', '53', '55', '56', '58', '60');
|
||||||
TestProcName = 'ucnv_open';
|
TestProcName = 'ucnv_open';
|
||||||
|
|
||||||
var
|
var
|
||||||
i: longint;
|
i: longint;
|
||||||
s: ansistring;
|
s: ansistring;
|
||||||
|
dir: PAnsiChar;
|
||||||
begin
|
begin
|
||||||
Result:=False;
|
Result:=False;
|
||||||
{$ifdef android}
|
{$ifdef android}
|
||||||
@ -543,6 +545,7 @@ begin
|
|||||||
// Trying versionless name
|
// Trying versionless name
|
||||||
if GetProcedureAddress(hlibICU, TestProcName) = nil then begin
|
if GetProcedureAddress(hlibICU, TestProcName) = nil then begin
|
||||||
// Unable to get ICU version
|
// Unable to get ICU version
|
||||||
|
SysLogWrite(ANDROID_LOG_ERROR, 'cwstring: Unable to get ICU version.');
|
||||||
UnloadICU;
|
UnloadICU;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
@ -558,13 +561,19 @@ begin
|
|||||||
if not GetIcuProc('u_strToLower', u_strToLower) then exit;
|
if not GetIcuProc('u_strToLower', u_strToLower) then exit;
|
||||||
if not GetIcuProc('u_strCompare', u_strCompare) then exit;
|
if not GetIcuProc('u_strCompare', u_strCompare) then exit;
|
||||||
if not GetIcuProc('u_strCaseCompare', u_strCaseCompare) then exit;
|
if not GetIcuProc('u_strCaseCompare', u_strCaseCompare) then exit;
|
||||||
|
if not GetIcuProc('u_getDataDirectory', u_getDataDirectory) then exit;
|
||||||
if not GetIcuProc('u_errorName', u_errorName) then exit;
|
if not GetIcuProc('u_setDataDirectory', u_setDataDirectory) then exit;
|
||||||
|
|
||||||
if not GetIcuProc('ucol_open', ucol_open, 1) then exit;
|
if not GetIcuProc('ucol_open', ucol_open, 1) then exit;
|
||||||
if not GetIcuProc('ucol_close', ucol_close, 1) then exit;
|
if not GetIcuProc('ucol_close', ucol_close, 1) then exit;
|
||||||
if not GetIcuProc('ucol_strcoll', ucol_strcoll, 1) then exit;
|
if not GetIcuProc('ucol_strcoll', ucol_strcoll, 1) then exit;
|
||||||
if not GetIcuProc('ucol_setStrength', ucol_setStrength, 1) then exit;
|
if not GetIcuProc('ucol_setStrength', ucol_setStrength, 1) then exit;
|
||||||
|
|
||||||
|
// Checking if ICU data dir is set
|
||||||
|
dir:=u_getDataDirectory();
|
||||||
|
if (dir = nil) or (dir^ = #0) then
|
||||||
|
u_setDataDirectory('/system/usr/icu');
|
||||||
|
|
||||||
Result:=True;
|
Result:=True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user