Showing posts with label multibyte. Show all posts
Showing posts with label multibyte. Show all posts

Friday, September 27, 2013

Embedding C++ code analysis into Visual Studio

Once needed to perform C++ code analysis in order to find multibyte-unfriendly code. Perl with regular expressions helped me a much. Then I've realized that asking everybody in my team to work from DOS console would be inconvenient, thus I've started thinking how to embed this stuff into my lovely IDE (*)

I even asked the community a question: How do I modify View.FindResults1 contents in Visual Studio? 
and got am advice to my own version of the "Find Results" window by creating a Visual Studio extension myself. We can start by having a look at Extending Visual Studio > Tool Windows


Probably writing VisualStudio extensions is a deal of my future self-development. For now I've stopped on calling the script from Post-Build process:
perl $(SolutionDir)\Localization\test_resource_funs.pl  $(InputDir)
thus having its output in Compile Output window. No additional efforts are needed. I can even use "Errors List" to sort and observe all of script warnings.

"Output" window:

"Error List" window:


* - I bet Visual Studio is the best one IDE.

PS see: Formatting the Output of a Custom Build Step or Build Event 

Thursday, September 5, 2013

Why is UTF-8 treated as not multibyte?



It’s a long discussion and object of terminology. Multibyte is a slippery term and is not the best one.
Visual Studio has 3 options for characters sets:

a) No characters set, which means it works OK with single byte characters sets (SBCS) like CP1251 (ru-RU) or CP1252 (en-US)
characters take 1 byte

b) MBCS, which means it works OK with multibyte Character sets like CP936,
characters take 1 or 2 bytes, GUI accepts such characters if appropriate locale is selected in Control Panel

c) Unicode, which means working with UTF-16BE,
characters take 2 bytes, selected locale doesn’t make any sense

Note that there is no option to work with utf-8.
There are conversion functions utf8 <-> MBCS.
In Microsoft documentation term “multibyte” is related to MBCS. It was hard for me to achieve, and I suppose there could be misunderstanding among the team regarding this term.

Even having the same way of coding and having floating amount of bytes, utf8 is a way of encoding Unicode characters, it is not related to MBCS at all.

In order to have our virare and maina (it.) we’ve agreed to call MBCS multibyte

Wednesday, August 7, 2013

MultiByte, UTF-8 and Chinese Character Set



This is a result of long discussion and research of MultiByte encoding with Olga L. this morning. Keep in mind the following information when processing strings when performing localization to Chinese:
  • Multibyte is used in HyperLynx for localized strings.
  • Multibyte is not related to wide chars (wchar_t, Utf-16) at all, even having 2 bytes per character.
  • Multibyte is not related to Utf-8.
  • In Visual Studio debugger you always see Multibyte characters in case Chinese Simplified locale is selected in Control Panel
  • Multibyte (MBCS, DBCS) is the same as CodePage 936 or GB2312 in case Chinese Simplified locale is selected in Control Panel
  • getchar's _(“Two beer or not to be”) returns Multibyte string.
  • “tchar.h” routines like _tcsclen, _tcsncpy,  etc. deal with Multibyte strings
  • .po files are written in UTF-8 and converted to Multibyte on loading
  • .rc files resources are written in Win1251
  • Chinese .zh-CN.rc resources are written in CP936
  • Some of MFC Windows GUI accepts  Multibyte, some only accept ANSI or wchar_t *
Use this site to understand different encodings better, note that on Chinese locale we deal with CP936 Encoding: http://www.kreativekorp.com/charset/encoding.php