mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-20 17:29:26 +01:00
compiler: use widestrings for json resource file generation
git-svn-id: trunk@26477 -
This commit is contained in:
parent
d7fb3be2af
commit
3aec5da7a7
@ -32,7 +32,7 @@ implementation
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
SysUtils,
|
SysUtils,
|
||||||
cclasses,
|
cclasses,widestr,
|
||||||
cutils,globtype,globals,systems,
|
cutils,globtype,globals,systems,
|
||||||
symconst,symtype,symdef,symsym,
|
symconst,symtype,symdef,symsym,
|
||||||
verbose,fmodule,ppu,
|
verbose,fmodule,ppu,
|
||||||
@ -298,7 +298,8 @@ uses
|
|||||||
R: TResourceStringItem;
|
R: TResourceStringItem;
|
||||||
ResFileName: string;
|
ResFileName: string;
|
||||||
I: Integer;
|
I: Integer;
|
||||||
C: Char;
|
C: tcompilerwidechar;
|
||||||
|
W: pcompilerwidestring;
|
||||||
begin
|
begin
|
||||||
ResFileName:=ChangeFileExt(current_module.ppufilename,'.rsj');
|
ResFileName:=ChangeFileExt(current_module.ppufilename,'.rsj');
|
||||||
message1 (general_i_writingresourcefile,ExtractFileName(ResFileName));
|
message1 (general_i_writingresourcefile,ExtractFileName(ResFileName));
|
||||||
@ -316,31 +317,32 @@ uses
|
|||||||
while assigned(R) do
|
while assigned(R) do
|
||||||
begin
|
begin
|
||||||
write(f, '{"hash":',R.Hash,',"name":"',R.Name,'","value":"');
|
write(f, '{"hash":',R.Hash,',"name":"',R.Name,'","value":"');
|
||||||
for I := 0 to R.Len - 1 do
|
initwidestring(W);
|
||||||
|
ascii2unicode(R.Value,R.Len,current_settings.sourcecodepage,W);
|
||||||
|
for I := 0 to W^.len - 1 do
|
||||||
begin
|
begin
|
||||||
C := R.Value[I];
|
C := W^.Data[I];
|
||||||
case C of
|
case C of
|
||||||
'"', '\', '/':
|
Ord('"'), Ord('\'), Ord('/'):
|
||||||
write(f, '\', C);
|
write(f, '\', C);
|
||||||
#8:
|
8:
|
||||||
write(f, '\b');
|
write(f, '\b');
|
||||||
#9:
|
9:
|
||||||
write(f, '\t');
|
write(f, '\t');
|
||||||
#10:
|
10:
|
||||||
write(f, '\n');
|
write(f, '\n');
|
||||||
#13:
|
13:
|
||||||
write(f, '\r');
|
write(f, '\r');
|
||||||
#12:
|
12:
|
||||||
write(f, '\f');
|
write(f, '\f');
|
||||||
else
|
else
|
||||||
// todo: this is wrong for now
|
if (C < 32) or (C > 127) then
|
||||||
// we need to have C as unicode char, not a single byte char
|
write(f,'\u',hexStr(Longint(C), 4))
|
||||||
//if (C < #32) or (C > #127) then
|
else
|
||||||
// write(f,'\u',hexStr(Longint(C), 4))
|
write(f,Chr(C));
|
||||||
//else
|
|
||||||
write(f,C);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
donewidestring(W);
|
||||||
write(f,'"}');
|
write(f,'"}');
|
||||||
R:=TResourceStringItem(R.Next);
|
R:=TResourceStringItem(R.Next);
|
||||||
if assigned(R) then
|
if assigned(R) then
|
||||||
@ -356,7 +358,7 @@ uses
|
|||||||
begin
|
begin
|
||||||
if (tsym(p).typ=constsym) and
|
if (tsym(p).typ=constsym) and
|
||||||
(tconstsym(p).consttyp=constresourcestring) then
|
(tconstsym(p).consttyp=constresourcestring) then
|
||||||
List.Concat(tResourceStringItem.Create(TConstsym(p)));
|
List.Concat(TResourceStringItem.Create(TConstsym(p)));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user