[在Delphi 7中(由于很多原因,我无法在Xe中转换应用程序)我必须从存储在UTF8字段(在Firebird 2.5表中)的中文字符串生成RTF字符串。
例如,我将包含字符串“史蒂芬·克拉申”的UTF8值的字段值读为有线字符串,然后我应该将其转换为这样的字符串'ca \'b7 \'b5 \'d9 \'b7 \'d2 \ f1 \'b7 \ f0 \'bf \'cb \'c0 \'ad \'c9 \'ea \
前一个中文字符串的UTF8字段的值为'å²è',芬·克拋‰ç”³'
我该怎么做?
我进行了大量搜索,但没有找到解决方案。
请给我一些建议以解决此问题。
感谢Massimo
[几天后,我终于找到了一个受本文启发的解决方案Getting char value in Delphi 7以及此站点上可用的十进制转换https://www.branah.com/unicode-converter
从字段加载UTF8值后,我使用UTF8Decode,然后转换为Rtf ..
var
fUnicode : widestring;
function UnicodeToRtf(const S: WideString): string;
var
I: Integer;
begin
Result := '';
for I := 1 to Length(S) do
Result := Result + '\u' + IntToStr(Word(S[I]))+'?';
end;
begin
fUnicode := Utf8Decode(DbChineseField.AsString);
fRtfString := UnicodetoRtf(fUnicode);
.....
end;