* Do not use DOS code pages for Android. Now all CP string tests pass on Android.

git-svn-id: branches/targetandroid@23390 -
This commit is contained in:
yury 2013-01-15 11:55:24 +00:00
parent a5182d6487
commit 4cec8df547
4 changed files with 68 additions and 32 deletions

View File

@ -11,8 +11,15 @@ uses
cwstring;
{$endif}
const
{$ifdef android}
OemCP = 1251;
{$else}
OemCP = 866;
{$endif}
type
TOEMStr = type AnsiString(866);
TOEMStr = type AnsiString(OemCP);
{$ifndef FPC}
TSystemCodePage = Word;
const
@ -54,9 +61,9 @@ begin
TestCodeConvRaw(s, CP_UTF8);
TestCodeConvAnsi(u8, CP_UTF8);
TestCodeConvAnsi(s, CP_UTF8);
// converts to 866
// converts to OemCP
oemstr := u8;
TestCodeConvRaw(oemstr, 866);
TestCodeConvRaw(oemstr, OemCP);
TestCodeConvAnsi(oemstr, DefaultSystemCodePage);
s := 'test';
TestCodeConvRaw(s, CP_UTF8);
@ -67,5 +74,5 @@ begin
// outputs in source codepage instead of OEM
TestCodeConvRaw('привет', CP_UTF8);
// outputs in OEM codepage
TestCodeConvRaw(TOEMStr('привет'), 866);
TestCodeConvRaw(TOEMStr('привет'), OemCP);
end.

View File

@ -4,15 +4,26 @@ uses
cwstring,
{$endif unix}
SysUtils;
const
{$ifdef android}
cp1 = 1251;
cp2 = 1252;
cp3 = 65001;
{$else}
cp1 = 866;
cp2 = 850;
cp3 = 1251;
{$endif}
type
ts866 = type AnsiString(866);
ts850 = type AnsiString(850);
ts1251 = type AnsiString(1251);
ts1 = type AnsiString(cp1);
ts2 = type AnsiString(cp2);
ts3 = type AnsiString(cp3);
var
a : ts1251;
b : ts850;
c, d : ts866;
a : ts3;
b : ts2;
c, d : ts1;
begin
a := 'al';
b := 'b2';
@ -21,32 +32,32 @@ begin
//without "DestS" in the array
c := '';
c := a + b;
if (StringCodePage(c) <> 866) then
if (StringCodePage(c) <> cp1) then
halt(1);
c := '';
c := a + d;
if (StringCodePage(c) <> 866) then
if (StringCodePage(c) <> cp1) then
halt(2);
c := '';
c := d + b;
if (StringCodePage(c) <> 866) then
if (StringCodePage(c) <> cp1) then
halt(3);
//with empty "DestS" in the array
c := '';
c := c + a ;
if (StringCodePage(c) <> 866) then
if (StringCodePage(c) <> cp1) then
halt(4);
c := '';
c := c + d ;
if (StringCodePage(c) <> 866) then
if (StringCodePage(c) <> cp1) then
halt(5);
//with "DestS" in the array at the start
c := c + a ;
if (StringCodePage(c) <> 866) then
if (StringCodePage(c) <> cp1) then
halt(6);
//with "DestS" in the array, not at the start
c := a + c;
if (StringCodePage(c) <> 866) then
if (StringCodePage(c) <> cp1) then
halt(7);
WriteLn('ok');

View File

@ -5,9 +5,16 @@ uses
cwstring,
{$endif unix}
SysUtils;
const
{$ifdef android}
cp = 1251;
{$else}
cp = 866;
{$endif android}
type
ts866 = type AnsiString(866);
ts866 = type AnsiString(cp);
var
a, b, c, d : ts866;
begin
@ -17,20 +24,20 @@ begin
//without "DestS" in the array
d := a + b + c;
if (StringCodePage(d) <> 866) then
if (StringCodePage(d) <> cp) then
halt(1);
//with empty "DestS" in the array
d := '';
d := d + a + b + c;
if (StringCodePage(d) <> 866) then
if (StringCodePage(d) <> cp) then
halt(2);
//with "DestS" in the array at the start
d := d + b + c;
if (StringCodePage(d) <> 866) then
if (StringCodePage(d) <> cp) then
halt(3);
//with "DestS" in the array, not at the start
d := a + b + d + c;
if (StringCodePage(d) <> 866) then
if (StringCodePage(d) <> cp) then
halt(4);
WriteLn('ok');

View File

@ -6,14 +6,25 @@ uses
{$endif unix}
SysUtils;
const
{$ifdef android}
cp1 = 1251;
cp2 = 1252;
cp3 = 65001;
{$else}
cp1 = 866;
cp2 = 850;
cp3 = 1251;
{$endif}
type
ts866 = type AnsiString(866);
ts850 = type AnsiString(850);
ts1251 = type AnsiString(1251);
ts1 = type AnsiString(cp1);
ts2 = type AnsiString(cp2);
ts3 = type AnsiString(cp3);
var
a : ts1251;
b : ts850;
c, d : ts866;
a : ts3;
b : ts2;
c, d : ts1;
begin
a := 'al';
b := 'b2';
@ -21,20 +32,20 @@ begin
//without "DestS" in the array
d := a + b + c;
if (StringCodePage(d) <> 866) then
if (StringCodePage(d) <> cp1) then
halt(1);
//with empty "DestS" in the array
d := '';
d := d + a + b + c;
if (StringCodePage(d) <> 866) then
if (StringCodePage(d) <> cp1) then
halt(2);
//with "DestS" in the array at the start
d := d + a + b + c;
if (StringCodePage(d) <> 866) then
if (StringCodePage(d) <> cp1) then
halt(3);
//with "DestS" in the array, not at the start
d := a + b + d + c;
if (StringCodePage(d) <> 866) then
if (StringCodePage(d) <> cp1) then
halt(4);
WriteLn('ok');