I just tested and found that it's the Qt or M$'s stdc++ lib
that made the mistake. LyX call Qt to convert filenames to
UTF-32, and then call Qt again to convert it to local 8bit.
Finally, the converted results is transfered to i/ofstream
to open the files. I know that M$'s libaray can _never_
properly pass 8-bit strings, in any local... So, there may
be two problems:
(1) Qt uses incorrect local. I have printed some trace,
and it seems Qt treat my local as latin1. I will double check this.
(2) M$'s i/ofstream can't accept 8-bit string as filename. That's the
worst thing, but M$ always do such disgusting things... Even though
all other libraries can pass 8-bit strings in local encoding.
My tex2lyx just successfully converted one .tex file with Chinese name.
The filename is accepted from argv. But the file open procedure is
changed. I'll check whether Qt properly handles my local. If so,
it must be M$'s evil. If it's the case. we need to patch a lot of different
places. All file open from fstream, and all file open from clib must
be patched...
Or, can we use another stdc++ and clib to replace it?
Hangzai
----- Original Message -----
From: "Andre Poenitz" <[EMAIL PROTECTED]>
To: "hzluo" <[EMAIL PROTECTED]>
Cc: <lyx-devel@lists.lyx.org>; <[EMAIL PROTECTED]>
Sent: Wednesday, June 13, 2007 3:54 PM
Subject: Re: [patch] tex2lyx crash when full path is given from commandline
on Win32
On Wed, Jun 13, 2007 at 02:23:21PM -0400, hzluo wrote:
I just tested it, and the answer is no...
At least on Windows XP with local set to Simplified Chinese,
LyX does not accept any filename with Chinese characters.
Neither lyx.exe nor tex2lyx.exe can propertly handle such files.
I suspected so much.
I'm trying to make a patch for this problem.
Note that argc/argv are not usable in this setup as they are already
trashed when passed into main().
A proper solution probably involves CommandLineToArgvW from shell32.lib
(#include <shellapi.h>) wrapped in #ifdef WIN32. This is documented
to be available since NT 3.51, so it should be fine for us.
Andre'
PS: I wonder whether delegating that kind of mess to an external
library would be politically correct in this universe ;-}
PPS: For completeness' sake and only if you have the time to spare:
could you please try the same with anything that causes ForkedProcess to
run with arguments containing Chinese characters? Using \spell_command
CHINESE_PATH_TO_ISPELL or using graphics with chinese file names might
already do the trick.