469,352 Members | 1,811 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

[MFC] CRichEditCtrl how to set codepage for Unicode?

In MFC, CRichEditCtrl contrl, I want to set the codepage for the control to
Unicode.

I used the following method to set codepage for it (only for ANSI or BIG5,
etc, not unicode). How should I change codepage to Unicode?

[Step 1]
Get the default character format. GetDefaultCharFormat(CHARFORMAT2& _cf)

[Step 2]
Modify received character format.

[Step 2.1]
Modify bCharSet, szFaceName, and dwMask member variables in _cf.

For the bCharSet, it should be one of the value of lfCharSet in LOGFONT
structure.
lfCharSet may be ANSI_CHARSET, CHINESEBIG5_CHARSET, TURKISH_CHARSET, etc.
I cannot find a value for Unicode.

[Step 3]
Set back to RichEdit Control. SetDefaultCharFormat(CHARFORMAT2& _cf).

Feb 14 '07 #1
5 9011
In MFC, CRichEditCtrl contrl, I want to set the codepage for the control to
Unicode.
....
Get the default character format. GetDefaultCharFormat(CHARFORMAT2& _cf)
Modify received character format.
Modify bCharSet, szFaceName, and dwMask member variables in _cf.
What you are changing for the font is the charset, not codepage.
See http://www.mihai-nita.net/20060806a.shtml

If you need Unicode support in the RTF control, the control itself should be
Unicode (the class should be RichEdit20W, not RichEdit20A).
See here: http://www.mihai-nita.net/20050709b.shtml
--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Feb 14 '07 #2
Thanks.

Do you know which font is suitable for Unicode?

Thanks.
Kevin Tang.

"Mihai N." wrote:
In MFC, CRichEditCtrl contrl, I want to set the codepage for the control to
Unicode.
....
Get the default character format. GetDefaultCharFormat(CHARFORMAT2& _cf)
Modify received character format.
Modify bCharSet, szFaceName, and dwMask member variables in _cf.
What you are changing for the font is the charset, not codepage.
See http://www.mihai-nita.net/20060806a.shtml

If you need Unicode support in the RTF control, the control itself should be
Unicode (the class should be RichEdit20W, not RichEdit20A).
See here: http://www.mihai-nita.net/20050709b.shtml
--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Feb 14 '07 #3
Do you know which font is suitable for Unicode?

There is no font covering all the Unicode ranges.

But Windows does a good job in selecting a font, and will even mix
various fonts to cover all your text.
Depending on what you want to do this might be enough, or not.

In general, you cannot properly select a font if you don't know the language
of the text. Knowing the Unicode value is not enough.
Example: the same Kanji is present in Chinese Simplified, Traditional and
Japanese. But a Japanese font cannot be used for Chinese Traditional, for
example.
--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Feb 15 '07 #4
Mihai N. wrote:
>>Do you know which font is suitable for Unicode?
In general, you cannot properly select a font if you don't know the language
of the text.
That's probably true with Asian languages. However, there are clearly
non-Unicode fonts that contain 256 characters at best, and there are
Unicode ones, covering all the Central and Eastern European languages,
Russian, Greek, etc.

Typically most of the Microsoft-provided TrueType fonts that come with
the OS are Unicode. That's Arial, Courier New, Tahoma, Times New Roman
at the minimum.

The US and European Windows don't have the Asian package installed by
default, but you can always choose to install it later. Many of the
fonts I have will never show Japanese characters, but the built-in
Microsoft fonts will do, after installing the Asian package.

Tom
Feb 15 '07 #5

My interpretation of the "Do you know which font is suitable for Unicode?"
question was Do you know which font can cover all the Unicode ranges?"
not "Do you know a Unicode font?"

I could have ask for more clarification and waste another day,
or restate the question as I understand it, which I did
("There is no font covering all the Unicode ranges.") and answer.

If I got the question wrong, Kevin can ask again.
But the answer to the question (as I understand it) is correct.

That's probably true with Asian languages. However, there are clearly
non-Unicode fonts that contain 256 characters at best, and there are
Unicode ones, covering all the Central and Eastern European languages,
Russian, Greek, etc.
....
Typically most of the Microsoft-provided TrueType fonts that come with
the OS are Unicode. That's Arial, Courier New, Tahoma, Times New Roman
at the minimum.
What makes a font unicode is not support for more than one script, or more
than 256 characters, but the presence of one of the Unicode cmap table
formats (see http://www.microsoft.com/typography/otspec/cmap.htm)

The US and European Windows don't have the Asian package installed by
default, but you can always choose to install it later. Many of the
fonts I have will never show Japanese characters, but the built-in
Microsoft fonts will do, after installing the Asian package.
Some of the MS fonts show Japanese after installing Asian support
not because the MS fonts are smarter, or Unicode, but because adding Asian
support also adds the proper font linking entries in the registry.
It can be done with your fonts too, if you are not afraid to play
with the registry (see HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\FontLink\SystemLink)

--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Feb 16 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Christopher H. Laco | last post: by
reply views Thread by Chip_VC | last post: by
reply views Thread by Rachid1977 | last post: by
17 posts views Thread by =?Utf-8?B?R2Vvcmdl?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.