Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Displaying unicode value in MFC CEdit text box

Displaying unicode value in MFC CEdit text box

Scheduled Pinned Locked Moved C / C++ / MFC
c++
12 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B bhanu_8509

    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

    R Offline
    R Offline
    Rajesh R Subramanian
    wrote on last edited by
    #2

    Just build your application for Unicode. In the preprocessor settings, remove _MBCS and add _UNICODE (additionally add UNICODE 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

    B T 2 Replies Last reply
    0
    • B bhanu_8509

      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

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #3

      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. Use wchar_t instead of char. Use wcscpy instead of strcpy. Also constant string must be preceded with L (L"hello world")

      «_Superman_» I love work. It gives me something to do between weekends.

      B 1 Reply Last reply
      0
      • _ _Superman_

        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. Use wchar_t instead of char. Use wcscpy instead of strcpy. Also constant string must be preceded with L (L"hello world")

        «_Superman_» I love work. It gives me something to do between weekends.

        B Offline
        B Offline
        bhanu_8509
        wrote on last edited by
        #4

        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

        T _ 2 Replies Last reply
        0
        • R Rajesh R Subramanian

          Just build your application for Unicode. In the preprocessor settings, remove _MBCS and add _UNICODE (additionally add UNICODE 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

          B Offline
          B Offline
          bhanu_8509
          wrote on last edited by
          #5

          I have given the information in another reply.

          1 Reply Last reply
          0
          • B bhanu_8509

            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

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #6

            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" - Mixture

            cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

            B 1 Reply Last reply
            0
            • R Rajesh R Subramanian

              Just build your application for Unicode. In the preprocessor settings, remove _MBCS and add _UNICODE (additionally add UNICODE 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

              T Offline
              T Offline
              ThatsAlok
              wrote on last edited by
              #7

              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" - Mixture

              cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

              1 Reply Last reply
              0
              • T ThatsAlok

                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" - Mixture

                cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

                B Offline
                B Offline
                bhanu_8509
                wrote on last edited by
                #8

                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.

                1 Reply Last reply
                0
                • B bhanu_8509

                  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

                  _ Offline
                  _ Offline
                  _Superman_
                  wrote on last edited by
                  #9

                  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.

                  A 1 Reply Last reply
                  0
                  • _ _Superman_

                    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.

                    A Offline
                    A Offline
                    aravind sn
                    wrote on last edited by
                    #10

                    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

                    B 1 Reply Last reply
                    0
                    • A 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

                      B Offline
                      B Offline
                      bhanu_8509
                      wrote on last edited by
                      #11

                      The CEdit control displays only ??. Please advice some other way.

                      wchar_t mySymbols[]={9664, 9824, 0000};
                      CString symbolText(mySymbols);
                      Edit.SetWindowText(symbolText);

                      A 1 Reply Last reply
                      0
                      • B bhanu_8509

                        The CEdit control displays only ??. Please advice some other way.

                        wchar_t mySymbols[]={9664, 9824, 0000};
                        CString symbolText(mySymbols);
                        Edit.SetWindowText(symbolText);

                        A Offline
                        A Offline
                        aravind sn
                        wrote on last edited by
                        #12

                        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..!!!:)");

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups