Problem with Unicode

Anybody help me please ! How can i use unicode string in C++. I use Eclipse IDE for C/C++, MinGW to build project.
Thanks.
std::wstring holds a UTF-16 unicode string. It's methods are the same as those of std::string.

The standard library does not provide a conversion between unicode and ascii.

A standard string constant is defined as:
L"This is a Unicode string constant."

There is a set of wide string operations in C. All the strXXX functions in C have wcsXXX equivalents that handle wide strings, e.g. wcslen() returns the length of a wide string.
but, how can trace it's value. I can't use cout or printf or wprintf for it !
If you have wprintf, you ought to be able to use it.

I recomend reading this:
http://cplusplus.com/forum/articles/16820/
Not useful ! It tells me use "wcout" but not useful. And wchar* with wprintf also is bad !!
Disch wrote:
Try the following:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
int main()
{
  HANDLE hin = GetStdHandle(STD_INPUT_HANDLE);
  HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);
  wchar_t buf[512];
  DWORD rd;

  ReadConsoleW( hin, buf, 512, &rd, 0 );
  WriteConsoleW( hout, buf, rd, &rd, 0 );

  getch();

  return 0;
}


Does this not help?
Last edited on
I don't see anything ? Output console's empty ! Not allow put in, not allow display... Nothing.
Did you try the code L B posted? That really should work.

Here's a more simple test:

1
2
3
4
5
6
7
8
int main()
{
  wchar_t buf[] = L"This should be displayed in the console.";
  DWORD written;
  WriteConsoleW( GetStdHandle(STD_OUTPUT_HANDLE), buf, sizeof(buf), &written, 0 );

  return 0;
}


This should display the text in the console. Try that and see if it works.
Just works in Codeblocks, not work in Eclipse for C/C++ ! Even thought, I use MinGW to compile !
Last edited on
Topic archived. No new replies allowed.