【问题标题】:STL/Boost Replacement for WideCharToMultiByte-functionWideCharToMultiByte 函数的 STL/Boost 替换
【发布时间】:2020-09-28 10:51:25
【问题描述】:

在以下代码 (sn-p) 中,WideCharToMultiByte 是 Windows 特定的函数。

是否有使用 STLBoost 的函数的合适替代品?

//in function parameters: (..., WCHAR* szNameOfDll, ...)

char szSourceTemp[MAX_PATH + 1] = {0};

WideCharToMultiByte(CP_ACP,0,szNameOfDLL,-1, szSourceTemp,MAX_PATH,NULL,NULL);

任何帮助表示赞赏!

【问题讨论】:

标签: c++ boost


【解决方案1】:
std::wctomb/std::wcstombs
std::mbtowc/std::mbstowcs

#include <boost/locale.hpp>
#include <iostream>

std::string  utf8_string  = to_utf<char>(latin1_string,"Latin1");
std::wstring wide_string  = to_utf<wchar_t>(latin1_string,"Latin1");
std::string  latin1_string= from_utf(wide_string,"Latin1");
std::string  utf8_string2 = utf_to_utf<char>(wide_string);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-03
    • 1970-01-01
    相关资源
    最近更新 更多