wchar-t

How to work with UTF-16 in python ctypes?

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-07 10:09:43
问题 I have a foreign C library which uses utf-16 in API: as function arguments, return values and structure members. On Windows its OK with ctypes.c_wchar_p, but under OSX ctypes uses UCS-32 in c_wchar and I could not find the way to support utf-16. Here is my research: Use _SimpleCData subclassing to redefine _check_retval_. it allows a transparent conversion of utf-16 to Python string. can be placed as C structure member But it doesn't allow to handle strings as arguments, its from_param()

How to work with UTF-16 in python ctypes?

萝らか妹 提交于 2021-02-07 10:09:34
问题 I have a foreign C library which uses utf-16 in API: as function arguments, return values and structure members. On Windows its OK with ctypes.c_wchar_p, but under OSX ctypes uses UCS-32 in c_wchar and I could not find the way to support utf-16. Here is my research: Use _SimpleCData subclassing to redefine _check_retval_. it allows a transparent conversion of utf-16 to Python string. can be placed as C structure member But it doesn't allow to handle strings as arguments, its from_param()

How to work with UTF-16 in python ctypes?

喜欢而已 提交于 2021-02-07 10:07:23
问题 I have a foreign C library which uses utf-16 in API: as function arguments, return values and structure members. On Windows its OK with ctypes.c_wchar_p, but under OSX ctypes uses UCS-32 in c_wchar and I could not find the way to support utf-16. Here is my research: Use _SimpleCData subclassing to redefine _check_retval_. it allows a transparent conversion of utf-16 to Python string. can be placed as C structure member But it doesn't allow to handle strings as arguments, its from_param()

Windows console app stops printing when I switch to Edge

落爺英雄遲暮 提交于 2021-01-29 06:45:12
问题 I have to write a console app to log the active window PID, text length and text. It works except when I switch to Edge. The execution doesn't stop, but only the PID and text length get printed to the screen. Please help, I don't know what else to try. #include <iostream> #include <Windows.h> #include <WinUser.h> int main() { // Use environment's default locale for char type setlocale(LC_CTYPE, ""); std::cout << "Hello é World!\n"; while (1) { // Get foreground window HWND hwnd =

How am I allowed to workaround DOS functions that used strings containing accented characters (ASCII to UTF-8)?

瘦欲@ 提交于 2021-01-28 09:12:01
问题 I was writing a SW where I wanted to use an old C code written in the early '80. This code did some conversion on strings. It also used the accented characters that, at that time (DOS), were coded in the ASCII table (codes bigger than 127). Now the new systems use UTF-8 encoding, so the old code works very badly. I am using Linux (Ubuntu 17 / gcc gcc (Ubuntu 7.2.0-8ubuntu3) 7.2.0). I'm looking for a workaround allowing me to make the least possible changes. I have begun to do some tests to

XMLCh to wchar_t and vice versa

懵懂的女人 提交于 2021-01-24 12:21:28
问题 My config: Compiler: gnu gcc 4.8.2 I compile with C++11 platform/OS: Linux 64bit Ubuntu 14.04.1 LTS I want to feed a method with wchar_t* and use it in many xecerces library methods that need XMLCh* but I don't know how to translate from one to another. It's easy if you use char* instead of wchar_t* but I need to use wide character. Under windows I could easily cast from one to another but it doesn't work in my linux machine. Somehow I have to manually translate wchar_t* to a XMLCh* I link

XMLCh to wchar_t and vice versa

限于喜欢 提交于 2021-01-24 12:21:18
问题 My config: Compiler: gnu gcc 4.8.2 I compile with C++11 platform/OS: Linux 64bit Ubuntu 14.04.1 LTS I want to feed a method with wchar_t* and use it in many xecerces library methods that need XMLCh* but I don't know how to translate from one to another. It's easy if you use char* instead of wchar_t* but I need to use wide character. Under windows I could easily cast from one to another but it doesn't work in my linux machine. Somehow I have to manually translate wchar_t* to a XMLCh* I link

XMLCh to wchar_t and vice versa

好久不见. 提交于 2021-01-24 12:20:36
问题 My config: Compiler: gnu gcc 4.8.2 I compile with C++11 platform/OS: Linux 64bit Ubuntu 14.04.1 LTS I want to feed a method with wchar_t* and use it in many xecerces library methods that need XMLCh* but I don't know how to translate from one to another. It's easy if you use char* instead of wchar_t* but I need to use wide character. Under windows I could easily cast from one to another but it doesn't work in my linux machine. Somehow I have to manually translate wchar_t* to a XMLCh* I link

wchar_t* with UTF8 chars in MSVC

梦想的初衷 提交于 2020-08-07 18:27:15
问题 I am trying to format wchar_t* with UTF-8 characters using vsnprintf and then printing the buffer using printf . Given the following code: /* This code is modified version of KB sample: https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/rtref/vsnprintf.htm The usage of `setlocale` is required by my real-world scenario, but can be modified if that fixes the issue. */ #include <wchar.h> #include <stdarg.h> #include <stdio.h> #include <locale.h> #ifdef MSVC #include <windows.h> #endif

wchar_t* with UTF8 chars in MSVC

…衆ロ難τιáo~ 提交于 2020-08-07 18:26:29
问题 I am trying to format wchar_t* with UTF-8 characters using vsnprintf and then printing the buffer using printf . Given the following code: /* This code is modified version of KB sample: https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_73/rtref/vsnprintf.htm The usage of `setlocale` is required by my real-world scenario, but can be modified if that fixes the issue. */ #include <wchar.h> #include <stdarg.h> #include <stdio.h> #include <locale.h> #ifdef MSVC #include <windows.h> #endif