C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

unicode et stream

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French)
View previous topic :: View next topic  
Author Message
Amerio
Guest





PostPosted: Sun Mar 07, 2004 11:02 am    Post subject: unicode et stream Reply with quote



Bonjour,
Je débute avec l'unicode, et j'ai un peu du mal.
J'ai un fichier unicode.txt qui commence comme ca en binaire :
FF FE 54 00 68 00 69 00 73 00 ... : ??T.h.i.s ....

Si j'essaye de le lire ainsi :
std::wifstream fs("unicode.txt");
std::wstring wline;
std::getline(fs, wline);

alors wline contient : (FF),(FE),(54),(00),... en wchar_t
et non pas : L"This"....

Ou est mon erreur ?


Back to top
James Kanze
Guest





PostPosted: Sun Mar 07, 2004 1:14 pm    Post subject: Re: unicode et stream Reply with quote



"Amerio" <amerio (AT) hotmail (DOT) com> writes:

Quote:
Je débute avec l'unicode, et j'ai un peu du mal. J'ai un fichier
unicode.txt qui commence comme ca en binaire :
FF FE 54 00 68 00 69 00 73 00 ... : ??T.h.i.s ....

Si j'essaye de le lire ainsi :
std::wifstream fs("unicode.txt");
std::wstring wline;
std::getline(fs, wline);

alors wline contient : (FF),(FE),(54),(00),... en wchar_t
et non pas : L"This"....

Ou est mon erreur ?

Quel est le locale par défaut ? Il faut bien dire à wfstream
l'encodage du fichier qu'il lit. Sous Linux et sous Solaris, il n'existe
pas de locale pour lire Unicode ; on est donc quitte à l'écrire
soi-même. Sous Windows, je m'attendrais en trouver un, étant
donné que Windows utilise Unicode beaucoup dans ces fichiers (où
le monde Unix préfère UTF-Cool, mais il me semble avoir entendu dire
que le défaut se comportait à peu près comme ce que tu vois.

--
James Kanze mailto:kanze (AT) gabi-soft (DOT) fr
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
11 rue de Rambouillet, 78460 Chevreuse, France +33 1 41 89 80 93

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (French) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.