wchar.h is a header file in the C standard library. It is a part of the extension to the C programming language standard done in 1995. It contains extended multibyte and wide character utilities. The standard header
Questions tagged [wchar]
196 questions
1
vote
0 answers
Can std::wofstream << WCHAR and << CHAR at the same time?
How can we write WCHAR and CHAR to a wofstream at the same time?like this:
wofstream << L"汉字" << "汉字"
Here is something for testing. I can only "wofstream<

Li Da
- 41
- 4
1
vote
1 answer
EILSEQ with fgetws() and UTF-8
The following C code reads lines from stdin using fgetws() and writes them to stdout.
#include
#include
#include
#define STR_LEN 128
int main(int argc, char **argv)
{
FILE *infile = stdin, *outfile = stdout;
…

Rat Salad
- 23
- 4
1
vote
2 answers
fwprintf: only the first character from a wide char array argument gets copied to output
I'm trying to write a message containing "alpha = abcd" to a text file using the following code:
#include
#include
int
main()
{
const wchar_t *a = L"abcd", *msg = L"alpha = %s\n";
FILE *f =…

user6039980
- 3,108
- 8
- 31
- 57
1
vote
1 answer
Cannot convert parameter from WCHAR[100] to WCHAR**
I have a method expecting WCHAR**, i need to get some data back from this method. I am declaring an array WCHAR[100] and passing it to the function. The compiler throws this error:
WCHAR result[100];
UINT i;
hr = SomeFunc(handle, &i, result);
error…

Stanly
- 93
- 2
1
vote
2 answers
How to change wchar.h to make wchar_t the same type as wint_t?
wchar_t is defined in wchar.h
Currently, if the developers want to use only wchar_t, they can not do
this without getting type conversion warnings from the compiler. If
wchar_t will be made the same type as wint_t, it will be good for both…

Igor Liferenko
- 1,499
- 1
- 13
- 28
1
vote
2 answers
UNICODE_STRING to wchar_t* null terminated
I want to use the buffer from a UNICODE_STRING, but it seems I cannot just directly use it, by copying reference, because sometime I can see that there are null bytes in the middle of a string, and Length is greater than what I see in the debugger.…

Vlad
- 369
- 4
- 16
1
vote
2 answers
Can WriteFile() be used to write wchar_t characters to a file?
I am trying to write a string of type wchar_t to a file using WriteFile(). Here is the code:
void main()
{
wchar_t dataString[1024];
HANDLE hEvent, hFile;
DWORD dwBytesWritten, dwBytesToWrite;
hFile = CreateFileW(L"e:\\test.txt",…

Neena
- 13
- 1
- 5
1
vote
1 answer
What is the size of a Word in the context of the mbstowcs_s function SizeInWords parameter?
I am having difficulty determining what the exact size of a Word should be in the context of the Windows API function mbstowcs_s. Here is the relevant information from the MSDN as well as the link.
mbstowcs_s, _mbstowcs_s_l
Converts a sequence of…

HighExodus
- 104
- 2
- 11
1
vote
1 answer
Print value of this address
Hello. I have these lines of code in the image above. The second line prints the address. But I like to print the value of this address e.g. "Microsoft Loopback Adapter".
How to do that?

moobi
- 7,849
- 2
- 18
- 29
1
vote
1 answer
Display WCHAR Strings in Xcode Debugger
I'd like to preview WCHAR strings in the variable display of the Xcode 3.2 debugger.
Bascially if I have
WCHAR wtext[128];
wcscpy(wtext, L"Hello World");
I'd like to see "Hello World" for wtext when tracing into the function.

Nicholaz
- 1,419
- 9
- 11
1
vote
1 answer
wstring to const wchar* using c_str()
I'm trying to convert a wstring to const wchar*, but the null terminations aren't working as I expect:
Is there any way to convert wstring to const wchar* in the manner that I'm trying?

user2002287
- 51
- 1
- 6
1
vote
4 answers
Problems with wchar_t sprintf
I was learning how to use wchar, but I am unable to copy the char using snprintf().
I want to copy the text from a to b but it never prints the value. What am I doing wrong?
And I want to use snprintf and nothing else.
#include
#include…

chettyharish
- 1,704
- 7
- 27
- 41
1
vote
1 answer
Am I correctly pointing a PCWSTR to a string literal?
I'm a bit rusty with C++ so I'm looking for help with a string pointer question.
First, let's consider some pointer basics with an integer:
void SetBob(int* pBob)
{
*pBob = 5;
}
int main(int argc, _TCHAR* argv[])
{
int bob = 0;
…

Craig
- 1,890
- 1
- 26
- 44
1
vote
0 answers
Wide-characters support on VxWorks downloadable kernel module
I'm working on porting a project from Linux to VxWorks DKM.
But I face a problem: On linux, wide characters and wide char functions ( like wcslen() or mbrtowc() ) are used in some parts of this project and since VxWorks DKM doesn't support wide…

Eyesam
- 11
- 2
1
vote
1 answer
Compare WCHAR String with Const Char in C?
I have written a code in C which will use the Process32First() API to get information about the process. All the information is stored in the PROCESSENTRY32 structure defined…

Neon Flash
- 3,113
- 12
- 58
- 96