我试图让UTF-8字符与ANSI 8位字符共存.我的策略是表示utf-8字符,unsigned char以便可以对两种字符类型使用适当的函数重载.
例如
namespace MyStuff
{
typedef uchar utf8_t;
typedef std::basic_string<utf8_t> U8string;
}
void SomeFunc(std::string &s);
void SomeFunc(std::wstring &s);
void SomeFunc(MyStuff::U8string &s);
Run Code Online (Sandbox Code Playgroud)
这一切都很好,直到我尝试使用stringstream.
std::basic_ostringstream<MyStuff::utf8_t> ostr;
ostr << 1;
Run Code Online (Sandbox Code Playgroud)
MSVC Visual C++ Express V10无法编译:
c:\program files\microsoft visual studio 10.0\vc\include\xlocmon(213):
warning C4273: 'id' : inconsistent dll linkage
c:\program files\microsoft visual studio 10.0\vc\include\xlocnum(65) :
see previous definition of
'public: static std::locale::id std::numpunct<unsigned char>::id'
c:\program files\microsoft visual studio 10.0\vc\include\xlocnum(65) :
while compiling class template static data member 'std::locale::id
std::numpunct<_Elem>::id'
with
[ …Run Code Online (Sandbox Code Playgroud)