Questions tagged [wchar-t]

`wchar_t` is a fundamental data type in the C and C++ programming languages, and it stands for "wide character". Its intended use is to hold any character value from "the system's character set".

wchar_t is the fundamental "wide character" data type in the C and C++ programming languages. Both language standards are intentionally vague on what it is for, specifying only that it can hold any character value "from the system's character set". There are conversion functions to and from the system's narrow, multibyte character encoding, a concept left equally vague (the functions are mbtowc() and wctomb()).

The fact that the C and C++ language standards are at once encoding-agnostic yet also provide for a way to represent an extended character set is the source of much confusion for people who expect explicit guarantees of certain fixed encodings (such as UTF-8 or UTF-32).

The practical use of the wchar_t type is considered debatable by some programmers.

479 questions
1
vote
0 answers

Building C++ openCV project on Windows 11 will not build, works fine on Mac

When I configurate the source code in Cmake with configurator Mingw Makefile, I get no errors, when I proceed to the terminal and write "make" in the correct folder, I get the following error in termianl: error: cannot convert 'const value_type*'…
1
vote
1 answer

argument of type is incompatible with parameter of type error

uintptr_t gameModule = (uintptr_t)GetModuleHandle("client.dll"); Severity Code Description Project File Line Suppression State Error C2664 'HMODULE GetModuleHandleW(LPCWSTR)': cannot convert argument 1 from 'const char [11]' to…
tobee
  • 19
  • 1
1
vote
1 answer

Converting wchar_t * to char * in C++20

Currently using WSL2 Ubuntu, G++20. What are some recommended ways to convert wchar_t * to char * in C++20? I have seen similar posts created several years ago, but I wasn't sure if they were still viable as a solution or if they were deprecated.
spaL
  • 604
  • 7
  • 21
1
vote
1 answer

In C, what would happen if I put 'successive wchar_t characters' into a wchar_t variable?

#include wchar_t wc = L' 459'; printf("%d", wc); //result : 32 I know the 'space' is 'decimal 32' in ASCII code table. What I don't understand is, as far as I know, if there's not enough space for a variable to store value, the…
GamerCoder
  • 139
  • 6
1
vote
1 answer

Convert const char* to UTF16 from C on macOS and Windows?

My attempts seem hacky and overly convoluted. Is there a simple way to convert ASCII to UTF16 on Windows and macOS? (note that the prUTF16Char I can't change ) Attempt (written via https://stackoverflow.com/a/54376330) Prelude #include…
Samuel Marks
  • 1,611
  • 1
  • 20
  • 25
1
vote
2 answers

mbstowcs() gives incorrect results in Windows

I am using mbstowcs() to convert a UTF-8 encoded char* string to wchar_t*, and the latter will be fed into _wfopen(). However, I always get a NULL pointer from _wfopen() and I have found the problem is from the result of mbstowcs(). I prepared the…
nochenon
  • 326
  • 2
  • 12
1
vote
0 answers

WCHAR not functioning properly in linux

I am trying to use wstring in a C++ program which is as follows:- #include using namespace std; const wstring NAME = L"STACKOVERFLOW"; int main() { wcout<
1
vote
1 answer

Can't use newline in OutputDebugStringW, weird behavior in DbgView

I'm using OutputDebugStringW in my application. Since WinDBG does not automatically append a newline, I had to add the \n in my output buffer: #include #include int main() { wchar_t buff[100]; ZeroMemory(buff,…
daisy
  • 22,498
  • 29
  • 129
  • 265
1
vote
2 answers

convert wchar_t array into int array in C

I'm trying to convert a wchar_t array into an int array which contains the encoding of each wchar_t element in C. I know I can do this by a loop like the code below, is there any other way without using a loop which can greatly improve performance? …
1
vote
1 answer

Is it possible to copy wchar_t* strings to vector as a new string of characters?

What I am trying to do is to save multiple different pointers to unique wchar_t strings into a vector. My current code is this: std::vector vectorOfStrings; wchar_t* bufferForStrings; for (i = 0, i > some_source.length; i++) { // copy…
1
vote
1 answer

How can I hand a wchar_t* over to espeak without getting German characters spoken incorrectly?

I'm using espeak-ng to turn German-language traffic messages into speech. See this example text: B6 Weserstraße B71 Seeborg vorübergehende Begrenzung der Breite. B213 Wildeshauser Landstraße Delmenhorst-Deichhorst wegen Baustelle gesperrt. The…
Neppomuk
  • 1,102
  • 1
  • 11
  • 24
1
vote
1 answer

Unable to ignore the escape characters from a text file stream & store in a wchar_t [ ] in C++

I am trying to read data from a text file using C++ & store the strings at each line into wchar_t [] or LPCWSTR. (These 2 datatypes are the constraints of the application on which I am working. That's why I have to store the data in these…
user14200418
1
vote
1 answer

How to convert char to wchar_t*?

As the title states I have a simple char that retrieves a full path name of a file I am looking for and I need to convert it to const wchar_t. How can I achieve this? Here is an example of the code: int main() { char filename[] = "poc.png"; …
D. Absolut
  • 13
  • 3
1
vote
1 answer

C++ Argument of type "const wchar_t" * incompatible with parameter of type "wchar_t"

Сan't call "GetProcessByExeName" DWORD GetProcessByExeName(wchar_t* ExeName) { PROCESSENTRY32W pe32; pe32.dwSize = sizeof(PROCESSENTRY32W); HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPALL, NULL); if (hProcessSnap ==…
danrom11
  • 27
  • 6
1
vote
1 answer

Converting to wide characters on z/OS

I have the following code on Linux:- rc = iconv_open("WCHAR_T", SourceCode); prior to using iconv to convert the data into a wide character string (wchar_t). I am now compiling this on z/OS. I do not know what value to use in place of "WCHAR_T". I…
Morag Hughson
  • 7,255
  • 15
  • 44