📄 string_conv.cpp
字号:
// Copyright E骾n O'Callaghan 2006 - 2007.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//#include "stdAfx.hpp"
#include <fstream>
#include <boost/smart_ptr.hpp>
#include "string_conv.hpp"
#include "unicode.hpp"
#include "logger.hpp"
namespace aux
{
std::wstring mbstowcs(const std::string& ustr)
{
std::wstring wstr;
unicode::transcode<unicode::utf8, unicode::wchar_encoding>(
ustr.begin(),
ustr.end(),
std::insert_iterator<std::wstring>(wstr, wstr.end())
);
return wstr;
}
std::string wcstombs(const std::wstring& wstr)
{
std::string ustr;
try
{
unicode::transcode<unicode::wchar_encoding, unicode::utf8>(
wstr.begin(),
wstr.end(),
std::insert_iterator<std::string>(ustr, ustr.end())
);
return ustr;
}
catch (const unicode::unicode_error& e)
{
log_file(L"mbstowcs unicode_error- ");
log_file(e.what());
log_file(L" : ");
log_file(wstr);
log_file(L"\r\n");
}
catch (const std::exception& e)
{
log_file(L"mbstowcs std::exception- ");
log_file(e.what());
log_file(L" : ");
log_file(wstr);
log_file(L"\r\n");
}
return "";
}
} // namespace aux
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -