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
Questions tagged [wchar]
196 questions
7
votes
1 answer
Converting string macros/constants to wide characters/Unicode
I have a Unicode Win32 application that uses 3rd party libraries, some of which provide constants for their version information as #defined (narrow) strings. For instance, libpng has the following:
#define PNG_LIBPNG_VER_STRING "1.5.4"
#define…

CoreyStup
- 1,488
- 13
- 14
6
votes
3 answers
Cannot convert char* to WCHAR* [qt/c++]
im developin QT application, and i need to include pure C code. When i compile this code in code::blocks it was successful, maybe one warning, but when i try to compile it in QT creator, i get these 4 errors.
cannot convert 'char*' to 'WCHAR*' for…

Anton Giertli
- 896
- 2
- 10
- 29
6
votes
2 answers
Why there is a underline before wtoi in function _wtoi which ansi version is atoi?
Hello! It is confused me for a long time!
Long long ago , there is only ansi version that is atoi .
And now (it is also long long ago ) there is a wide char version .
But why the wide char version has a uderline('_') before wtoi?
Could any one tell…

NorSD NorSD
- 225
- 4
- 14
6
votes
1 answer
Is it safe to return std::wstring from a DLL?
According to some older StackOverflow questions ( Unable to pass std::wstring across DLL , C++ DLL returning pointer to std::list ) it's not considered safe for a C++ DLL to return a std::wstring because there's no guarantee the main…

cf-
- 8,598
- 9
- 36
- 58
6
votes
2 answers
Implication of using -fshort-wchar
While going through the file wchar.h on Mac OS X system, I found that wchar_t equivalent of str functions such as wcscpy, wcscat are poisoned when __cplusplust is not defined and max size of wchar_t is of 2 bytes (by using compiler option…

doptimusprime
- 9,115
- 6
- 52
- 90
6
votes
3 answers
C++ WCHAR manipulations
I'm developing a tiny Win32 app in C++.
I've studied C++ fundamentals long time ago, so now I completely confused because of character strings in C++. There were no WCHAR or TCHAR only char and String.
After a little investigation I've decided not…

Geradlus_RU
- 1,466
- 2
- 20
- 37
6
votes
3 answers
char* to const wchar_t * conversion
I need to convert character pointer to a w_char * in order to use ParseNetworkString(). I've tried finding solutions to this myself, and while I have found one solution, there is one issue which blocks me from using it:
b1naryatr0phy said in an…

user1553248
- 1,184
- 2
- 19
- 33
6
votes
1 answer
how to define macro to convert concatenated char string to wchar_t string in C
Like _T() macro in Visual Studio, I defined and used my own _L macro as:
#define _L(x) __L(x)
#define __L(x) L ## x
It works for:
wprintf(_L("abc\n"));
But gets a compilation error for:
wprintf(_L("abc\n""def\n"));
It reports “string literals…

RolandXu
- 3,566
- 2
- 17
- 23
5
votes
0 answers
Different byte order from pipe using _wpopen in c
I wrote this function that opens a pipe and passes a command to that pipe to be executed, when examining the buffers I noticed that some commands take 1 byte other take 2 bytes, that being said trying to output the buffer to the screen causes some…

loaded_dypper
- 262
- 3
- 12
5
votes
4 answers
C++ , winapi Compare two WCHAR * strings
I want to compare two WCHAR* strings.
How to do it?
P.S.
I would like to ignore case while comparing.
I know you can use strcmpi but it id not working for WCHAR*.

Hooch
- 28,817
- 29
- 102
- 161
5
votes
2 answers
putwchar() can't diplay a wchar_t variable
Why printf() can display é (\u00E9 int UTF-16) and putwchar() can't ?
And what is the right syntax to get putwchar displaying é correctly ?
#include
#include
#include
#include
int main() {
wint_t wc =…

noraj
- 3,964
- 1
- 30
- 38
5
votes
2 answers
How to do operations with 'æ', 'ø' and 'å' in C
I have made a program in C which both can replace or remove all vowels from a string. In addition I would like it to work for these characters: 'æ', 'ø', 'å'.
I have tried to use strstr(), but I didn't manage to implement it without replacing all…

Martin Johansen
- 63
- 1
- 7
4
votes
3 answers
wchar_t* to char* conversion problems
I have a problem with wchar_t* to char* conversion.
I'm getting a wchar_t* string from the FILE_NOTIFY_INFORMATION structure, returned by the ReadDirectoryChangesW WinAPI function, so I assume that string is correct.
Assume that wchar string is "New…

Anatoly Lushnikov
- 43
- 1
- 4
4
votes
2 answers
writing unicode characters/string to file
I'm trying to write unicode characters to file with std::wofstream but the put or write function doesn't write any characters.
Sample code:
#include
#include
int main()
{
std::wofstream file;
file.open("output.txt",…
user11157650
4
votes
1 answer
C - How to avoid diacritic/accents sensitive issues
I'm creating a tiny program of guessing the capitals of countries. Some of the capitals have accents, cedillas, etc.
Since I have to compare the capital and the text the user guessed, and I don't want an accent to mess up the comparison, I went…

Cláudio Pinto
- 63
- 5