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

I am trying to draw text using a dll library that only has ANSI encapsulated window interfaces in ANSI, but I need to store string data using utf-8. I don’t want to convert strings using MultiByte / WideChar functions, so I need an approach to change CP_ACP in my application so that I can enter string data in ANSI apis. thanks.

ps: I do not want to change the default code page.

+4
source share
3 answers

CP_ACP is an Ansi encoding system. You cannot change this for each process or for each thread. This is a system-wide setting. If the DLL really depends on CP_ACP inside, then you have no choice but to convert your from / to UTF-8 whenever you interact with the DLL.

+5
source

"How to change CP_ACP?" - "I do not want (want) to change the default system code page."

Well, you need to choose. CP_ACP is the default system code page.

+1
source

UTF8 is not a code page, and since code pages only make sense for ANSI functions, you cannot do what you ask for.

If you want to save the string as UTF8, you will need to convert from ANSI your application to unicode (wide char) using MultiByteToWideChar() , and then use WideCharToMultiByte() to convert to UTF8.

Alternatively, update the application to use the internal unicode / wide line and convert as needed.

+1
source

Source: https://habr.com/ru/post/1393360/


All Articles