473,322 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

[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 9511
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Christopher H. Laco | last post by:
Long story longer. I need to get web user input into a backend system that a) only grocks single byte encoding, b) expectes the data transer to be 1 bytes = 1 character, and c) uses the HP Roman-6...
4
by: Ram | last post by:
Dear All, Good Day I am trying to convert a file which is generated on AS400 with codepage 00420 (arabic & English data combination) with no success. But using the same code( and changing 20420...
0
by: PowerPlane | last post by:
Hi, all Happy valentine I am struggling to insert an animated-gif into a CRichEditCtrl. Before I post this question here, I did some googling. And I found an article to introduce how to insert a...
0
by: Chip_VC | last post by:
Hi Guys, I use a CRichEditCtrl derived class in my project. I add text with a CRichEditCtrl ::ReplaceSel() call and images using IRichEditOle::InsertObject(). In order to keep the size of the...
0
by: Rachid1977 | last post by:
Hi, I like to use a conroller CRichEditCtrl in C++ in a Window, but this Window Visio Window and it derive of IUnknown (CVisioWindow), I want that an instance of CVisioWindow a Parent which...
6
by: msdnuniv | last post by:
Hello everybody, since days i try to convert Unicode-Strings in VB.NET to ANSI which should be processable in VB6 and converted to unicode again. It should be possible with any codepage, e.g....
17
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, Wide character and multi-byte character are two popular encoding schemes on Windows. And wide character is using unicode encoding scheme. But each time I feel confused when...
1
by: hugobotha | last post by:
Hi All, I have a problem when saving a text file as a html file in unicode and then google index the Unicode bom as well as I can not open these files. I have a asp page that takes another asp...
13
by: mario | last post by:
Hello! i stumbled on this situation, that is if I decode some string, below just the empty string, using the mcbs encoding, it succeeds, but if I try to encode it back with the same encoding it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.