关闭

A bug in MSDN 2005

391人阅读 评论(0) 收藏 举报

Recently when I am programming using Visual C++, I referenced to MSDN 2005. However, when looking up `_mbsinc' and `_mbcdec', I found a bug in MSDN 2005.

In MSDN 2005, the _mbsinc topic contains:

..._mbsinc recognizes multibyte-character sequences according to the multibyte code page currently in use...

Note that MSDN says it uses the current multibyte code page. However in the _mbsdec topic:

The output value is affected by the setting of the LC_CTYPE category setting of the locale; see setlocale for more information. _mbsdec recognizes multibyte-character sequences according to the local currently in use

Note in the above description, firstly, it says the "local" currently in use. It's a typo which should be "locale". Second, the current locale is _different_ from the the current multibyte code page. The current multibyte code page, which can be set in the Control Panel, is usually 936 on Simplified Chinese Windows systems. The current locale, however, is often set to a western one (may be "C") by default.

In MSDN 2005, there is another topic named "Locale". You can find it by typing "setlocale" in Index and look for "Locale" in the index results. Now in that page you can see that _mbsinc and _mbsdec are not listed in the table. It means that they both use the current multibyte code page rather than the current locale.

So it is a bug in MSDN 2005.

I don't know how Borland C++ Compiler 5.5 deals with locales. But as I observe, its mblen function uses the current multibyte code page. It is also possible that the default locale is set to the current multibyte code page, however it is not proven.

New: 20070912 22:01, after my testing, I confirmed that Borland _mbclen and mblen both use the locale, and the locale is set to the system default when the program is up and running.

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:196597次
    • 积分:2859
    • 等级:
    • 排名:第12885名
    • 原创:113篇
    • 转载:17篇
    • 译文:1篇
    • 评论:52条
    最新评论
    朋友的 csdn 博客