How to convert wstring into string?

前端 未结 17 2169
北海茫月
北海茫月 2020-11-22 13:10

The question is how to convert wstring to string?

I have next example :

#include 
#include 

int main()
{
    std::wstr         


        
17条回答
  •  萌比男神i
    2020-11-22 13:22

    I believe the official way is still to go thorugh codecvt facets (you need some sort of locale-aware translation), as in

    resultCode = use_facet >(locale).
      in(stateVar, scratchbuffer, scratchbufferEnd, from, to, toLimit, curPtr);
    

    or something like that, I don't have working code lying around. But I'm not sure how many people these days use that machinery and how many simply ask for pointers to memory and let ICU or some other library handle the gory details.

提交回复
热议问题