wchar-t

Dynamic wchar_t array (C++ beginner) [closed]

℡╲_俬逩灬. 提交于 2019-12-13 02:16:20
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . I am modifying some C++ code that has a wchar_t myArray[MAX_PATH] in the header file. My modifications mean that I cannot know the length of this array

Cython - convert wide string (wchar_t *) to Python 3 unicode object

杀马特。学长 韩版系。学妹 提交于 2019-12-12 16:55:41
问题 I'm wrapping a C library to Pyhon 3 using Cython and i'm looking for a way of converting wchar_t string to python object which i want to return from a function. There's an answer in this question, but it involves encoding the string as multibyte str, and decoding it back to unicode. I hope for more straightforward solution. I tried using PyUnicode_FromWideChar from Python C API, but i'm getting a segfault. Here's my .pyx code: from cpython.ref cimport PyObject from libc.stddef cimport wchar_t

Converting a UTF-8 text to wchar_t

三世轮回 提交于 2019-12-12 11:44:17
问题 I know this question has been asked quite a few times here, and i did read some of the answers, But there are a few suggested solutions and im trying to figure out the best of them. I'm writing a C99 app that basically receives XML text encoded in UTF-8. Part of it's job is to copy and manipulate that string (finding a substr, cat it, ex..) As i would rather not to use an outside not-standard library right now, im trying to implement it using wchar_t. Currently, im using mbstowcs to convert

How do I read Unicode-16 strings from a file using POSIX methods in Linux?

穿精又带淫゛_ 提交于 2019-12-12 11:15:56
问题 I have a file containing UNICODE-16 strings that I would like to read into a Linux program. The strings were written raw from Windows' internal WCHAR format. (Does Windows always use UTF-16? e.g. in Japanese versions) I believe that I can read them using raw reads and the converting with wcstombs_l. However, I cannot figure what locale to use. Runing "locale -a" on my up-to-date Ubuntu and Mac OS X machines yields zero locales with utf-16 in their names. Is there a better way? Update: the

How to avoid integer promotion in C?

冷暖自知 提交于 2019-12-12 06:52:39
问题 It is not clear how to write portable code in C, using wide-character API. Consider this example: #include <locale.h> #include <wchar.h> #include <wctype.h> int main(void) { setlocale(LC_CTYPE, "C.UTF-8"); wchar_t wc = L'ÿ'; if (iswlower(wc)) return 0; return 1; } Compiling it with gcc-6.3.0 using -Wconversion option gives this warning: test.c: In function 'main': test.c:9:16: warning: conversion to 'wint_t {aka unsigned int}' from 'wchar_t {aka int}' may change the sign of the result [-Wsign

What is the largest code point for 16-bit wchar_t type?

泄露秘密 提交于 2019-12-12 03:06:06
问题 It is said here that UTF-16's largest code point is 10FFFF Also it is written on that page that BMP characters require one 16-bit code unit to process or store. But in bit representation 10FFFF is 0001 0000 1111 1111 1111 1111 We see that it occupies more than 15 bits of 16-bit wchar_t (an implementation is allowed to support wide characters with >=0 value only, independently of signedness of wchar_t ) What is the real largest code point for 16-bit wchar_t ? 回答1: It is said here that UTF-16's

How to convert Python list of strings into C array of wchar_t?

自作多情 提交于 2019-12-11 15:28:22
问题 The source code in C looks like: typedef wchar_t char_t; typedef const char_t* const_string_t; static const_string_t g_symbols[] = { {L"IBM"}, {L"MSFT"}, {L"YHOO"}, {L"C"} }; ... some_c_func(g_symbols) ... some_c_func is declared somewhere earlier with something like: int some_c_func(const_string_t* symbols) It is important that g_symbols is passed to some_c_func function, so I have to write wrapper over it, that should look somehow like: ctypedef wchar_t char_t ctypedef const char_t* const

Compare C-string of types char* and wchar_t* [closed]

[亡魂溺海] 提交于 2019-12-11 08:34:11
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I have a key like: wchar_t key[] = L"764frtfg88fgt320nolmo098vfr"; and a char* row[i] returned by a query from a Database. I'd like to compare my Key with row[i] . I tried with wcscmp (key,row[i]) != 0) but it gives me an error. Any suggestions ? 回答1: This might help: C++ Convert string (or char*) to wstring (or

wstringstream to LPWSTR

孤街醉人 提交于 2019-12-11 07:43:09
问题 I have built up a string using wstringstream and need to assign it to a member of a struct of type LPWSTR . I try to use my_stringstream.str().c_str() but get the following compile time error: cannot convert from 'const wchar_t *' to 'LPWSTR' How can I do this? I have tried many different combinations of casts with either more compile time errors or random jargon when I try and display the string in a GUI. 回答1: Your function expects a pointer to modifiable data, i.e. wchar_t* , but the

C CSV API for unicode

天大地大妈咪最大 提交于 2019-12-11 06:24:45
问题 I need a C API for manipulating CSV data that can work with unicode. I am aware of libcsv (sourceforge.net/projects/libcsv), but I don't think that will work for unicode (please correct me if I'm wrong) because don't see wchar_t being used. Please advise. 回答1: It looks like libcsv does not use the C string functions to do its work, so it almost works out of the box, in spite of its mbcs/ws ignorance. It treats the string as an array of bytes with an explicit length. This might mostly work for