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. Reading a MBCS string from a Rich Edit Text Box in VC6

Reading a MBCS string from a Rich Edit Text Box in VC6

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
8 Posts 2 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.
  • J Offline
    J Offline
    JJeffrey
    wrote on last edited by
    #1

    I'm sorry to trouble everyone, I have a feeling this should be a simple answer but I'm missing something. I need to take in from a Rich Edit Box on my dialog box a string which can be a string in Chinese, Japanese, English, German, etc. I'm currently using this:

    char TextArray[SIZE]={0};
    m_RichEditBox.GetWindowText(TextArray, SIZE);

    When I encounter a Multi-char string (like the Chinese or Japanese ones), the string TextArray is filled with "????" instead (Yes, Question marks, in case you thought you saw wrongly) I have tried to declare TextArray as a

    TCHAR

    , tried to convert it to a wchar, tried to declare as a CString, but so far nothing has worked. I have checked, I do not have _UNICODE declared, and since _MBCS is default in VC6, shouldn't I get some result instead of "????" ? Or is my problem the fact I'm using VC6? Thanks in advance, and if you need more info, feel free to ask. Jeffrey

    R 1 Reply Last reply
    0
    • J JJeffrey

      I'm sorry to trouble everyone, I have a feeling this should be a simple answer but I'm missing something. I need to take in from a Rich Edit Box on my dialog box a string which can be a string in Chinese, Japanese, English, German, etc. I'm currently using this:

      char TextArray[SIZE]={0};
      m_RichEditBox.GetWindowText(TextArray, SIZE);

      When I encounter a Multi-char string (like the Chinese or Japanese ones), the string TextArray is filled with "????" instead (Yes, Question marks, in case you thought you saw wrongly) I have tried to declare TextArray as a

      TCHAR

      , tried to convert it to a wchar, tried to declare as a CString, but so far nothing has worked. I have checked, I do not have _UNICODE declared, and since _MBCS is default in VC6, shouldn't I get some result instead of "????" ? Or is my problem the fact I'm using VC6? Thanks in advance, and if you need more info, feel free to ask. Jeffrey

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

      Hi Jeffrey, I would like to ask you a few questions.

      • If you want to process Japanese or German text (Unicode?!), why do you do an _MBCS build?
      • Are you able to type in German text in the Rich Edit control?

      It is a crappy thing, but it's life -^ Carlo Pallini

      J 1 Reply Last reply
      0
      • R Rajesh R Subramanian

        Hi Jeffrey, I would like to ask you a few questions.

        • If you want to process Japanese or German text (Unicode?!), why do you do an _MBCS build?
        • Are you able to type in German text in the Rich Edit control?

        It is a crappy thing, but it's life -^ Carlo Pallini

        J Offline
        J Offline
        JJeffrey
        wrote on last edited by
        #3

        Hi Rajesh Aren't Japanese, Chinese and Korean Double byte and thus MBCS? I read this page and many others that led me to think so: [^] My main focus are the Asian text for now. If I need Unicode for German, then I'll do another program for it later, I'm sorry for the confusion and perhaps my lack of understanding on it. Are you telling me I should do a unicode build to handle both double byte and other non-double-byte text? I can cut and copy any text I can get on Wordpad into my Rich Edit Control with no problems, but I cannot seem change my language settings when my program is in focus and is the main window, thus I cannot type directly into the rich edit control. Does this help to diagnose my problem? Thanks

        R 1 Reply Last reply
        0
        • J JJeffrey

          Hi Rajesh Aren't Japanese, Chinese and Korean Double byte and thus MBCS? I read this page and many others that led me to think so: [^] My main focus are the Asian text for now. If I need Unicode for German, then I'll do another program for it later, I'm sorry for the confusion and perhaps my lack of understanding on it. Are you telling me I should do a unicode build to handle both double byte and other non-double-byte text? I can cut and copy any text I can get on Wordpad into my Rich Edit Control with no problems, but I cannot seem change my language settings when my program is in focus and is the main window, thus I cannot type directly into the rich edit control. Does this help to diagnose my problem? Thanks

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

          JJeffrey wrote:

          My main focus are the Asian text for now. If I need Unicode for German, then I'll do another program for it later, ...

          But why welcome pain? Won't a Unicode build solve your problem? Perhaps I'm not understanding your requirements or something like that... But I just opened VC6, created a dialog based app with a rich edit control (CRichEditCtrl) on it and then did a Unicode build. The first time, I wasn't able to copy or type in Japanese into the rich edit control, even though I've got the language installed on my machine and it displayed ????. I then remembered it was the old cow-doo with VC6 which requires a manual hack, and opened the .RC file of the project in a text editor to find this particular piece of code:

          CONTROL "",IDC_RICHEDIT1,"RICHEDIT",ES_AUTOHSCROLL | WS_BORDER |
          WS_TABSTOP,60,83,150,61

          which I replaced with

          CONTROL "",IDC_RICHEDIT1,"RICHEDIT20W",ES_AUTOHSCROLL | WS_BORDER |
          WS_TABSTOP,60,83,150,61

          A new build and off I go with my app ready to handle Japanese and German Unicode text.

          JJeffrey wrote:

          Aren't Japanese, Chinese and Korean Double byte and thus MBCS?

          I suggest that you read up on Unicode. From the link you gave me: Note: New Windows applications should use Unicode to avoid the inconsistencies of varied code pages and for ease of localization. Hope that would help. :)

          It is a crappy thing, but it's life -^ Carlo Pallini

          J 1 Reply Last reply
          0
          • R Rajesh R Subramanian

            JJeffrey wrote:

            My main focus are the Asian text for now. If I need Unicode for German, then I'll do another program for it later, ...

            But why welcome pain? Won't a Unicode build solve your problem? Perhaps I'm not understanding your requirements or something like that... But I just opened VC6, created a dialog based app with a rich edit control (CRichEditCtrl) on it and then did a Unicode build. The first time, I wasn't able to copy or type in Japanese into the rich edit control, even though I've got the language installed on my machine and it displayed ????. I then remembered it was the old cow-doo with VC6 which requires a manual hack, and opened the .RC file of the project in a text editor to find this particular piece of code:

            CONTROL "",IDC_RICHEDIT1,"RICHEDIT",ES_AUTOHSCROLL | WS_BORDER |
            WS_TABSTOP,60,83,150,61

            which I replaced with

            CONTROL "",IDC_RICHEDIT1,"RICHEDIT20W",ES_AUTOHSCROLL | WS_BORDER |
            WS_TABSTOP,60,83,150,61

            A new build and off I go with my app ready to handle Japanese and German Unicode text.

            JJeffrey wrote:

            Aren't Japanese, Chinese and Korean Double byte and thus MBCS?

            I suggest that you read up on Unicode. From the link you gave me: Note: New Windows applications should use Unicode to avoid the inconsistencies of varied code pages and for ease of localization. Hope that would help. :)

            It is a crappy thing, but it's life -^ Carlo Pallini

            J Offline
            J Offline
            JJeffrey
            wrote on last edited by
            #5

            Maybe I'm just too embedded into the notion that Unicode is Unicode, MBCS is MBCS and never the twain should they meet... Guess that idea is obsolete now. I tried the "hack" with my MBCS build but nothing changed. I'll take some time to convert to a Unicode build and try again. Thanks for your time and sorry for fustrating you.

            R 1 Reply Last reply
            0
            • J JJeffrey

              Maybe I'm just too embedded into the notion that Unicode is Unicode, MBCS is MBCS and never the twain should they meet... Guess that idea is obsolete now. I tried the "hack" with my MBCS build but nothing changed. I'll take some time to convert to a Unicode build and try again. Thanks for your time and sorry for fustrating you.

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

              JJeffrey wrote:

              I'll take some time to convert to a Unicode build and try again.

              I'd very strongly recommend that you do it.

              JJeffrey wrote:

              Thanks for your time and sorry for fustrating you.

              Me frustrated? Not at all. :)

              It is a crappy thing, but it's life -^ Carlo Pallini

              J 1 Reply Last reply
              0
              • R Rajesh R Subramanian

                JJeffrey wrote:

                I'll take some time to convert to a Unicode build and try again.

                I'd very strongly recommend that you do it.

                JJeffrey wrote:

                Thanks for your time and sorry for fustrating you.

                Me frustrated? Not at all. :)

                It is a crappy thing, but it's life -^ Carlo Pallini

                J Offline
                J Offline
                JJeffrey
                wrote on last edited by
                #7

                Thanks, my problem is resolved, though now I need to iron out the bugs that appeared due to my hasty switchover to Unicode. I'll start building my programs using Unicode from the start next time. Thanks again. Jeffrey

                R 1 Reply Last reply
                0
                • J JJeffrey

                  Thanks, my problem is resolved, though now I need to iron out the bugs that appeared due to my hasty switchover to Unicode. I'll start building my programs using Unicode from the start next time. Thanks again. Jeffrey

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

                  JJeffrey wrote:

                  I'll start building my programs using Unicode from the start next time.

                  That's wise!

                  JJeffrey wrote:

                  Thanks again.

                  My pleasure, and glad to be of help. :)

                  It is a crappy thing, but it's life -^ Carlo Pallini

                  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