Difference btw MBCS and Unicode?
-
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!
-
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!
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 :)
-
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!
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
-
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!
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"
-
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"