Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

runtime_error in older boost when locales are not set

$
0
0

in ofAppRunner line 111 there's:

#ifdef TARGET_LINUX
    if(std::locale().name() == "C"){
        try{
            std::locale::global(std::locale("C.UTF-8"));
        }catch(...){
            if(ofToLower(std::locale("").name()).find("utf-8")==std::string::npos){
                ofLogWarning("ofInit") << "Couldn't set UTF-8 locale, string manipulation functions\n"
                        "won't work correctly for non ansi characters unless you specify a UTF-8 locale\n"
                        "manually using std::locale::global(std::locale(\"locale\"))\n"
                        "available locales can be queried with 'locale -a' in a terminal.";
            }
        }
    }
#endif

we can add a small fix for that by checking if the locale is empty and try to set it too like:

#ifdef TARGET_LINUX
    if(std::locale().name() == "C" || std::locale().name().empty()){
        try{
            std::locale::global(std::locale("C.UTF-8"));
        }catch(...){
            if(ofToLower(std::locale("").name()).find("utf-8")==std::string::npos){
                ofLogWarning("ofInit") << "Couldn't set UTF-8 locale, string manipulation functions\n"
                        "won't work correctly for non ansi characters unless you specify a UTF-8 locale\n"
                        "manually using std::locale::global(std::locale(\"locale\"))\n"
                        "available locales can be queried with 'locale -a' in a terminal.";
            }
        }
    }
#endif

i don't have an rpi with me right now but if you can give it a try and send a PR?


Viewing all articles
Browse latest Browse all 40524