la conversion étroite chaîne à grande chaîne

Comment puis-je convertir un étroit string à un large string ?

J'ai essayé cette méthode :

string myName;
getline( cin , myName );
wstring printerName( L(myName) );  //error C3861: 'L': identifier not found
wchar_t* WprinterName = printerName.c_str(); //error C2440: 'initializing' : cannot convert from 'const wchar_t *' to 'wchar_t *'

Mais j'ai des erreurs comme indiqué ci-dessus.

Pourquoi j'obtiens ces erreurs ? Comment puis-je corriger ?

Est-il de toute autre méthode de directement convertir un narrow chaîne wide chaîne ?

  • la source est codé en UTF-8, ou ASCII?
InformationsquelleAutor saplingPro | 2011-07-14