I have a Windows application written in LabVIEW, where path arguments are passed to a DLL which uses Qt. Inside the DLL, I create a QString (passing the char* from LabVIEW to the constructor) to open a QFile.

When the path contains Korean symbols, conversion to QString seems to fail in some way. I added

Qt Code:
  1. QTextCodec* codec = QTextCodec::codecForName("EUC-KR");
  2. QTextCodec::setCodecForCStrings(codec);
To copy to clipboard, switch view to plain text mode 
and also tried

Qt Code:
  1. QTextCodec* codec = QTextCodec::codecForName("UTF-8");
  2. QTextCodec::setCodecForCStrings(codec);
To copy to clipboard, switch view to plain text mode 

before using QString::QString(const char*), but the problems remain. The first try returns a 0-codec (not found), the second try still fails to convert.

I also tried using QString::fromLocal8Bit(), but even on my english machine this returns a string of size zero. Maybe something to do with the '\' character in the path?

On the National Instruments forum (LabVIEW) I got the following reply concerning the way LabVIEW passes the string to my DLL:

I don't think that we reinterpret your string in anyway, just reformat the data so that it can be passed to your dll.

So assuming you are getting text from, say, keyboard editing, the text should be in the ANSI codepage that the system is running under. That is, if you are running Windows using an English locale, it will be codepage 1252 (Windows Western, Latin 1), if you are running Windows with a Korean codepage iirc it will be codepage 949, Unified Hangul code.

If you are filling the string with data that you get from an instrument or some other fashion, it could really be anything.

Here is a list of the codepages that Windows knows about

http://msdn2.microsoft.com/en-us/lib...46(VS.85).aspx


I do have some experience with Qt as well, and I think that the function you are looking for to create, say, a QString from this is:

QString::fromLocal8Bit

but I am not 100% certain about this as I am not a Qt expert.

Jeff Peters
LabVIEW R & D
The important thing to note here is everything worked fine when I used fopen (C) or std streams instead of Qt to read the files. I changed them to QDataStreams because of some advantages and would not like to go back in time. But it also means something must be happening in the part where the QString is created from my char*, and not earlier.