mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2026-02-25 06:28:45 +01:00
o set the code page of the temporary "text" file to utf-8 for writestr with
unicodestring/widestring as destination, so that no data loss can occur
(+ properly deal with cases whereby part of an utf-8 character is
written to the textbuf in this case)
o explicitly pass the code page of the destination ansistring for writestr
with ansistring as destination and set it for the temporary "text" file
o set the code page of the text file for readstr
git-svn-id: trunk@26317 -
34 lines
675 B
ObjectPascal
34 lines
675 B
ObjectPascal
{$codepage utf8}
|
||
|
||
{$ifdef unix}
|
||
uses
|
||
cwstring;
|
||
{$endif}
|
||
|
||
type
|
||
ts866 = type ansistring(866);
|
||
var
|
||
u: unicodestring;
|
||
s: utf8string;
|
||
rs: ts866;
|
||
p: pointer;
|
||
i: longint;
|
||
begin
|
||
DefaultSystemCodePage:=CP_ASCII;
|
||
s:='§èà£ù';
|
||
rs:=ts866('Популярные фото');
|
||
writestr(u,s,1,s,rs);
|
||
if u <>'§èà£ù1§èà£ùПопулярные фото' then
|
||
halt(1);
|
||
getmem(p,length(s)-1);
|
||
s:='';
|
||
for i:=1 to (256 div 3) do
|
||
s:=s+utf8string('㒨');
|
||
s:=s+utf8string('㒨');
|
||
{ check that splitting the last 㒨 into two parts during writestr doesn't cause a
|
||
conversion error }
|
||
writestr(u,s);
|
||
if utf8string(u)<>s then
|
||
halt(2);
|
||
end.
|