Ejemplo n.º 1
0
		/**@brief 初始化local设置*/
		char const* localinit() {
			static std::locale loc = std::locale("");
			std::cout.imbue(loc);
			std::wcout.imbue(loc);
			std::cin.imbue(loc);
			std::wcin.imbue(loc);
			std::cerr.imbue(loc);
			return loc.name().c_str();
		}
Ejemplo n.º 2
0
string __lang_from_locale(const std::locale& loc)
{
    std::string lname = loc.name();
    
    // handle custom locales, i.e. "LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C"
    auto __p = lname.find("LC_CTYPE=");
    if ( __p != std::string::npos )
    {
        auto __e = lname.find(";", __p);
        if ( __e == std::string::npos )
            __e = lname.size();
        lname = lname.substr(__p, __e);
    }
    
    // now we have something like "en_US.UTF-8" or "en_US". Strip the ".UTF-8" part, if any
    __p = lname.find(".");
    if ( __p != std::string::npos )
        lname = lname.substr(0, __p);
    
    return string(lname);
}
Ejemplo n.º 3
0
 MeinWaehrungsformat(const std::locale& loc, const char* ws) 
    : MeinMoneypunct(loc.name().c_str()), wsymbol(ws) {
 }