This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Chinese RTFText in Scrollable Text Control
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 12, 2008
03:26 AM
Chinese RTFText in Scrollable Text Control
I have a custom dialog to summary the selections the user has made in the UI.
This dialog contains a Scrollable text control.
In this control, I want to display RTF text. This works fine for all languages except for Chinese(Traditional/Simplified).
This has probably something to do with my RTF Initialisation which should be modified when running on a Chinese OS but I don't know what to change.
My current initialization looks like this:
function void RTFInit(Rtf)
begin
Rtf->Indent = 0;
Rtf->Contents =
"{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033" +
"{\\colortbl;\\red0\\green0\\blue0;\\red128\\green128\\blue128;}" +
"{\\fonttbl{\\f0\\fswiss\\fcharset0 Arial;}}" +
"\\viewkind4\\uc1\\pard\\f0\\fs18";
Rtf->InText = FALSE;
end;
I've already tried to modify the deflang1033 parameter into 'deflang2052' or 'deflang1028' but this doesn't work. My RTF text in the control isn't displayed correctly(see attached screenshot).
Does someone knows how that I need to modify the RTF initialisation string to display the text correctly on Chinese OS?
This dialog contains a Scrollable text control.
In this control, I want to display RTF text. This works fine for all languages except for Chinese(Traditional/Simplified).
This has probably something to do with my RTF Initialisation which should be modified when running on a Chinese OS but I don't know what to change.
My current initialization looks like this:
function void RTFInit(Rtf)
begin
Rtf->Indent = 0;
Rtf->Contents =
"{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033" +
"{\\colortbl;\\red0\\green0\\blue0;\\red128\\green128\\blue128;}" +
"{\\fonttbl{\\f0\\fswiss\\fcharset0 Arial;}}" +
"\\viewkind4\\uc1\\pard\\f0\\fs18";
Rtf->InText = FALSE;
end;
I've already tried to modify the deflang1033 parameter into 'deflang2052' or 'deflang1028' but this doesn't work. My RTF text in the control isn't displayed correctly(see attached screenshot).
Does someone knows how that I need to modify the RTF initialisation string to display the text correctly on Chinese OS?
(3) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 12, 2008
10:33 AM
I don't know much about RTF itself, but \ansicpg1252 looks like it's specifying the Western European codepage which will be unable to handle Chinese characters. Per a quick search on "2052 codepage" it looks like you might want to try 936 or 950 instead of 1252.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 13, 2008
02:16 AM
MichaelU wrote:
I don't know much about RTF itself, but \ansicpg1252 looks like it's specifying the Western European codepage which will be unable to handle Chinese characters. Per a quick search on "2052 codepage" it looks like you might want to try 936 or 950 instead of 1252.
Michael,
I tried it already with the codepage nr. 936 but this still doesn't display the chinese RTF correctly.
I will need to take a furthur look into this...
Thanks for the information however.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 19, 2008
04:22 AM
For those who are interested... I found the solution to this problem.
The initialisation of the RTF had nothing to do with the problem... this was correct.
The problem is to encode the decimal value of the (chinese) character into RTFCode. For chinese characters, the solution is Sprintf(Result, "\\u%d?", n) where n is the decimal value of the chinese character.
So a possible function could look like this:
function STRING RTFEncodeChar(ch)
INT n;
STRING Result;
begin
n = ch;
if (n < 0x020) then
switch (n)
case 0: Result = "";
case 9: Result = "\\tab ";
case 10: Result = "\\par ";
case 13: Result = "";
default: Sprintf(Result, "\\'%2lx", n);
endswitch;
elseif (n > 0x07f) && (n < 0x0ff) then
Sprintf(Result, "\\'%2lx", n);
elseif (n > 0x0ff) && (n < 0xffff) then
Sprintf(Result, "\\u%d?", n);
else
if ((ch == "\\") || (ch == "{") || (ch == "}")) then
Sprintf(Result, "\\'%2lx", n);
else
Result = " ";
Result[0] = ch;
endif;
endif;
return Result;
end;
The initialisation of the RTF had nothing to do with the problem... this was correct.
The problem is to encode the decimal value of the (chinese) character into RTFCode. For chinese characters, the solution is Sprintf(Result, "\\u%d?", n) where n is the decimal value of the chinese character.
So a possible function could look like this:
function STRING RTFEncodeChar(ch)
INT n;
STRING Result;
begin
n = ch;
if (n < 0x020) then
switch (n)
case 0: Result = "";
case 9: Result = "\\tab ";
case 10: Result = "\\par ";
case 13: Result = "";
default: Sprintf(Result, "\\'%2lx", n);
endswitch;
elseif (n > 0x07f) && (n < 0x0ff) then
Sprintf(Result, "\\'%2lx", n);
elseif (n > 0x0ff) && (n < 0xffff) then
Sprintf(Result, "\\u%d?", n);
else
if ((ch == "\\") || (ch == "{") || (ch == "}")) then
Sprintf(Result, "\\'%2lx", n);
else
Result = " ";
Result[0] = ch;
endif;
endif;
return Result;
end;
![](/skins/images/A5EADE085F77DE82FB3B14D6B307AE6A/responsive_peak/images/icon_anonymous_message.png)