Microsoft KB Archive/225136

= How to convert full-width numbers to half-width numbers =

Article ID: 225136

Article Last Modified on 2/12/2007

-

APPLIES TO

 Microsoft Windows 98 Standard Edition, when used with:  Microsoft Windows 95

 Microsoft Windows 98 Standard Edition

 Microsoft Visual C++ 5.0 Professional Edition

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual Basic 5.0 Enterprise Edition</li></ul>

 Microsoft Visual Basic 6.0 Enterprise Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q225136

<div class="summary_section">

SUMMARY
When converting the full-width Unicode numbers (U+FF10-U+FF19) to standard half-width numbers (U+0030-U+0039)while using WideCharToMultiByte, it fails to do the conversion on Windows 95 and 98. One should use the API LCMapString with flag LCMAP_HALFWIDTH to convert the full-width characters to half-width characters.

<div class="moreinformation_section">

MORE INFORMATION
Since the W version of this API does not work on Windows 95 and Windows 98 one needs to convert the full-width characters from Unicode to proper DBCS strings, and then call LCMapString to do the conversion. Here is a sample working with full-width Unicode numbers in traditional Chinese, simplified Chinese, Japanese and Korean:
 * 1) include <stdio.h>
 * 2) include <tchar.h>
 * 3) include <windows.h>

void main(void) {   WCHAR T[2] = {65301, 0}; TCHAR dbcs[3], conv[3]; WideCharToMultiByte(CP_ACP, 0, T, -1, dbcs, sizeof(dbcs), NULL, NULL); int nRes = LCMapString(LOCALE_USER_DEFAULT, LCMAP_HALFWIDTH,                                                      dbcs,sizeof(dbcs),conv,sizeof(conv)); printf("%s\n",conv); } To make the conversion work for Windows 95 and Windows 98, install one of the four code pages (950 for traditional Chinese, 936 for simplified Chinese, 932 for Japanese and 949 for Korean) on the system and explicitly set the code page and locale ID parameters in the above API calls.

<div class="references_section">