What encoding does std::string.c_str() use?

后端 未结 2 1307
春和景丽
春和景丽 2020-11-30 06:49

I am trying to convert a C++ std::string to UTF-8 or std::wstring without losing information (consider a string that contains non-ASCII characters)

2条回答
  •  既然无缘
    2020-11-30 06:56

    std::string per se uses no encoding -- it will return the bytes you put in it. For example, those bytes might be using ISO-8859-1 encoding... or any other, really: the information about the encoding is just not there -- you have to know where the bytes were coming from!

提交回复
热议问题