Microsoft KB Archive/89295

{|
 * width="100%"|

Unicode Conversion to Integers

 * }

Q89295

-

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK) for Windows NT, versions 3.1, 3.5

-

SUMMARY
Under Windows NT, strings may be either Unicode or ANSI. There is no function for reliably converting a string that might be either Unicode or ANSI to an integer. This is because, given a random set of bytes, it is difficult to determine whether the string is in Unicode or ANSI. The calling program has to know which format the string uses in order to convert it.

If the string uses Unicode, the functions wcstol, wcstoul, and wcstod can be used to perform the conversion.

Note that when you are using the Win32 application programming interface (API), you can choose what kind of characters you get from the console or window manager. The names of the API functions that are called to use Unicode and ANSI characters are different. For more details, see Chapter 93 in the overview, &quot;Unicode.&quot;

To mark a string as Unicode, insert the byte-ordering-mark (BOM) 0xFEFF in the string and/or file.

MORE INFORMATION
You can assume that the first 128 bytes in each character set are in the same codepoint. For portability, you should code character conversions in this range as:

{ TCHAR    c;        ... i = c - TEXT('0'); } The TEXT macro places an &quot;L&quot; before the constant if Unicode is defined.

Additional query words: 3.10 3.50

Keywords :

Issue type :

Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch kbWin32SDKNT310 kbWin32SDKNT350