[Interest] Converting std::string.c_str() code to use QString methods

Thiago Macieira thiago.macieira at intel.com
Sat Aug 31 18:55:23 CEST 2013


On sábado, 31 de agosto de 2013 11:41:20, Till Oliver Knoll wrote:
> Am 31.08.2013 um 03:00 schrieb Thiago Macieira <thiago.macieira at intel.com>:
> > ....
> > 
> > As I said in the other email, if you're going to run this code on Windows,
> > you should stop using fopen and iostreams.
> 
> Out of curiosity (and since I am a "spoiled Qt child" and basically never
> touched most of the "C Lib" API ever since, let alone the STL *quickly
> cruzifies himself*): what is the problem with fopen on Windows? The thing
> with "wchar vs char" (?) and how Windows encodes file names?

Yes.

On Windows, the filesystem stores the file names in UTF-16. However, the 8-bit 
API for applications uses a non-Unicode codec on most Windows versions (the 
exception is Vietnamese Windows). For example, on Windows on English uses 
CP1252, which is a slight expansion on Latin 1 (ISO-8859-1) with a few more 
characters in the 0x80-0xA0 range.

That means the filesystem may have paths that the 8-bit API cannot open and the 
user may give you a file name that cannot be encoded into 8-bit.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130831/1d6e5c53/attachment.sig>


More information about the Interest mailing list