lang:cpp:string
Ceci est une ancienne révision du document !
wstring
wstring
est surtout utile pour Windows car toutes les appels de fonctions finissant par W
en ont besoin.
#include <fstream> #include <ios> #include <codecvt> std::wofstream out("file.txt", std::ios_base::out | std::ios_base::app); const std::locale utf8_locale = std::locale(std::locale(), new std::codecvt_utf8<wchar_t>()); out.imbue(utf8_locale); // Verify that the file opened correctly std::wstring s(L"contenu"); out << s << std::endl;
Split
std::istringstream f("denmark;sweden;india;us"); std::string s; while (getline(f, s, ';')) { // Résultat dans s. }
Splitting a C++ std::string using tokens, e.g. “;” Archive du 10/02/2019
lang/cpp/string.1549841593.txt.gz · Dernière modification : 2019/02/11 00:33 de root