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
votes
2 answers

how do I create a functioning vector that has an erase(size_t pos) method?

I am creating a C++ wstring class for use with mingw version 4.3.0, cross-compiling for Win32. I want my string to work like std::string which means that I want an erase(int pos) method that erases a single element at position pos. Here is my first…
vy32
  • 28,461
  • 37
  • 122
  • 246
-1
votes
2 answers

How to print wchar_t variables in C

I am debugging some old C code written in our company. The function is something like this -- uint32 ExecuteCommand(wchar_t *dnsName, // IN wchar_t *dnsUser, // IN …
user496934
  • 3,822
  • 10
  • 45
  • 64
-1
votes
1 answer

How to write windows-936 to log When wchar_t in the code by boost.log

Follow the boost.log , the sample.log was parsed as utf8. Now I want to write at windows.936, but the code below is useless. void init_logging() { ... std::string strCodePage = boost::locale::util::get_system_locale();//strCodePage is…
sculida
  • 11
  • 3
-1
votes
1 answer

Using wstring and wcout doesn't get the expected output

I'm writing a program in C++ which have to handle unicode characters. The main problem is I use algorithms where I need to parse my s/wstrings char by char : std::wstring word = L"Héllo" for (auto &e : word) // doing something with e But if I run…
LightMan
  • 53
  • 1
  • 8
-1
votes
1 answer

Is it possible to change the content of a wchar_t*?

I have a function that receive a wchar_t* parameter named somestring. I'd like to resize wchar_t* somestring to contain more elements than it is passed, bBecause I want to copy something larger than the original string: void a_function(wchar_t…
felipe
  • 1,212
  • 1
  • 15
  • 27
-1
votes
1 answer

Cannot convert from lpstr to wchar_t

I got a piece of code from a Bluetooth example on the web, where we use a condition: ULONG NameToBthAddr(_In_ const LPWSTR pszRemoteName, _Out_ PSOCKADDR_BTH pRemoteBtAddr) { INT iResult = CXN_SUCCESS; BOOL …
user6812514
  • 49
  • 1
  • 7
-1
votes
2 answers

How to load a html file to memory?

I want to load a html file to memory (in fact a wchar_t string). And this is the code: size_t myGetFileSize(const wchar_t *wcPath) { struct _stat fileinfo; _wstat(wcPath, &fileinfo); return (fileinfo.st_size); } int…
Shaheen
  • 53
  • 6
-1
votes
2 answers

Declaration of wchar_t by myself

Please tell me, where can I find the wchar_t declaration. I use linux, and I think it is 32 bits. I need to declarate this type, because i can't use the standart library (it is used in my boot programm). The files /usr/include/wchar.h and…
Maxim Gusev
  • 213
  • 3
  • 10
-1
votes
1 answer

C/C++ Set encoding to UNICODE.. How to write 'ă' to a file

I am trying to write special characters to a file. To be specific something along the 'ă' character, which apparently has the U+0103 Code. I do not understand how to set the encoding to UNICODE. And how to actually print that character. Everything I…
RatkinHHK
  • 27
  • 1
  • 4
-1
votes
2 answers

memcpy only copies first half of wchar_t array

I am encountering an error when I try to use memcpy on a wchar_t string. Specifically, despite the length I am sending in to memcpy being correct for the length of the string I want to copy, only the first half of the characters in the string are…
CodeRedd
  • 283
  • 1
  • 4
  • 14
-1
votes
1 answer

how to copy a wchar_t from a char array

Assume I've an array of strings which contain some chinese chars inside. Eg: " This is a sample 在按键 needs to be tested" ^ ^ | | start end I need to extract only the chinese alone…
-1
votes
2 answers

Instantiate C++ function using wstring instead of wchar_t

I have a C++ overloaded function and one of its variants receives a wstring as a parametre, but when I call it like myfunc(L"Some text"), the compiler complains that there is no variant of the function which accepts wchar_t *. What should I…
Petru Dimitriu
  • 365
  • 1
  • 5
  • 14
-2
votes
1 answer

cannot convert 'const wchar_t*' to 'LPCSTR' {aka 'const char*'}

Please help me with this code, I don't know how to change it so I can fix it and run it std::wstring stemp = std::wstring(filename.begin(), filename.end()); hBitmapG = (HBITMAP)LoadImage(GetModuleHandle(NULL), stemp.c_str(), IMAGE_BITMAP, …
-2
votes
1 answer

Is " const wchar_t* " a pointer?

Normally when we write: int a = 10; int* ptr = &a; std::cout << *ptr; Code output is: > 10 But when I write this: const wchar_t* str = L"This is a simple text!"; std::wcout << str << std::endl; std::wcout << &str << std::endl; Code output is: >…
-2
votes
2 answers

Get the last token out of wchar_t*

I have a wchar_t* in my C code, that contains URL in the following format: https://example.com/test/...../abcde12345 I want to split it by the slashes, and get only the last token (in that example, I want to get a new wchar_t* that contains…
alon
  • 57
  • 1
  • 1
  • 6
1 2 3
31
32