unicode question!
unicode question!
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!!!
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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:
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);
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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??
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??
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!
-
- Site Admin
- Posts: 17566
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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)
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)