TRTFExporter enhancement
Original Reporter info from Mantis: zgabrovski
-
Reporter name: Zdravko Gabrovski
Original Reporter info from Mantis: zgabrovski
- Reporter name: Zdravko Gabrovski
Description:
When you try to export any kind of text data, that contains a non-ascii unicode characters (for example - cyrillic symbols), it is not possible to open a document into Microsoft word.
Word reports that a document is corrupted.
The reason is, that RTF format native does not support UTF8 character encoding.
The only way to avoid this is to replace that kind of symbols with combination of \uxxxxxxx?, where xxxx is a symbol code in Unicode format.
My proposal is to replace a existing code of method
function TCustomRTFExporter.EscapeRTF(S: String): String; (fprtxexport.pas, line111)
With following one:
function TCustomRTFExporter.EscapeRTF(S: String): String;
var
SS : UnicodeString;
Ch : UnicodeChar;
begin
SS := UTF8Decode( S );
Result := '';
For Ch in SS do begin
if Ch In ['{', '}', '\'] then
Result := Result + '\';
if Ord( Ch ) > 255 then
Result := Result +'\u'+Ord( Ch ).ToString+'?'
else
Result := Result + Utf8Encode( Ch );
end;
end;
This fix a problem and everything is OK.
Steps to reproduce:
As described above.
Mantis conversion info:
- Mantis ID: 36231
- OS: all
- OS Build: all
- Build: fcldb - trunk
- Platform: all
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 43356 (#c6f53adf)
- Target version: 3.2.0