mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-19 00:09:26 +02:00
* fixed writing of widestrings
git-svn-id: trunk@7645 -
This commit is contained in:
parent
8523bdc831
commit
ceaaa0e552
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -7008,6 +7008,7 @@ tests/test/tvarset1.pp svneol=native#text/plain
|
|||||||
tests/test/tw6727.pp svneol=native#text/plain
|
tests/test/tw6727.pp svneol=native#text/plain
|
||||||
tests/test/twide1.pp svneol=native#text/plain
|
tests/test/twide1.pp svneol=native#text/plain
|
||||||
tests/test/twide2.pp svneol=native#text/plain
|
tests/test/twide2.pp svneol=native#text/plain
|
||||||
|
tests/test/twide3.pp svneol=native#text/plain
|
||||||
tests/test/twrstr1.pp svneol=native#text/plain
|
tests/test/twrstr1.pp svneol=native#text/plain
|
||||||
tests/test/twrstr2.pp svneol=native#text/plain
|
tests/test/twrstr2.pp svneol=native#text/plain
|
||||||
tests/test/twrstr3.pp svneol=native#text/plain
|
tests/test/twrstr3.pp svneol=native#text/plain
|
||||||
|
@ -623,6 +623,7 @@ Procedure fpc_Write_Text_WideStr (Len : Longint; Var f : Text; const S : WideStr
|
|||||||
}
|
}
|
||||||
var
|
var
|
||||||
SLen : longint;
|
SLen : longint;
|
||||||
|
a: ansistring;
|
||||||
begin
|
begin
|
||||||
If (pointer(S)=nil) or (InOutRes<>0) then
|
If (pointer(S)=nil) or (InOutRes<>0) then
|
||||||
exit;
|
exit;
|
||||||
@ -632,7 +633,9 @@ begin
|
|||||||
SLen:=Length(s);
|
SLen:=Length(s);
|
||||||
If Len>SLen Then
|
If Len>SLen Then
|
||||||
fpc_WriteBlanks(f,Len-SLen);
|
fpc_WriteBlanks(f,Len-SLen);
|
||||||
fpc_WriteBuffer(f,PChar(AnsiString(S))^,SLen);
|
a:=s;
|
||||||
|
{ length(a) can be > slen, e.g. after utf-16 -> utf-8 }
|
||||||
|
fpc_WriteBuffer(f,pchar(a)^,length(a));
|
||||||
end;
|
end;
|
||||||
fmInput: InOutRes:=105
|
fmInput: InOutRes:=105
|
||||||
else InOutRes:=103;
|
else InOutRes:=103;
|
||||||
|
32
tests/test/twide3.pp
Normal file
32
tests/test/twide3.pp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{$codepage utf-8}
|
||||||
|
|
||||||
|
{$mode objfpc}
|
||||||
|
uses
|
||||||
|
{$ifdef unix}
|
||||||
|
cwstring,
|
||||||
|
{$endif}
|
||||||
|
sysutils;
|
||||||
|
|
||||||
|
{$i+}
|
||||||
|
|
||||||
|
var
|
||||||
|
t: text;
|
||||||
|
w: widestring;
|
||||||
|
a: ansistring;
|
||||||
|
|
||||||
|
begin
|
||||||
|
assign(t,'twide3.txt');
|
||||||
|
rewrite(t);
|
||||||
|
writeln(t,'łóżka');
|
||||||
|
close(t);
|
||||||
|
reset(t);
|
||||||
|
try
|
||||||
|
readln(t,a);
|
||||||
|
w:=a;
|
||||||
|
if (w<>'łóżka') then
|
||||||
|
raise Exception.create('wrong string read');
|
||||||
|
finally
|
||||||
|
close(t);
|
||||||
|
erase(t);
|
||||||
|
end;
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user