tags:

views:

166

answers:

1

Since Windows doesnt have a C++ locale with UTF8 support by default, i would like to construct a custom locale object which supports UTF8 (by creating it with a custom ctype facet).

How can i construct a locale object with a my own ctype implementation (i only found functions to construct a locale using an already existing locale as base..)

If C++ does not support construction of locales with a custom ctype facet at all, why is that so ?

+1  A: 

It's possible to create custom facets by inheriting from std::locale::facet. Locales can use those custom facets as in following code:

class custom_facet : public std::locale::facet {
public:
    static std::locale::id id;
    custom_facet(int);  
    int custom_value() const; 
    };

std::locale  custom_locale ( std::locale(), new custom_facet() );
int s = std::use_facet<custom_facet>(custom_locale).custom_value();
buratinas
accepted as answer, even though this answered my question only partially, but annos links helped me aswell, so this question is solved for me.
smerlin