diff --git a/include/boost/nowide/filebuf.hpp b/include/boost/nowide/filebuf.hpp index c67e22b..95858eb 100644 --- a/include/boost/nowide/filebuf.hpp +++ b/include/boost/nowide/filebuf.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #else #include @@ -83,6 +84,7 @@ namespace nowide { { if(is_open()) return NULL; + validate_cvt(this->getloc()); bool ate = bool(mode & std::ios_base::ate); if(ate) mode = mode ^ std::ios_base::ate; @@ -138,6 +140,11 @@ namespace nowide { own_ = true; } } + void validate_cvt(const std::locale &loc) + { + if(!std::use_facet >(loc).always_noconv()) + throw std::runtime_error("Converting codecvts are not supported"); + } protected: virtual std::streambuf *setbuf(char *s, std::streamsize n) @@ -243,6 +250,10 @@ namespace nowide { { return seekoff(std::streamoff(off), std::ios_base::beg, m); } + virtual void imbue(const std::locale &loc) + { + validate_cvt(loc); + } private: int fixg()