Hi!

Wolfram Gloger wrote:

>>The real cause is not the filename itself it is the conversion from QString 
>>to 
>>std::string and back, because the internal format of QString is unicode 
>>whereas std::string is using ascii.
> 
> That is not true.  I can put anything I want in std::string, it
> doesn't care whether it is UTF8 or ascii or latin1 or whatever, as
> long as it consists of 8 bit "characters".

It can do so because it doesn't (have to) interpret the data.

Qt, however, has to map the raw bytes to font glyphs. The result of that
translation - i.e. whether 0x41 is displayed as "A", and so on - always
depends on the chosen character set encoding.

> If there really is a locale-dependent conversion going on whenever
> converting QString <-> std::string -- what a horrible misdesign (in
> QString)!  Is that really unavoidable?

It has to be done somewhere - either inside or outside the GUI toolkit.
Qt leaves that task to the application, assuming that it knows best what
a particular string of bytes means. It's not a design error, it's a
logical choice.

On the other hand, the world is a jungle where every animal might use a
different encoding. Even if you use UTF-8 throughout a system, there are
other systems on the net that don't. I've been bitten by that myself
several times when I used an entirely UTF-8 based Linux desktop at work.
Login to a Latin-1 based system via ssh, and then type some umlauts to
see what I mean. I finally gave up and instructed the keyboard driver to
not generate Unicode characters any more. There are too many systems in
my personal jungle who don't understand them. Your mileage may vary.

In general, the character encoding problem is unsolvable - plainly
because there are different encodings. Possibly even inside the same
filename - just consider a path like "Ä/Ö/Ü" where each component is
stored in a different string inside the file system. As far as I can
tell, there are only two ways to cope with it:

- treat filenames as opaque objects (i.e. strings of raw bytes)
- use the same encoding for all filenames

The former won't work because Qt requires UTF-8 encoding.

The latter might be impossible in some cases (e.g. when you mix
Unix/Linux, Windows and networked file systems).

-- 
Michael "Tired" Riepe <[EMAIL PROTECTED]>
X-Tired: Each morning I get up I die a little

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
DVBCUT-user mailing list
DVBCUT-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dvbcut-user

Reply via email to