Unicode plugin help [Archive] - Quintessential Forum

PDA

View Full Version : Unicode plugin help


acozz
03-25-2004, 09:58 PM
Alright, it has come to my attention that Cover Art Vis isn't working in Win98, and I think this is because of a unicode issue.

Some things to know:
- pluginInfo->version = PLUGIN_API_VERSION_WANTUTF8;
- UNICODE is defined
- unicows.lib is the first library I attach with a #pragma in QCDVisualsDLL.cpp, I assume this carries through all my source code files which all use unicode
- I never use TCHARs or LPTSTR, I always explicitly use WCHAR of WCHAR*
- Whenever I call a QCD op that returns char*, I follow it with the op to convert it to UC2 and put that in a WCHAR*.

The problem as I understand it is that unicode strings are failing to be used, as when the Win98 user goes into the config dialog, there is no text in the list boxes and any entered text isn't saved.

Anything I should know or am doing wrong? Any help is appreciated.

Paul
03-25-2004, 10:07 PM
Two things:
When you convert to USC2, make sure you are doing a WideCharToMultibyte on Win9x, and UTF8toUCS2 on WinNT.

Using a pragma for linking won't cut it. Go to the linker in MSDev and set all default libraries on the ignore line, then set all needed libraries on the module line after unicows.dll. See image:

acozz
03-25-2004, 10:25 PM
Two things:
When you convert to USC2, make sure you are doing a WideCharToMultibyte on Win9x, and UTF8toUCS2 on WinNT.

Using a pragma for linking won't cut it. Go to the linker in MSDev and set all default libraries on the ignore line, then set all needed libraries on the module line after unicows.dll. See image:

I think you mean MultibyteToWideChar.

Thanks, I'll try these out. One question, why doesn't the UTF8toUCS2 check the Windows version and use MultibyteToWideChar if necessary?

Paul
03-26-2004, 01:01 AM
One question, why doesn't the UTF8toUCS2 check the Windows version and use MultibyteToWideChar if necessary?
The UTF8<->UCS2 service ops don't check Windows versions. They are strict utf8 conversions.
I will add MB<->UCS2 service ops which does do the check.

acozz
03-28-2004, 05:18 AM
Which code page should I use on Win9x in the coversion?

Paul
03-28-2004, 06:18 AM
This is what I do:

if (GetVersion() < 0x80000000) // NT
QCDCallbacks.Service(opUTF8toUCS2, (void*)abuf, (long)wbuf, wbufsize);
else
MultiByteToWideChar(CP_ACP, 0, abuf, -1, wbuf, wbufsize)

The reason for this convolution is if the player sent utf8 to win9x systems, it would take two steps to convert it to the local encoding (utf8->unicode->acp). So sending acp in the first place is more efficient.