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
-2
votes
1 answer

Visual Studio C++ 2019. How to convert wstring to WCHAR *

i tried google search a lot but only found the ways how to convert string to const LPCWSTR I try this code but i can't success string s = "ABCD"; wstring stemp = wstring(s.begin(), s.end()); WCHAR* sw = stemp.c_str();
-2
votes
1 answer

overloading operator for string in c++

I have a class named Fstring, it has a wchar_t* in it. I wrote the following to copy the string literal into Fstring: #include using namespace std; class Fstring{ wchar_t *arr; public: Fstring& operator = (const wchar_t temp[]) …
-2
votes
1 answer

defining wchar_t to 2byte

In my application I always need wchar_t to be 2 byte. I know -fshort-wchar can do this. But I can't use this on zSeries. is there any other way to define wchar_t to 2 byte?
Nagasai Sowmya
  • 271
  • 2
  • 3
  • 4
-2
votes
1 answer

Win32 API Visual C++ ReadFile() function generates gibberish if second parameter is LPWSTR

I was trying to make a very basic text editor with Win32 that has the ability to read files and change the text of an edit control to it. I want it to be able to handle chars in all languages, so I tried to use a LPWSTR for the second parameter of…
Tyler Tian
  • 597
  • 1
  • 6
  • 22
-2
votes
2 answers

Declaring a std::string after Unicode to ASCII conversion is giving Segmentation fault

I am trying to take a wchar_t string from stdin and then convert it from unicode to ASCII through a function. The function is somehow not allowing me to use std::string further in the program. #include #include #include…
-2
votes
2 answers

ASCII characters in C

I'm trying to save a character from the cyrillic alphabet in a char. When I take a string from the console it saves it in the char array successfully but just initializing it doesn't seem to work. I get "programName.exe has stopped working" when…
-2
votes
1 answer

What are inconveniences of using UTF-8 instead of wchar_t with non-Western languages?

Apart from storage size differences, what are the differences between using wchar_t (2-byte or 4-byte) and using UTF-8 encoding for text processing programming oriented to non-Western languages? When using wchar_t, one can use wide versions of…
Al Berger
  • 1,048
  • 14
  • 35
-2
votes
2 answers

Conversion from UTF-8 to ANSI wcstombs failes at one spezial character

I want to change a wchar_t* like it is displayed to a char*. No conversions like in the WideCharToMultibyte should be done. I found the wcstombs function and it looked like it works perfectly, but there is one char which does not get changed…
Ich
  • 1
  • 1
-3
votes
1 answer

Why are two strings with same content different while using wchar_t?

I am writing a code for comparing two strings of type LPSTR and wchar_t type. The contents of strings are same but the output is showing that the strings are different. Below is screenshot of the complete code. #include #include…
akashagrawal
  • 3
  • 1
  • 7
-3
votes
1 answer

Never seen this syntax before, can someone explain..... return L""

Its been difficult trying to find an explanation online on the below syntax and searching for L"" in these forums doesn't provide any results. I'm inside Qt5 debugging an application which is too lengthy to paste here. I'm trying to resolve this…
bAsH
  • 25
  • 4
-3
votes
2 answers

Required to convert a String to UTF8 string

Problem Statement: I am required to convert a generated string to UTF8 string, this generated string has extended ascii characters and I am on Linux system (2.6.32-358.el6.x86_64). A POC is still in progress so I can only provide small code…
Sanyam Goel
  • 2,138
  • 22
  • 40
-4
votes
1 answer

How do I add a Variable into a wchar_t null terminated string

I am using C++, Unicode. What I am trying to do is pretty much this: int Main(){ int test = 5; std::cout << "hi " << test; return 0; } Output: hi 5 I am using C++ so which method should I use? So I can add a int/NullTerminated. The reason for this…
-4
votes
1 answer

How to find a unicode char pointer in a void pointer?

Assume I have the following: wchar_t *x = L"myname"; void *y = 0; // assume that p is already assigned previously to any given buffer How can I determine if the unicode char pointer x is inside the void* y buffer? Basically How can I find a needle…
Farrell32
  • 7
  • 3
-5
votes
1 answer

C++ wchar_t* not working

wchar_t* Pfad; wcin >> Pfad; wchar_t* file = Pfad + "*.quiz"; Not working for me, how can I make this work? It says "*.quiz" is wrong, something like it has to be a numeric value or something like that. Well sorry, I am new to c++... and…
user3566608
  • 353
  • 3
  • 15
1 2 3
31
32