Use MultiByteToWideChar with MB_PRECOMPOSED and MB_ERR_INVALID_CHARS

Use MultiByteToWideChar with MB_PRECOMPOSED and MB_ERR_INVALID_CHARS

When calling MultiByteToWideChar, always use the MB_PRECOMPOSED flag. This reduces, but does not eliminate, the occurrence of combining characters and speeds normalization. This is the default. Except for code pages greater than 50000, use MB_ERR_INVALID_CHARS with MultiByteToWideChar. This will catch undefined characters in the source string. The function converts code pages greater than 50000 by using algorithms rather than tables. Depending on the algorithm, invalid characters might be handled by the algorithm and the MB_ERR_INVALID_CHARS option might not be accepted. Check the MSDN documentation for code pages greater than 50000.

NOTE
Starting with Windows XP, MB_ERR_INVALID_CHARS is supported for UTF8 conversion as well (code page 65001 or CP_UTF8).



Writing Secure Code
Writing Secure Code, Second Edition
ISBN: 0735617228
EAN: 2147483647
Year: 2001
Pages: 286

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net