unicode question!

General TRichView support forum. Please post your questions here
Post Reply
newfile
Posts: 15
Joined: Fri Jan 18, 2008 8:36 am

unicode question!

Post 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!!!
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Please send me a project to reproduce this problem.

PS: I recommend to update to newer version.
newfile
Posts: 15
Joined: Fri Jan 18, 2008 8:36 am

Post by newfile »

mail is send ,tks
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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);
newfile
Posts: 15
Joined: Fri Jan 18, 2008 8:36 am

Post 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.
newfile
Posts: 15
Joined: Fri Jan 18, 2008 8:36 am

Post by newfile »

How do I determine whether the font have required characters??
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Using WinAPI function GetFontUnicodeRanges
newfile
Posts: 15
Joined: Fri Jan 18, 2008 8:36 am

Post 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??
newfile
Posts: 15
Joined: Fri Jan 18, 2008 8:36 am

Post 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!
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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)
newfile
Posts: 15
Joined: Fri Jan 18, 2008 8:36 am

Post 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
Post Reply