Questions tagged [wchar]

wchar.h is a header file in the C standard library. It is a part of the extension to the C programming language standard done in 1995. It contains extended multibyte and wide character utilities. The standard header is included to perform input and output operations on wide streams. It can also be used to manipulate the wide strings.

196 questions
36
votes
2 answers

Why does wprintf transliterate Russian text in Unicode into Latin on Linux?

Why does the following program #include #include int main() { wprintf(L"Привет, мир!"); } print "Privet, mir!" on Linux? Specifically, why does it transliterate Russian text in Unicode into Latin as opposed to transcoding it…
vitaut
  • 49,672
  • 25
  • 199
  • 336
21
votes
5 answers

Convert char* to wchar* in C

I would like to convert a char* string to a wchar* string in C. I have found many answers, but most of them are for C++. Could you help me? Thanks.
Crupuk
  • 297
  • 1
  • 3
  • 9
19
votes
5 answers

WideCharToMultiByte() vs. wcstombs()

What is the difference between WideCharToMultiByte() and wcstombs() When to use which one?
Greenhorn
  • 658
  • 2
  • 8
  • 24
15
votes
1 answer

Convert WCHAR to QString in Qt

Convert WCHAR to QString in Qt. Please help me to implement it to complete this convertion.
Harry Fox
  • 603
  • 2
  • 6
  • 11
14
votes
1 answer

What is the fate of wchar_t in c++0x?

What is the fate of wchar_t in c++0x considering the new character types char8_t, char16_t, and char32_t? More importantly, what about std::wstring, std::wcout, etc? Are the w* family classes deprecated? Are there new std::ustring and std::Ustring…
deft_code
  • 57,255
  • 29
  • 141
  • 224
13
votes
3 answers

Is it actually possible to store and process individual UTF-8 characters on C ? If so, how?

I've written a program in C that breaks words down into syllables, segments and letters. It's working well with ASCII characters but I want to make versions that work for the IPA and Arabic too. I'm having massive problems saving and performing…
sally2000
  • 788
  • 4
  • 14
12
votes
4 answers

wchar ends with single null byte or two of them?

I just don't understand and can't find much info about wchar end. If it ends with single null byte, how it know it not string end yet, if something like that "009A" represent one of unicode symbols? If it ends with two null bytes? Well, I am not…
Kosmo零
  • 4,001
  • 9
  • 45
  • 88
11
votes
3 answers

check if WCHAR contains string

I have variable WCHAR sDisplayName[1024]; How can I check if sDisplayName contains the string "example"?
Irakli Lekishvili
  • 33,492
  • 33
  • 111
  • 169
10
votes
2 answers

How to convert Wchar_t* to const char*

I am a kind of new for c++ , while working on the windows CE .net compact application while trying to write hexa datas to a file CString dataBlock1; dataBlock1 = ""; CString temp; for(int i = 0; i < rLen; i++) { temp.Format(L"%02X…
saroll
  • 217
  • 2
  • 4
  • 9
10
votes
2 answers

sz and pwsz prefixes in WinAPI

I'm a little confused now with the hungarian notation prefixes in WinAPI for CHAR strings and WCHAR strings. When we use a CHAR string usually such a prefix is used: CHAR szString[] = "Hello"; We have a zero-terminated string szString so…
spandei
  • 219
  • 3
  • 16
9
votes
2 answers

How to declare wchar_t and set its string value later on?

I am developing for Windows, I have not found adequate information on how to correctly declare and later on set a unicode string. So far, wchar_t myString[1024] = L"My Test Unicode String!"; What I assume the above does is [1024] is the allocated…
user780756
  • 1,376
  • 3
  • 19
  • 31
8
votes
3 answers

Print wchar to Linux console?

My C program is pasted below. In bash, the program print "char is ", Ω is not printed. My locale are all en_US.utf8. #include #include #include int main() { int r; wchar_t myChar1 = L'Ω'; r = wprintf(L"char…
davy
  • 123
  • 1
  • 3
  • 8
8
votes
5 answers

How to open a file with wchar_t* containing non-Ascii string in Linux?

Environment: Gcc/G++ Linux I have a non-ascii file in file system and I'm going to open it. Now I have a wchar_t*, but I don't know how to open it. (my trusted fopen only opens char* file) Please help. Thanks a lot.
Cauly
  • 370
  • 1
  • 2
  • 12
8
votes
1 answer

Using fgetws after setting a UTF-8 locale?

GCC 4.8, 5.1, 6.2 and Clang 3.8.1 on Ubuntu 16.10 with -std=c11, -std=c++11, -std=c++14, and -std=c++17 all exhibit this weird behaviour when using fgetws(buf, (int) bufsize, stdin) after setlocale(LC_ALL, "any_THING.utf8");. Example…
cat
  • 3,888
  • 5
  • 32
  • 61
8
votes
2 answers

Cannot convert 'const char*' to 'WCHAR*' in argument passing

I have documentation where written that username, IP and password must be const char* and when I'm putting varaibles in const char, I'm getting this error message. This is my code: #include #include #include #include…
DTDest
  • 99
  • 1
  • 2
  • 8
1
2 3
13 14