wchar-t

Lowercase of Unicode character

对着背影说爱祢 提交于 2019-12-22 05:20:14
问题 I am working on a C++ project that need to get data from unicode text . I have a problem that I can't lower some unicode character . I use wchar_t to store unicode character which read from a unicode file. After that, I use _wcslwr to lower a wchar_t string. There are many case still not lower such as: Đ Â Ă Ê Ô Ơ Ư Ấ Ắ Ế Ố Ớ Ứ Ầ Ằ Ề Ồ Ờ Ừ Ậ Ặ Ệ Ộ Ợ Ự which lower case is: đ â ă ê ô ơ ư ấ ắ ế ố ớ ứ ầ ằ ề ồ ờ ừ ậ ặ ệ ộ ợ ự I have try tolower and it is still not working. 回答1: If you call only

UTF-8 Compatibility in C++

江枫思渺然 提交于 2019-12-21 07:37:25
问题 I am writing a program that needs to be able to work with text in all languages. My understanding is that UTF-8 will do the job, but I am experiencing a few problems with it. Am I right to say that UTF-8 can be stored in a simple char in C++? If so, why do I get the following warning when I use a program with char , string and stringstream : warning C4566: character represented by universal-character-name '\uFFFD' cannot be represented in the current code page (1252) . (I do not get that

C++ count matches regex function that works with both char and wchar_t?

蓝咒 提交于 2019-12-20 04:04:59
问题 With the answer from this question I was able to create a function that uses regex to find and replace in strings that works with both char and wchar_t template<typename CharT> basic_string<CharT> replaceString(const CharT* find, const CharT* str, const CharT* repl) { basic_string<CharT> text(str); basic_regex<CharT> reg(find); return regex_replace(text, reg, repl); } I've been trying to achieve the same with my function to count the number of matches but I can't figure it out. Currently the

warning: multi-character character constant [-Wmultichar]

依然范特西╮ 提交于 2019-12-19 18:30:57
问题 I want to have an Array of the Greek alphabet and this is what I do: wchar_t pcletters[30] = {'α' , 'ά' , 'β' , 'γ' , 'δ' , 'ε' , 'ζ' , 'η', 'θ' , 'ι' , 'κ' , 'λ' , 'μ' , 'ν','ξ' , 'ο' , 'π' , 'ρ' , 'σ' , 'τ' , 'υ' , 'φ' , 'χ' , 'ψ' , 'ω', 'έ' , 'ή' , 'ί' , 'ό' , 'ύ' , 'ώ'} ; I also include <locale.h> and have a line setlocale(LC_CTYPE, "") . However I get the warning warning: multi-character character constant [-Wmultichar]. Moreover when I get to check if one of this letters is in a user

warning: multi-character character constant [-Wmultichar]

别来无恙 提交于 2019-12-19 18:30:26
问题 I want to have an Array of the Greek alphabet and this is what I do: wchar_t pcletters[30] = {'α' , 'ά' , 'β' , 'γ' , 'δ' , 'ε' , 'ζ' , 'η', 'θ' , 'ι' , 'κ' , 'λ' , 'μ' , 'ν','ξ' , 'ο' , 'π' , 'ρ' , 'σ' , 'τ' , 'υ' , 'φ' , 'χ' , 'ψ' , 'ω', 'έ' , 'ή' , 'ί' , 'ό' , 'ύ' , 'ώ'} ; I also include <locale.h> and have a line setlocale(LC_CTYPE, "") . However I get the warning warning: multi-character character constant [-Wmultichar]. Moreover when I get to check if one of this letters is in a user

Is wchar_t just a typedef of unsigned short?

荒凉一梦 提交于 2019-12-18 07:29:33
问题 for example, does: wchar_t x; translate to: unsigned short x; 回答1: In short: in C may be in C++ no. Widely. C defines wchar_t as typedef but in Unix it is generally 4 bytes (so generally not short) and in Windows 2 so it may be short. Under C++ it is unique built-in type like char or int , so you can legally overload void foo(short x) and void foo(wchar_t x) 回答2: For anyone else who may come across this answer because function calls in your Visual Studio project won't link, despite both

cannot convert 'const char*' to 'LPCWSTR {aka const wchar_t*}'

别来无恙 提交于 2019-12-17 16:52:07
问题 I'm getting an error in my C++ code that I can't quite make sense of. The stripped down code bits are here: RS232Handle=OpenRS232("COM1", 9600); HANDLE OpenRS232(const char* ComName, DWORD BaudRate) { ComHandle=CreateFile(ComName, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); } I get the following error: error: cannot convert 'const char*' to 'LPCWSTR {aka const wchar_t*}' for argument '1' to 'void* CreateFileW(LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES,

I want to convert std::string into a const wchar_t *

ぐ巨炮叔叔 提交于 2019-12-17 07:17:13
问题 Is there any method? My computer is AMD64. ::std::string str; BOOL loadU(const wchar_t* lpszPathName, int flag = 0); When I used: loadU(&str); the VS2005 compiler says: Error 7 error C2664:: cannot convert parameter 1 from 'std::string *__w64 ' to 'const wchar_t *' How can I do it? 回答1: If you have a std::wstring object, you can call c_str() on it to get a wchar_t* : std::wstring name( L"Steve Nash" ); const wchar_t* szName = name.c_str(); Since you are operating on a narrow string, however,

Getting the length of a formatted string from wsprintf

你离开我真会死。 提交于 2019-12-13 18:43:37
问题 When using standard char* strings, the snprintf and vsnprintf functions will return the length of the output string, even if that string was truncated due to overflow.* It seems like the ISO C committee didn't like this functionality when they added swprintf and vswprintf , which return -1 on overflow. Does anyone know of a function that will provide this length? I don't know the size of the potential strings. I might be asking too much, but.. I'd rather not: allocate a huge static temp

Issue in Converting wchar_t* to char*

孤街浪徒 提交于 2019-12-13 04:47:48
问题 I need to read the current directory in Windows 7 which is in a different locale than the one that is currently used. So I thought of using GetCurrentDirectoryW() since it is unicode compatible, with wchar_t*. However, I need to use an existing API, so I need to convert this to char*. For this purpose I used the wcstombs() function. However, the conversion is not happening properly. Included below is the code that I used: wchar_t w_currentDir[MAX_PATH + 100]; char currentDir[MAX_PATH + 100];