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. Difference btw MBCS and Unicode?

Difference btw MBCS and Unicode?

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 4 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.
  • F Offline
    F Offline
    fynox
    wrote on last edited by
    #1

    Hi, I'm a little confused... Under MBCS the following code works... --------------------------------------------------------------------- main_doc->SelectByID(au2B(CEditUPara::UComp),au2B("COMPONENT"), 0, 0, 0, &retval); main_doc->ShowComponent2 ( ); ===================================================================== But under Unicode, i needed to do this for a particular part of the code... --------------------------------------------------------------------- CString type = "COMPONENT"; BSTR ucomp = CEditUPara::UComp.AllocSysString(); BSTR Type = type.AllocSysString(); main_doc->SelectByID(ucomp,Type, 0, 0, 0, &retval); main_doc->ShowComponent2 ( ); ===================================================================== The weird thing is that, --------------------------------------------------------------------- main_doc->IParameter(au2B(Diameter), &dim ); ===================================================================== still works in some other parts of the code...I can compile and run it successfully...Why is this so?? Thanks!

    A A M 3 Replies Last reply
    0
    • F fynox

      Hi, I'm a little confused... Under MBCS the following code works... --------------------------------------------------------------------- main_doc->SelectByID(au2B(CEditUPara::UComp),au2B("COMPONENT"), 0, 0, 0, &retval); main_doc->ShowComponent2 ( ); ===================================================================== But under Unicode, i needed to do this for a particular part of the code... --------------------------------------------------------------------- CString type = "COMPONENT"; BSTR ucomp = CEditUPara::UComp.AllocSysString(); BSTR Type = type.AllocSysString(); main_doc->SelectByID(ucomp,Type, 0, 0, 0, &retval); main_doc->ShowComponent2 ( ); ===================================================================== The weird thing is that, --------------------------------------------------------------------- main_doc->IParameter(au2B(Diameter), &dim ); ===================================================================== still works in some other parts of the code...I can compile and run it successfully...Why is this so?? Thanks!

      A Offline
      A Offline
      Anand Paranjpe
      wrote on last edited by
      #2

      In MBCS, a 'character' as the user thinks of it may be one or two bytes and in Unicode, it is two bytes. More info regarding conversion from Unicode to mbcs refer MSDN with key as "MBCS/Unicode conversion" The chosen One :)

      1 Reply Last reply
      0
      • F fynox

        Hi, I'm a little confused... Under MBCS the following code works... --------------------------------------------------------------------- main_doc->SelectByID(au2B(CEditUPara::UComp),au2B("COMPONENT"), 0, 0, 0, &retval); main_doc->ShowComponent2 ( ); ===================================================================== But under Unicode, i needed to do this for a particular part of the code... --------------------------------------------------------------------- CString type = "COMPONENT"; BSTR ucomp = CEditUPara::UComp.AllocSysString(); BSTR Type = type.AllocSysString(); main_doc->SelectByID(ucomp,Type, 0, 0, 0, &retval); main_doc->ShowComponent2 ( ); ===================================================================== The weird thing is that, --------------------------------------------------------------------- main_doc->IParameter(au2B(Diameter), &dim ); ===================================================================== still works in some other parts of the code...I can compile and run it successfully...Why is this so?? Thanks!

        A Offline
        A Offline
        Anthony_Yio
        wrote on last edited by
        #3

        In UNICODE, all the characters are in two bytes. (english characters, chinese characters, kanji characters, vietnamese character, etc ) In MBCS, english characters A-Z , a-z are in single bytes, but some characters like numeric 1- 10, chinese characters, kanji characters, vietnamese character, etc should be treated as two bytes or else you will not be able to read it properly. You need a in depth study to understand it. For your case as I assume you do not know about the languages like Chinese, Kanji, and etc. I suggest you to stick to UNICODE. Just my suggestion. Hope this helps. Sonork 100.41263:Anthony_Yio

        1 Reply Last reply
        0
        • F fynox

          Hi, I'm a little confused... Under MBCS the following code works... --------------------------------------------------------------------- main_doc->SelectByID(au2B(CEditUPara::UComp),au2B("COMPONENT"), 0, 0, 0, &retval); main_doc->ShowComponent2 ( ); ===================================================================== But under Unicode, i needed to do this for a particular part of the code... --------------------------------------------------------------------- CString type = "COMPONENT"; BSTR ucomp = CEditUPara::UComp.AllocSysString(); BSTR Type = type.AllocSysString(); main_doc->SelectByID(ucomp,Type, 0, 0, 0, &retval); main_doc->ShowComponent2 ( ); ===================================================================== The weird thing is that, --------------------------------------------------------------------- main_doc->IParameter(au2B(Diameter), &dim ); ===================================================================== still works in some other parts of the code...I can compile and run it successfully...Why is this so?? Thanks!

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          Without knowing what those macros do (au2b??) it's hard to say, but start here to learn about the different character sets: The Complete Guide to C++ Strings, Part I - Win32 Character Encodings[^] The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)[^] --Mike-- Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber #include "witty-quote.h"

          F 1 Reply Last reply
          0
          • M Michael Dunn

            Without knowing what those macros do (au2b??) it's hard to say, but start here to learn about the different character sets: The Complete Guide to C++ Strings, Part I - Win32 Character Encodings[^] The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)[^] --Mike-- Ericahist | CP SearchBar v2.0.2 | Homepage | RightClick-Encrypt | 1ClickPicGrabber #include "witty-quote.h"

            F Offline
            F Offline
            fynox
            wrote on last edited by
            #5

            I see, au2B is defined like this, #define au2B( STUFF ) auT(STUFF) #define au2B( STUFF ) (LPTSTR)((LPCTSTR)STUFF) but i'm still not sure what that means...and why there are 2 definitions... Thanks for ur help guys...

            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