Questions tagged [wchar]

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 is included to perform input and output operations on wide streams. It can also be used to manipulate the wide strings.

196 questions
1
vote
0 answers

how to make my code handle wchar_t as well

I would really like some help in this. I am relatively new to programming in C++. I need my code to be able to deal with ASCII and Unicode. The following is taking an input szTestString1, finds "Ni" in the input and replaces it with "NI".…
1
vote
0 answers

Wsutil.exe (Native Web Services Compiler): WCHAR* vs LPCWSTR for xsd:string type

Is there a good reason for the native web services compiler to generate a WCHAR * for an xsd:string vs a const wchar_t* (or LPCWSTR in short)? The reason I state this question is that ours is a native c++ application which has std::wstrings…
Raghu
  • 21
  • 3
0
votes
3 answers

Reading string from C# managed code to C++ wchar* [] getting AccessViolation

The question is easy, Want to read a string from managed C# code to my unmanaged C++ code in WCHAR* []. The C function is: extern "C" __declspec(dllexport) int __cdecl myfunc(int argc, WCHAR* argv[]) and in C# I imported the…
user888270
  • 613
  • 2
  • 8
  • 16
0
votes
1 answer

wchar_t reading

I have a mistake in the function for reading the file but I don't know what is wrong. all the symbols are read correctly when the symbol is beyond the ASCII table. while ((c = fgetwc(file)) != WEOF) { if (c != L'\n') { if (i ==…
nikigx2
  • 63
  • 6
0
votes
2 answers

Win32 strange widechar behavior

I haven't used wide chars before. Here's the code from someone else: char moduleFileName[512]; int size = ::GetModuleFileName(NULL,moduleFileName,sizeof(moduleFileName)); char c_drive[256]; char…
fred basset
  • 9,774
  • 28
  • 88
  • 138
0
votes
2 answers

WCHAR overflow when performing wcscpy_s

When trying to retrieve a massive folder path from an outlook mailbox (no 255 char max length in path) I seem not be be handling it correctly, yet i have tried everything on the code and nothing seems to shine some light on the issue. Path: …
Carlos
  • 5,405
  • 21
  • 68
  • 114
0
votes
3 answers

C++ How to wprintf an int as wstring

I have the following code. I want it to print the letter A but it gives me 65. How do I wprintf the wchar/wstring of this number? int aa=65; std::wstring ws65 = std::to_wstring(aa); wprintf(L" ws65 = %ls \n", ws65.c_str());
user3443063
  • 1,455
  • 4
  • 23
  • 37
0
votes
0 answers

With MacOS Ventura, using VSC, Clang compiles, but GCC does not. Compile Error: wchar.h: No such file or directory

Clang Compiles, but GCC does not. /usr/local/Cellar/gcc/12.2.0/include/c++/12/cwchar:44:10: fatal error: wchar.h: No such file or directory 44 | #include
tom_kp
  • 21
  • 4
0
votes
2 answers

Converting SQLWCHAR * to char*

Working for the first time in the area of unicode and widechars, I am trying to convert WCHAR* to char*. (WCHAR typedefed to SQLWCHAR, and eventually to unsigned short) And I need to support all platforms(windows, mac, linux). What I have as input…
rahman
  • 4,820
  • 16
  • 52
  • 86
0
votes
1 answer

printf() not working with wchar_t no matter what I try

This doesn't work - nothing is printed. #include #include #include int main(void) { setlocale(LC_ALL,""); wchar_t a = 0xfe; printf("%lc",a); return 0; } I've just been staring at it and trying…
Bfyuvf
  • 139
  • 9
0
votes
1 answer

My WCHAR* variable prints unicode chars in my C project

I made a small linked map for my C project. And I'm using this map for cache my checks, I'm putting current file path to map. If the same file path request again, it has to get value from the cache map. struct StrBoolNode { const WCHAR* key; …
fladon
  • 65
  • 6
0
votes
1 answer

Error C2440 when compiling a library with meson

I have code C++ that I want to compile as a library using meson where I get 2 kinds of errors error C2440: 'initializing': cannot convert from 'const wchar_t [19]' to 'const PWCHAR' -note: Conversion from string literal loses const qualifier (see…
user3443063
  • 1,455
  • 4
  • 23
  • 37
0
votes
1 answer

Why can't wcout use the hex keyword to output hexadecimal format?

I have entered a wchar type variable and want to see the hexadecimal of the variable. However,when I use the wcout keyword, I can't always output hexadecimal. Is there a grammatical error? #include void test_wide_character_input() { …
0
votes
2 answers

In C, how to print UTF-8 char if given its bytes in char variables?

If I have c1, c2 as char variables (such that c1c2 would be the byte sequences for the UTF-8 character), how do I create and print the UTF-8 character? Similarly for the 3 and 4 byte UTF-8 characters? I've been trying all kinds of approaches with…
SO Stinks
  • 3,258
  • 4
  • 32
  • 37
0
votes
1 answer

How to deal with wide and narrow buffers in c?

According to embarcadero docs we can use different Format Specifier to output a buffer to the console in my case I have a function that reads from a stream and outputs to the console but sometimes the stream is wide other times it is narrow and I…
loaded_dypper
  • 262
  • 3
  • 12