How to change the CP_ACP(0) of windows ANSI apis in an application?

后端 未结 3 745
深忆病人
深忆病人 2021-01-19 19:30

I try to draw text using a dll library which has only interfaces of ANSI version encapsulated windows ANSI apis, but I need to store string data using utf-8. I don\'t want t

相关标签:
3条回答
  • 2021-01-19 19:34

    CP_ACP represents the system Ansi codepage. You cannot change that on a per-process or per-thread basis. It is a system-wide setting. If the DLL really is dependant on CP_ACP internally, then you have no choice but to convert your from/to UTF-8 whenever you interact with the DLL.

    0 讨论(0)
  • 2021-01-19 19:35

    "How to change the CP_ACP?" - "I don't (want) to change the system default codepage."

    Well, you have to choose. CP_ACP is the system default codepage.

    0 讨论(0)
  • 2021-01-19 19:45

    UTF8 is not a codepage, and as codepages only make sense to ANSI functions, you can't do what you're asking.

    If you want to store string as UTF8, you WILL need to convert from the ANSI of your app to unicode (wide char) using MultiByteToWideChar() then use WideCharToMultiByte() to convert to UTF8.

    Alternatively, update you app to use unicode/wide strings internally, and convert as needed.

    0 讨论(0)
提交回复
热议问题