473,554 Members | 2,865 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[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. GetDefaultCharF ormat(CHARFORMA T2& _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_CHA RSET, TURKISH_CHARSET , etc.
I cannot find a value for Unicode.

[Step 3]
Set back to RichEdit Control. SetDefaultCharF ormat(CHARFORMA T2& _cf).

Feb 14 '07 #1
5 9551
In MFC, CRichEditCtrl contrl, I want to set the codepage for the control to
Unicode.
....
Get the default character format. GetDefaultCharF ormat(CHARFORMA T2& _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. GetDefaultCharF ormat(CHARFORMA T2& _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_MACH INE\SOFTWARE\Mi crosoft\Windows
NT\CurrentVersi on\FontLink\Sys temLink)

--
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
687
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 codepage system wide. As much as it sounds good, UTF/Unicode encoding is not an option, nor is changing the codepage. Tackling the first is easy...
4
7114
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 to 708) I am able to convert a file from codepage ASMO 708 to windows based file and it is perfect. The following is the code I tried. i used 20420...
0
4773
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 bitmap into a RichEdit http://www.codeguru.com/richedit/richeditrc.htm I can use a timer/thread to replace my bitmap to show the animation....
0
951
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 content of the CRichEditCtrl object manageable, I remove the first half of the lines from the control from time to time. The memory used by those lines...
0
997
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 contain the control CRichEditCtrl instance!!!and this must visualize text in RTF. how I have to program, or is the choice of CRichEditCtrl OK???...
6
18040
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. somebody on a greek PC should be able to handle chinese strings -------------- VB.NET ---------------- 'On the vb.net side (I am pretty sure, it is...
17
10626
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 talking with another team -- codepage -- at the same time. I am more confused when I saw sometimes we need codepage parameter for wide character...
1
8348
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 template page and suck some data out of a database, I then create a text file, put this information in there and then save it as a text file except...
13
3666
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 surprisingly fails with a LookupError. This seems like something to be corrected? $ python Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04) on...
0
7573
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7778
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8008
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6114
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5412
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5135
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3538
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3525
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.