Nantes Université

Skip to content
Extraits de code Groupes Projets
Non vérifiée Valider f94399f6 rédigé par qykth-git's avatar qykth-git Validation de GitHub
Parcourir les fichiers

Use classic "C" locale if "C.UTF-8" locale is not supported by libc (#63)

parent 55890379
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <ctime> #include <ctime>
#include <cstring> #include <cstring>
#include <locale> #include <locale>
#include <stdexcept>
using namespace std; using namespace std;
#include "cmdline.h" #include "cmdline.h"
...@@ -129,8 +130,18 @@ int main ...@@ -129,8 +130,18 @@ int main
IN char* args[] IN char* args[]
) )
{ {
// Use UTF-8 for multi-byte character I/O everywhare // Use "C.UTF-8" locale for multi-byte character I/O everywhare
std::locale::global(std::locale("C.UTF-8")); // If "C.UTF-8" locale is not supported, use classic "C" locale as fallback.
std::locale loc;
try
{
loc = std::locale("C.UTF-8");
}
catch ( std::runtime_error )
{
loc = std::locale::classic();
}
std::locale::global(loc);
// convert all args to wchar_t's // convert all args to wchar_t's
wchar_t** wargs = new wchar_t*[ argc ]; wchar_t** wargs = new wchar_t*[ argc ];
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter