widechar

C++, WCHAR[] to std::cout and comparision

Hi, I need to put WCHAR[] to std::cout ... It is a part of PWLAN_CONNECTION_NOTIFICATION_DATA passed from Native Wifi API callback. I tried simply std::cout << var; but it prints out the numeric address of first char. the comparision (var == L"some text") doesn't work either. The debugger returns the expected value, however the compari...

C/C++ I18N mbstowcs question

I am working on internationalizing the input for a C/C++ application. I have currently hit an issue with converting from a multi-byte string to wide character string. The code needs to be cross platform compatible, so I am using mbstowcs and wcstombs as much as possible. I am currently working on a WIN32 machine and I have set the loc...

How to test if a string has a certain unicode char?

Supose you have a command line executable that receives arguments. This executalbe is widechar ready and you want to test if one of this arguments starts with an HYPHEN case in which its an option: command -o foo how you could test it inside your code if you don't know the charset been used by the host? Should be not possible to a give...

C++: wide characters outputting incorrectly?

My code is basically this: wstring japan = L"日本"; wstring message = L"Welcome! Japan is "; message += japan; wprintf(message.c_str()); I'm wishing to use wide strings but I do not know how they're outputted, so I used wprintf. When I run something such as: ./widestr | hexdump The hexidecimal codepoints create this: 65 57 63 6c 6...

How to cast wchar_t into int for displaying the code point?

I have a simple function in my program, when I was wanting to mess around with unicode and do stuff with it. In this function, I wished to display the code value of the character the user entered. It SEEMED possible, here's my function: wstring listcode(wchar_t arg) { wstring str = L""; str += static_cast<int> (arg); //I tried (...

Mac/iPhone - NSString - comparing multibyte character and wide character strings

I'm using NSString that is a combination of "japanese" and "english" characters. All are two byte (multi byte) characters. From a webservice I'm receiving a string that is also a combination of "japanese" and "english" characters, but as far as I know english characters in that string are one byte characters. I want to compare my string ...

Using Wide Character Constants with clang Gets "extraneous characters in wide character constant ignored" Error

I recently decided to switch to clang from gcc and I’m getting the following warning for my use of wide character constants: "extraneous characters in wide character constant ignored". Here is the code that gets the warning: wstring& line; … for (wstring::iterator ch = line.begin(); ch != line.end(); ++ch) switch (*ch) { cas...

WideCharToMultiByte problem

I have the lovely functions from my previous question, which work fine if I do this: wstring temp; wcin >> temp; string whatever( toUTF8(getSomeWString()) ); // store whatever, copy, but do not use it as UTF8 (see below) wcout << toUTF16(whatever) << endl; The original form is reproduced, but the in between form often contains extr...

"Incompatible pointer type" compiler warning for 4th argument of qsort

I'm trying to use the standard library's qsort to sort an array of wide characters: wchar_t a = L'a'; wchar_t a1 = L'ä'; wchar_t b = L'z'; wchar_t chararray[] = {b, a, a1}; length = wcslen(chararray); qsort(chararray, length, sizeof(wchar_t), wcscoll); Now I think the functions involved have these prototypes: int wcscoll(const wch...