mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-11 18:49:14 +02:00
Merged revision(s) 31722, 31865 from trunk:
* android: Fixed ansi-unicode conversion when DefaultSystemCodePage is changed. ........ * Added predefined ICU versions for newer Android version. * Fixed search of unknown ICU versions. * Do UTF-8 conversion by RTL if ICU can not be loaded. ........ git-svn-id: branches/fixes_3_0@31917 -
This commit is contained in:
parent
decff7ad16
commit
08804c4d7c
@ -98,7 +98,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
InitThreadData;
|
InitThreadData;
|
||||||
if (cp = DefaultSystemCodePage) or (cp = CP_ACP) then
|
if (cp = CP_UTF8) or (cp = CP_ACP) then
|
||||||
Result:=DefConv
|
Result:=DefConv
|
||||||
else begin
|
else begin
|
||||||
if cp <> LastCP then begin
|
if cp <> LastCP then begin
|
||||||
@ -121,7 +121,8 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
conv:=GetConverter(cp);
|
conv:=GetConverter(cp);
|
||||||
if conv = nil then begin
|
if (conv = nil) and not ( (cp = CP_UTF8) or (cp = CP_ACP) ) then begin
|
||||||
|
// fallback implementation
|
||||||
DefaultUnicode2AnsiMove(source,dest,DefaultSystemCodePage,len);
|
DefaultUnicode2AnsiMove(source,dest,DefaultSystemCodePage,len);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
@ -129,12 +130,23 @@ begin
|
|||||||
len2:=len*3;
|
len2:=len*3;
|
||||||
SetLength(dest, len2);
|
SetLength(dest, len2);
|
||||||
err:=0;
|
err:=0;
|
||||||
len2:=ucnv_fromUChars(conv, PAnsiChar(dest), len2, source, len, err);
|
if conv <> nil then
|
||||||
|
len2:=ucnv_fromUChars(conv, PAnsiChar(dest), len2, source, len, err)
|
||||||
|
else begin
|
||||||
|
// Use UTF-8 conversion from RTL
|
||||||
|
cp:=CP_UTF8;
|
||||||
|
len2:=UnicodeToUtf8(PAnsiChar(dest), len2, source, len) - 1;
|
||||||
|
end;
|
||||||
if len2 > Length(dest) then begin
|
if len2 > Length(dest) then begin
|
||||||
SetLength(dest, len2);
|
SetLength(dest, len2);
|
||||||
err:=0;
|
err:=0;
|
||||||
len2:=ucnv_fromUChars(conv, PAnsiChar(dest), len2, source, len, err);
|
if conv <> nil then
|
||||||
|
len2:=ucnv_fromUChars(conv, PAnsiChar(dest), len2, source, len, err)
|
||||||
|
else
|
||||||
|
len2:=UnicodeToUtf8(PAnsiChar(dest), len2, source, len) - 1;
|
||||||
end;
|
end;
|
||||||
|
if len2 < 0 then
|
||||||
|
len2:=0;
|
||||||
SetLength(dest, len2);
|
SetLength(dest, len2);
|
||||||
SetCodePage(dest, cp, False);
|
SetCodePage(dest, cp, False);
|
||||||
end;
|
end;
|
||||||
@ -150,7 +162,8 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
conv:=GetConverter(cp);
|
conv:=GetConverter(cp);
|
||||||
if conv = nil then begin
|
if (conv = nil) and not ( (cp = CP_UTF8) or (cp = CP_ACP) ) then begin
|
||||||
|
// fallback implementation
|
||||||
DefaultAnsi2UnicodeMove(source,DefaultSystemCodePage,dest,len);
|
DefaultAnsi2UnicodeMove(source,DefaultSystemCodePage,dest,len);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
@ -158,12 +171,21 @@ begin
|
|||||||
len2:=len;
|
len2:=len;
|
||||||
SetLength(dest, len2);
|
SetLength(dest, len2);
|
||||||
err:=0;
|
err:=0;
|
||||||
len2:=ucnv_toUChars(conv, PUnicodeChar(dest), len2, source, len, err);
|
if conv <> nil then
|
||||||
|
len2:=ucnv_toUChars(conv, PUnicodeChar(dest), len2, source, len, err)
|
||||||
|
else
|
||||||
|
// Use UTF-8 conversion from RTL
|
||||||
|
len2:=Utf8ToUnicode(PUnicodeChar(dest), len2, source, len) - 1;
|
||||||
if len2 > Length(dest) then begin
|
if len2 > Length(dest) then begin
|
||||||
SetLength(dest, len2);
|
SetLength(dest, len2);
|
||||||
err:=0;
|
err:=0;
|
||||||
len2:=ucnv_toUChars(conv, PUnicodeChar(dest), len2, source, len, err);
|
if conv <> nil then
|
||||||
|
len2:=ucnv_toUChars(conv, PUnicodeChar(dest), len2, source, len, err)
|
||||||
|
else
|
||||||
|
len2:=Utf8ToUnicode(PUnicodeChar(dest), len2, source, len) - 1;
|
||||||
end;
|
end;
|
||||||
|
if len2 < 0 then
|
||||||
|
len2:=0;
|
||||||
SetLength(dest, len2);
|
SetLength(dest, len2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -485,7 +507,7 @@ var
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
ICUver: array [1..5] of ansistring = ('3_8', '4_2', '44', '46', '48');
|
ICUver: array [1..9] of ansistring = ('3_8', '4_2', '44', '46', '48', '50', '51', '53', '55');
|
||||||
TestProcName = 'ucnv_open';
|
TestProcName = 'ucnv_open';
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -511,7 +533,7 @@ begin
|
|||||||
// Finding unknown ICU version
|
// Finding unknown ICU version
|
||||||
Val(ICUver[High(ICUver)], i);
|
Val(ICUver[High(ICUver)], i);
|
||||||
repeat
|
repeat
|
||||||
Inc(i, 2);
|
Inc(i);
|
||||||
Str(i, s);
|
Str(i, s);
|
||||||
s:='_' + s;
|
s:='_' + s;
|
||||||
if GetProcedureAddress(hlibICU, TestProcName + s) <> nil then begin
|
if GetProcedureAddress(hlibICU, TestProcName + s) <> nil then begin
|
||||||
|
Loading…
Reference in New Issue
Block a user