PDA

View Full Version : Two Byte character Support


rajveer
21st August 2008, 09:49
How two byte support can be done.

wysota
21st August 2008, 11:52
How two byte support can be done.

Please be more specific and stop spamming me with same private messages all over or you'll start receiving infractions for spamming.

aamer4yu
22nd August 2008, 09:41
Did you see QChar ?

rajveer
23rd August 2008, 11:02
1 how can this conversion done:

a) wchar_t* to char*
b) wchar_t* to LPSTR

rajveer
23rd August 2008, 13:04
NO i didn't see earlier but now i see it. but i have to do the conversion of wchar_t* to char* and wchar_t* to LPSTR.

ktk
23rd August 2008, 23:12
If you insist on a Qt based solution, have a look at QString::fromWCharArray() and QString::toLatin1() etc.

jacek
24th August 2008, 01:37
{merged two and a half thread}

Please, don't start more than one thread on the same topic.

wysota
24th August 2008, 19:09
Is it really a Qt-related question?

rajveer
25th August 2008, 06:10
yeah, i have to convert w_char_t* to char* and wchar_t* to LPSTR.
please help me out.

wysota
25th August 2008, 06:58
LPSTR is the same as char* so no conversion is required. As for wchar_t* it is the same as PWSTR and I'm sure that a visit to msdn.microsoft.com will reveal a proper conversion.

Moving the thread to general programming forum...

krsmichael
25th October 2008, 01:29
LPSTR is the same as char* so no conversion is required. As for wchar_t* it is the same as PWSTR and I'm sure that a visit to msdn.microsoft.com will reveal a proper conversion.

Moving the thread to general programming forum...


This answer is not quite right. It depends on the platform and, on Windows, whether "UNICODE" is defined or not. A wchar_t* is 2 bytes, ucs2, on a Windows machine. On a Mac or Unix machine, it is typically 4 bytes, usc4. I wouldn't bother doing this with C++ without QT. A QChar is UCS2 on all platforms. The encoders from USC2 to ascii code pages are consistant and do the right thing. To do wchar_t* to char* and back requires a third party encoder. IBM has an open source one. I don't remember the name. BTW, scripting languages such as Lua and Python will have a Unicode implementation based on the wchar_t of the compiler that it is built with. C# is always USC2 no matter what platform. The moral of the story...stick with QT.

C++ does not have encoding built in.