microsoft / cpprestsdk

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
8.01k stars 1.66k forks source link

utility::conversions::latin1_to_utf16 - Is there a bug for characters above 0x80? #101

Open pp555 opened 8 years ago

pp555 commented 8 years ago

I've tried to use utility::conversions::latin1_to_utf16 to convert latin1 string to UTF-16. The string contained 'í' character (0xed). After converting it should become 0x00ed but it seems that converting method replaced it with 0xffed.

I think this may be result of casting signed char to utf16char and dest[i] = utf16char(s[i]); in asyncrt_utils.cpp should be replaced by dest[i] = utf16char(static_cast<unsigned char>(s[i])); to fix it. Can someone check if I'm right?

ras0219-msft commented 8 years ago

This could very well be an issue. Please consider making a PR with the fix and a test case; it would be gladly accepted.