更新时间:2023-11-14 20:18:16
简单的答案称为 WideCharToMultiByte 进行反向转换.还有 CW2A 和 CA2W 使用起来更简单.
The simple answer is called MultiByteToWideChar and WideCharToMultiByte to do the reverse conversion. There's also CW2A and CA2W that are a little simpler to use.
但是,我强烈建议不要直接使用这些功能.您有手动处理字符缓冲区的痛苦,并且有创建内存损坏或安全漏洞的风险.
However, I would strongly recommand against using these functions directly. You have the pain of handling character buffers manually with the risk of creating memory corruption or security holes.
使用基于std :: string和/或迭代器的库要好得多.例如, utf8cpp .这具有体积小,仅标头和多平台的优点.
It's much better to use a library based on std::string and/or iterators. For example, utf8cpp. This one has the advantage to be small, header-only and multiplatform.