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

Portable way to use the regex(3) functions on a wide char string in C

There are functions like regwcomp(3) etc. on some systems, but this does not seem to be a portable solution at the moment. When there is a wchar_t string, what is the suggested portable solution (not Linux or GNU specific) to use the regex(3)…
user3224237
  • 448
  • 6
  • 12
2
votes
2 answers

One function for handling char* and wchar_t*

Right now I have two functions which do the exact same parsing stuff, one for char* and one for wchar_t*. I'd like to have just one function so that I only need to change it once (for consistency). Converting the whole string to char* or wchar_t* is…
MrTux
  • 32,350
  • 30
  • 109
  • 146
2
votes
1 answer

How to pass a char* to the GetModuleHandle function?

I'm just trying to get the module information based on a string that can very well be something like "somefile.exe". MODULEINFO GetModuleInfo(char *szModule) { MODULEINFO modinfo = {0}; HMODULE hModule = GetModuleHandle(szModule); …
Gera
  • 65
  • 5
2
votes
2 answers

proper style for interfacing with legacy TCHAR code

I'm modifying someone else's code which uses TCHAR extensively. Is it better form to just use std::wstring in my code? wstring should be equivalent to TString on widechar platforms so I don't see an issue. The rationale being, its easier to use a…
Dustin Getz
  • 21,282
  • 15
  • 82
  • 131
2
votes
2 answers

How to convert wchar_t* to long c++

As the title indicates I need to know the best way to convert wchar_t* to long in visual c++. Is it possible to do that? If possible how to do that?
2
votes
1 answer

wstring to wchar_t conversion

I am using Namedpipes communication(C++) to transfer data between two processes. For the sake of comfort, I am using wstring to transfer the data and everything is fine at the transfer end. I am not able to receive the total data on the receiving…
2
votes
2 answers

Conversion between wchar_t* to string

I was trying to create a client in c++ for a web service using a Service Model Metadata Utility Tool, I have established the communication between the two endpoints, but at the client side I receive a wchar_t*, how can i convert it to a…
lulas
  • 860
  • 9
  • 29
2
votes
0 answers

Changing wchar_t from 32 bit to 16bit in iOS

I am porting a windows application to iOS platform. In the c++ code, the wchar_t is widely used instead of using wchar16_t or wchar32_t. The application is coded in such a way in windows assuming the wchar_t to be 16 bit while it takes 32 bit in iOS…
Govind
  • 2,337
  • 33
  • 43
2
votes
1 answer

Convert unicode string into wchar_t

I'm having a little problem with my application while trying to use WindowsAPI... I'm trying to connect to a handle in a way it works, but if I change the code it doesn't works anymore... The code that works: handle_t porta; // Global var …
mauroaraujo
  • 332
  • 1
  • 10
  • 23
2
votes
1 answer

c++ wchar_t array and char array in programming for win32 console

I am writing a program includes output chinese characters using Dev C++. I've added -finput-charset=big5 -fexec-charset=big5 in compiler parameters. I also set the code page of the console to be 950 (traditional chinese) It works perfectly while…
2
votes
1 answer

Convert wchar_t to float in c++

Is there a better way to convert a wchar_t to float? I've only found one solution that actually works. wchar_t buf = GetText(); // GetText() returns a wchar_t float fNumber1 = _wtof(&buf); I've tried the following as well that fail: float fNumber1…
Vince
  • 2,596
  • 11
  • 43
  • 76
2
votes
2 answers

How to get substring from WCHAR array

I have one array of WCHAR is like this WCHAR Path[256]; So I'm passing this array in my function getpath(Path) and It's filling the value in path like this: //device/systemName/ So I want to get only device from above string. My code is here: …
Vikas Sharma
  • 33
  • 1
  • 4
2
votes
2 answers

Unable to create an array of wchar_t

In my code I have an array of wchar_t: wchar_t paths [6] = {L"C:\\Program Files\\SomeAppsSuiteFolder1", L"C:\\Program Files\\SomeAppsSuiteFolder2", L"C:\\Program Files (x86)\\SomeAppsSuiteFolder1", L"C:\\Program Files (x86)\\SomeAppsSuiteFolder2",…
burtek
  • 2,576
  • 7
  • 29
  • 37
2
votes
1 answer

is second argument in vswprintf_s size of buffer or numberofElements

vswprintf_s : msdn link int vswprintf_s( wchar_t *buffer, size_t numberOfElements, const wchar_t *format, va_list argptr ); I'm confused about the second element since MSDN states it to be: numberOfElements Size of buffer. However name…
brainydexter
  • 19,826
  • 28
  • 77
  • 115
2
votes
1 answer

Cython - convert wide string (wchar_t *) to Python 3 unicode object

I'm wrapping a C library to Pyhon 3 using Cython and i'm looking for a way of converting wchar_t string to python object which i want to return from a function. There's an answer in this question, but it involves encoding the string as multibyte…
compostus
  • 1,178
  • 10
  • 13