From ae302f31b20732fe6a1a67dd1e4c01e3faecc4b9 Mon Sep 17 00:00:00 2001 From: juha Date: Sun, 8 Jun 2014 23:48:37 +0000 Subject: [PATCH] Converter: Do not convert ansi control characters to unicode. Issue #26274, patch from Jesus Reyes. git-svn-id: trunk@45417 - --- converter/missingpropertiesdlg.pas | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/converter/missingpropertiesdlg.pas b/converter/missingpropertiesdlg.pas index 70af4a46d1..f8083ae9cd 100644 --- a/converter/missingpropertiesdlg.pas +++ b/converter/missingpropertiesdlg.pas @@ -211,6 +211,29 @@ function TDFMConverter.FixWideString(aInStream, aOutStream: TMemoryStream): TMod Result:=SysToUTF8(chr(c)); end; + function FixControlChars(const s:string): string; + var + i: Integer; + InControl: boolean; + begin + Result := ''; + InControl := false; + for i:=1 to Length(s) do begin + if s[i] < #32 then begin + if not InControl then + result := result + ''''; + result := result + '#' + IntToStr(ord(s[i])); + InControl := true; + end else begin + if InControl then begin + result := result + ''''; + InControl := false; + end; + Result := Result + s[i]; + end; + end; + end; + function CollectString(const InS: string; var Ind: integer): string; // Collect a string composed of quoted strings and unicode numbers like #xxx var @@ -235,7 +258,7 @@ function TDFMConverter.FixWideString(aInStream, aOutStream: TMemoryStream): TMod else Break; until False; - Result:=QuotedStr(Result); + Result:=FixControlChars(QuotedStr(Result)); end; var