On Wed, Oct 15, 2008 at 10:52:02PM +0200, Jean-Marc Lasgouttes wrote:
> Andre Poenitz <[EMAIL PROTECTED]> writes:
> > +   setlocale(LC_CTYPE, "");
> 
> Are we sure that the locale of LyX matches the encoding of the file
> name?

I am not quite sure what you mean but "locale of LyX". This is the
tex2lyx binary that does not have a Q[Core]Application that does
this 'setlocale' for us in the LyX application.

On closer inspection, it is

        void QCoreApplication::init()
        {
                ...

        #ifdef Q_OS_UNIX
                setlocale(LC_ALL, "");                // use correct char set 
mapping
        #endif

so maybe we should do the #ifdef in tex2lyx, too, 

> If I set locale to C, it does not change the name of the file,
> does it?

The problem is that the file name is in a non-"C" encoding but
the applications starts up assuming a "C" locale, therefore 
getting problems beyond 7 bit.

The question is whether file content input/output is affected:
As we mainly pass through it should just work [I just tried with
Russian, and it looks ok...], at least for 8-bit encodings.
Apart from that, tex2lyx is broken for >7 bit in general anyway
(see the latin1 assumption for german umlauts...)

An option would be something like

   char *locale = setlocale(LC_ALL, "")

for the filesystem accesses and reset the locale using

   setlocale(LC_ALL, locale) 

before reading file contents. That is probably closer to the 
current behaviour but broken at a similar level.

> I thought that Qt had a magic method to convert from the encoding
> of the file system.

Sure. But we are not using it ;-}

Andre'

PS: I can have a look at this tex2lyx encoding mess in early 1.7.  It's
actually pretty straightforward to solve: Convert from native, possibly
mixed-within-a-file to some "internal" encoding (using docstring or
QString) and produce UTF8 .lyx on output. Make lyx2lyx convert
everything to UTF8 (will need python help here...), then LyX can assume
UTF8 in .lyx files. Produce output in a suitable encoding for .tex
output.

Reply via email to