Cannot use non-english characters correctly in your source code, which triggers elusive bugs when ca


This problem can cause the following elusive bugs by AUTOMATIC ENCODING CONVERSION without any warnings or errors:

  1. Cannot read or write strings of the type WCHAR , LPCWSTR… correctly; can not declare any non-English wchar_t with the format of L”おかしい” correctly. e.g: L”正£” cannot be correctly received by the windows API. You cannot easily notice that since you check the memory/the variables, those wchar_t variables are correctly encoded into UTF-16LE. But those variables cannot be correctly passed between services. If you only use those WChar[] in your program without calling any APIs, everything will be ok.
  2. Cannot use the CString correctly. CString st = _T(“正£”); will actually create L”正£”
  3. Cannot use Windows API correctly: the API can receive and use those arguments without any warnings, yet non-ASCII bytes will be combined together to trigger unexpected behavior.
  4. In SAPI5, you can speak English text but cannot speak non-English text correctly. Strange symbols like öüäü€$ will be spoken.

Solution:
Change the encoding of the source files(e.g: Source.cpp) into UTF-16LE WITH BOM

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/288111.html

(0)
上一篇 2022年9月7日
下一篇 2022年9月7日

相关推荐

发表回复

登录后才能评论