function TForm1.WideStringToDisplay(mWideString: WideString): string;
var
I: Integer;
S: string;
begin
Result := '';
S := '';
for I := 1 to Length(mWideString) do
begin
if Ord(mWideString[I]) in [32..127] then S := S + mWideString[I]
else
begin
if S <> '' then
begin
Result := Result + QuotedStr(S);
S := '';
end;
Result := Result + Format('#%d', [Ord(mWideString[I])]);
end;
if S <> '' then Result := Result + QuotedStr(S);
end;
end; { WideStringToDisplay }
function TForm1.DisplayToWideString(mDisplay: string): WideString;
var
I: Integer;
S: string;
B: Boolean;
begin
Result := '';
B := False;
mDisplay := mDisplay;
for I := 1 to Length(mDisplay) do
if B then
case mDisplay[I] of
'''':
begin
if S <> '' then Result := Result + StringReplace(S,'''''','''',[rfReplaceAll]);
if Copy(mDisplay,I + 1,1) = '''' then Result := Result + '''';
S := '';
B := False;
end;
else S := S + mDisplay[I];
end
else
case mDisplay[I] of
'#', '''':
begin
if S <> '' then Result := Result + WideChar(StrToIntDef(S,0));
S := '';
B := mDisplay[I] = '''';
end;
'$', '0'..'9', 'a'..'f', 'A'..'F':
S := S + mDisplay[I];
end;
if (not B) and (S <> '') then Result := Result + WideChar(StrToIntDef(S,0));
end; {DisplayToWideString }