简体   繁体   中英

How do I add Unicode support to a CRichEditCtrl?

My application used to use an MFC CEdit control and we had no problems with wide character (Unicode) strings. After switching to a CRichEditCtrl, it seems that Unicode is no longer supported. Chinese characters become "??" and so forth. I have read that CRichEditCtrl uses RichEdit* under the hood and I have played around with trying to cast the pointer, but nothing works.

I thought it could be the font, but I can certainly write Unicode into the control using the ALT key method, just when they are saved into the model and written back, they are "????".

Is there a hidden property somewhere, some manual setting that I have to do when initializing the dialog that will enable Unicode?

I found out that MFC Automatically uses RichEdit 1.0. Unless one uses a RichEdit 2.0, 3.0, or 4.0 implementation, one will not have true Unicode support by the rich edit. I was able to change the properties in the resource file manually: Change the class name from "RICHEDIT" to "RichEdit20W" for RichEdit 2.0 (with Unicode support).

Voila! Unicode support!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM