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

How to convert wchar_t (or wchar_t* or CORBA::WChar*) to string?

In my app I have to use CORBA::WChar* (or equivalent wchar_t*) but my program also needs to save some information to the PostgreSQL database. To insert data to PostgreSQL in C++ I use SOCI. And there's the problem because : The following types are…
Brian Brown
  • 3,873
  • 16
  • 48
  • 79
0
votes
1 answer

How to handle wchar_t ** with python ctypes?

I've a dynamic C library (say foo.so) in which there's a function having the following prototype wchar_t **foo(const char *); /* The structure of the return value is a NULL terminated (wchar_t **), each of which is also NULL terminated (wchar_t…
user975506
0
votes
1 answer

Reading UTF8 from System in C++ Windows

My Windows application calls a system command using _wpopen. This command produces a UTF8 response that I attempt to read using fgetws into a buffer of wchar_t. The problem is that the result in my buffer is not correct. There might be a problem…
0
votes
1 answer

convert char * to wchar_t *

I have a file.txt encoded in gbk, I read some bytes through ifstream::read and store them into a char buffer, then I want to print every word in the buffer in gbk. I assume wchar_t is needed here, so I do it like this: int main() { ifstream…
Alcott
  • 17,905
  • 32
  • 116
  • 173
0
votes
1 answer

wcslen quits silently when string returned by the ReadConsoleOutputCharacterW has some particular length

compiler : http://sourceforge.net/projects/mingwbuilds/files/ #include #include #include using namespace std; const wchar_t* readConsole(int chars_to_read) { wchar_t* wcharFromConsole = new…
rsk82
  • 28,217
  • 50
  • 150
  • 240
0
votes
3 answers

how to rtrim wchar_t using specific unicode codepoint?

For example I have defined such string: const wchar_t mystring[] = L"зеленыйййййййййййййййййййййййй" And I need to change it to: зелены What options I have ? Is there anything like: wsrtrim(input,char_code) ?
rsk82
  • 28,217
  • 50
  • 150
  • 240
0
votes
2 answers

How to get codepoint of particular WCHAR character?

For example I need codepoint of 5th character here, that is ð const WCHAR* mystring = L"Þátíð"; I know that it has code point : U+00F0 - but how to get this integer using c++ ?
rsk82
  • 28,217
  • 50
  • 150
  • 240
0
votes
2 answers

C++ wstringstream << NULL

I'm having an issue with wstringstream. When I'm doing this std::wstringstream ss; wchar_t* str = NULL; ss << str; Application crashes with error Unhandled exception at 0x53e347af (msvcr100d.dll) in stringstr.exe: 0xC0000005: Access…
user1112008
  • 432
  • 10
  • 27
0
votes
1 answer

C++ Multitype object idea

My program needs a lot of ANSI<=>UNICODE conversation so I got the idea to create multitype object which will convert all stuff easier than addinational function and a lot of new/delete. Pseudocode: class CWchar // char based { public: public…
user1112008
  • 432
  • 10
  • 27
-1
votes
1 answer

printf(), fprintf(), wprintf() and NSlog() won't print on XCode

I'm doing a small app for evaluating and analyzing transfer functions. As boring as the subject might seem to some, I want it to at least look extra cool and pro and awesome etc... So: Step 1: Gimme teh coefficients! [A bunch of numbers] Step 2:…
whtlnv
  • 2,109
  • 1
  • 25
  • 26
-1
votes
1 answer

Windows Dialog : how to convert type PWSTR to char*?

I am using a Windows Dialog to select a file. The output type I receive is a PWSTR. Whenever I've tried to convert it to char*, all I get is the first character of the string (ie 'C'). For some context, my variable name is pszFilePath. I have used…
-1
votes
1 answer

wchar_t user input with spaces

Im currently using wchar_t for a username, however, I'm having an issue when the username contains a space when using std::wcout as it will just get the first word typed. I am aware of getline for when your user input contains a space but I can't…
Kryton
  • 95
  • 1
  • 5
-1
votes
1 answer

How to write qsort() comparator for sentence and text structs?

Suppose I have a struct Sentence and a struct Text. How do I implement qsort on capital_letters_quant? How can you write out the same compare function? struct Sentence { wchar_t* sentence_text; size_t sentence_size; bool…
-1
votes
1 answer

c++ How to read a wchar_t* to into a std::wsting variable and print in HEX

In main I have a wstring mystr that contains unicode characters. int main() { std::wcout << std::hex << 16 << endl; std::wstring mystr = L"abc - "; result = myfun(mystr); // here I want to print out my variable result //std::wcout…
user3443063
  • 1,455
  • 4
  • 23
  • 37
-1
votes
1 answer

Returning strings from functions in C++

I have a function: BOOL ReadWebPage(CONST TCHAR *sURL, TCHAR *sDataRead) { BOOL rv = FALSE TCHAR *sFile = new TCHAR[1024](); StringCchCopy(sFile, 1024, L"c:\\temp\\file.txt"); res = URLDownloadToFileW(NULL, sURL, sFile, 0, NULL); if (res != S_OK) …
JeffR
  • 765
  • 2
  • 8
  • 23