Displaying unicode value in MFC CEdit text box
-
Dear All, I developed a project by setting the Character Set option (Project Properties) to "Not Set" in Visual C++. Now one of my class in the project needs Unicode character set support and if I change the Character set option in the Project properties then it displays several errors on the text declaration for the other class files. It will be too difficult for me to modify the other class files according to Unicode character set. Can anyone please advice me to change the Character set for that specific class alone. I will be very grateful if someone helps me. Thanks in Advance. Bhanu
-
Dear All, I developed a project by setting the Character Set option (Project Properties) to "Not Set" in Visual C++. Now one of my class in the project needs Unicode character set support and if I change the Character set option in the Project properties then it displays several errors on the text declaration for the other class files. It will be too difficult for me to modify the other class files according to Unicode character set. Can anyone please advice me to change the Character set for that specific class alone. I will be very grateful if someone helps me. Thanks in Advance. Bhanu
Just build your application for Unicode. In the preprocessor settings, remove
_MBCS
and add_UNICODE
(additionally addUNICODE
if it is a non-MFC app). You may get further help with those "many errors", if you give precise details of them.It is a crappy thing, but it's life -^ Carlo Pallini
-
Dear All, I developed a project by setting the Character Set option (Project Properties) to "Not Set" in Visual C++. Now one of my class in the project needs Unicode character set support and if I change the Character set option in the Project properties then it displays several errors on the text declaration for the other class files. It will be too difficult for me to modify the other class files according to Unicode character set. Can anyone please advice me to change the Character set for that specific class alone. I will be very grateful if someone helps me. Thanks in Advance. Bhanu
You can use the
MultiByteToWide
char to convert the required strings to unicode. Or you can explicitly use the wide version of the APIs, for example,GetWindowTextW
etc. Usewchar_t
instead ofchar
. Usewcscpy
instead ofstrcpy
. Also constant string must be preceded with L (L"hello world")«_Superman_» I love work. It gives me something to do between weekends.
-
You can use the
MultiByteToWide
char to convert the required strings to unicode. Or you can explicitly use the wide version of the APIs, for example,GetWindowTextW
etc. Usewchar_t
instead ofchar
. Usewcscpy
instead ofstrcpy
. Also constant string must be preceded with L (L"hello world")«_Superman_» I love work. It gives me something to do between weekends.
The problem is that I already created the project without setting the Character set and I used declarations such as
CString str = ""; char temp[20];
. In addition to this I also used strcpy, strlen like methods. If I change the Character Set in the Project properties to "Unicode" then I need to change all the above and this is not at all simple. Even though if I change all the strings, some of my classes does not support Unicode char set. Now I am in deep trouble to solve this issue. The real work for me now is to display the characters such as ►♂↨∟↑•↕ in a text box. Please tell me and help me how can I display these characters without changing the Character set in project properties. P.S : I already using Character set as "Not Set" Please help me :( Bhanu
-
Just build your application for Unicode. In the preprocessor settings, remove
_MBCS
and add_UNICODE
(additionally addUNICODE
if it is a non-MFC app). You may get further help with those "many errors", if you give precise details of them.It is a crappy thing, but it's life -^ Carlo Pallini
I have given the information in another reply.
-
The problem is that I already created the project without setting the Character set and I used declarations such as
CString str = ""; char temp[20];
. In addition to this I also used strcpy, strlen like methods. If I change the Character Set in the Project properties to "Unicode" then I need to change all the above and this is not at all simple. Even though if I change all the strings, some of my classes does not support Unicode char set. Now I am in deep trouble to solve this issue. The real work for me now is to display the characters such as ►♂↨∟↑•↕ in a text box. Please tell me and help me how can I display these characters without changing the Character set in project properties. P.S : I already using Character set as "Not Set" Please help me :( Bhanu
bhanu_8509 wrote:
char temp[20];
use TCHAR instead of char!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
-
Just build your application for Unicode. In the preprocessor settings, remove
_MBCS
and add_UNICODE
(additionally addUNICODE
if it is a non-MFC app). You may get further help with those "many errors", if you give precise details of them.It is a crappy thing, but it's life -^ Carlo Pallini
you didn't reply to his question.. humm busy with work!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
-
bhanu_8509 wrote:
char temp[20];
use TCHAR instead of char!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
Never mind - my own stupidity is the source of every "problem" - Mixturecheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You
I already told that it is not possible to change all the datatypes and string assignments and some of my classes doesn't support Unicode. Please give me a good solution.
-
The problem is that I already created the project without setting the Character set and I used declarations such as
CString str = ""; char temp[20];
. In addition to this I also used strcpy, strlen like methods. If I change the Character Set in the Project properties to "Unicode" then I need to change all the above and this is not at all simple. Even though if I change all the strings, some of my classes does not support Unicode char set. Now I am in deep trouble to solve this issue. The real work for me now is to display the characters such as ►♂↨∟↑•↕ in a text box. Please tell me and help me how can I display these characters without changing the Character set in project properties. P.S : I already using Character set as "Not Set" Please help me :( Bhanu
Like I said before use the wide versions of the API only for those strings.
«_Superman_» I love work. It gives me something to do between weekends.
-
Like I said before use the wide versions of the API only for those strings.
«_Superman_» I love work. It gives me something to do between weekends.
Hey Bhanu,, Y dont you try out this,, Say you wanna display "↨↔♀☺☻♥♦♣" on the MFC window.. create an array of type unsigend short with the decimal values of these symbols.say, wchar_t mySymbols[]={8616, 8595, ...., ...., ...., 0000}; //(make sure array ends with 0000); //this unicode values u can get from MSWord[Menu->Insert->Symbols) //then CString symbolText(mySymbols); M_displaytext=symbolText; or M_displaytext=SetWindowText(symbolText); .. think this will work out... -regards aravind sn
-
Hey Bhanu,, Y dont you try out this,, Say you wanna display "↨↔♀☺☻♥♦♣" on the MFC window.. create an array of type unsigend short with the decimal values of these symbols.say, wchar_t mySymbols[]={8616, 8595, ...., ...., ...., 0000}; //(make sure array ends with 0000); //this unicode values u can get from MSWord[Menu->Insert->Symbols) //then CString symbolText(mySymbols); M_displaytext=symbolText; or M_displaytext=SetWindowText(symbolText); .. think this will work out... -regards aravind sn
The CEdit control displays only ??. Please advice some other way.
wchar_t mySymbols[]={9664, 9824, 0000};
CString symbolText(mySymbols);
Edit.SetWindowText(symbolText); -
The CEdit control displays only ??. Please advice some other way.
wchar_t mySymbols[]={9664, 9824, 0000};
CString symbolText(mySymbols);
Edit.SetWindowText(symbolText);nope i tried it before sending the last post, also make sure u have used the macros _UNICODE and UNICODE, y dont u give it a go for variable of type CString of that EditBox and then m_EditMessage=symbolText; but the Edit control has to work,,,i wonder, also check whether it can read the unicodes if(symbolText.GetAt(0) == 0xFEFF) { Edit.SetWindowText(symbolText); } else MessageBox("\nOoops Sorry,, I gave UP..!!!:)");