Page 1 of 1
unicode question!
Posted: Sat Nov 21, 2009 3:41 pm
by newfile
my project use delphi7 and TRichView1.915, first ,i paste Korean information to richviewedit, then i get infomation use function "GetItemTextW" from richviewedit, but result is "??", property "unicode" is set true,why it's,please help me ,tks!!!
Posted: Sat Nov 21, 2009 8:59 pm
by Sergey Tkachenko
Please send me a project to reproduce this problem.
PS: I recommend to update to newer version.
Posted: Mon Nov 23, 2009 2:38 am
by newfile
mail is send ,tks
Posted: Mon Nov 23, 2009 7:27 pm
by Sergey Tkachenko
1) Charset does not affect displaying Unicode text. If you get rectangles in place of some characters, this means that the font does not have required characters. In TRichView, charsets affect converting to/from Unicode. You use GetCurrentItemTextW to get Unicode text from Unicode item, so no conversion is performed, and Charset is not used at all.
2) You get a correct Unicode text in str: WideString. But you use
procedure ShowMessage(const Msg: string) to display it. This procedure cannot display Unicode text: it has a String, not WideString parameter.
This code displays Unicode string:
Code: Select all
var
str:WideString;
begin
str:=edtsend.GetCurrentItemTextW;
MessageBoxW(0, PWideChar(str), PWideChar(str), 0);
Posted: Tue Nov 24, 2009 2:39 am
by newfile
ths for you reply,i use "MessageBox " so as to debug " str:=edtsend.GetCurrentItemTextW", str debug result is "??"£¬but MessageBoxW Result is right.
Posted: Tue Nov 24, 2009 2:46 am
by newfile
How do I determine whether the font have required characters??
Posted: Tue Nov 24, 2009 5:04 pm
by Sergey Tkachenko
Using WinAPI function GetFontUnicodeRanges
Posted: Tue Nov 24, 2009 5:35 pm
by newfile
thank you!!!
copy "시험¡° to richviewedit,and do it;
delphi7:
var
str:WideString;
begin
str:=edtsend.GetCurrentItemTextW;
//str debug print is "??";
end;
delphi2010:
var
str:WideString;
begin
str:=edtsend.GetCurrentItemTextW;
//str debug print is "시험"£¬it is right
end;
delphi 7 is set "str:WideString; ", why str debug print is "??";
can i save "시험" to str and display??
Posted: Tue Nov 24, 2009 6:00 pm
by newfile
my richview have picture and text, i need get all unicode text and picture ,and generate my self html format and transport,and so i need find and get all item unicode text ,then generate ,now str is display "??",the result is bad,I do not understand the depth of Unicode£¬i hope you give me a simple example ,thank you!
Posted: Tue Nov 24, 2009 8:02 pm
by Sergey Tkachenko
1) Because Delphi 7 is not Unicode by itself, so it cannot display Unicode strings (convert them to ANSI)
2) If you need to get a plain text from the component, the simplest way is using GetAllText function from RVGetTextW unit (not from RVGetText!)
But why you cannot use RichView.SaveHTML or SaveHTMLEx to save HTML file? If you include rvsoUTF8 in the Options parameter of these functions, the resulting HTML will be Unicode (in UTF-8 encoding)
Posted: Wed Nov 25, 2009 12:10 am
by newfile
thank you very much,
1)i understand it .
2) begin, i use RichView.SaveHTML ,it's ok ,but html information is very large ,udp socket transport is limited , so i generate my simple
html use small html tag.
i has come to some most satisfactory solution,thank you again!
wish you day day happy