FTXUI/src/ftxui/screen/string.cpp

33 lines
890 B
C++
Raw Normal View History

#include "ftxui/screen/string.hpp"
2018-09-18 14:48:40 +08:00
2021-05-23 18:53:20 +08:00
#include <codecvt> // for codecvt_utf8_utf16
#include <locale> // for wstring_convert
2018-09-18 14:48:40 +08:00
2020-08-09 20:53:56 +08:00
namespace ftxui {
2020-03-23 14:12:06 +08:00
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4996) // codecvt_utf8_utf16 is deprecated
2020-03-23 14:12:06 +08:00
#endif
2020-08-16 08:24:50 +08:00
/// Convert a UTF8 std::string into a std::wstring.
2018-09-18 14:48:40 +08:00
std::string to_string(const std::wstring& s) {
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
return converter.to_bytes(s);
}
2020-08-16 08:24:50 +08:00
/// Convert a std::wstring into a UTF8 std::string.
2018-09-18 14:48:40 +08:00
std::wstring to_wstring(const std::string& s) {
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
return converter.from_bytes(s);
}
2020-03-23 14:12:06 +08:00
#ifdef _MSC_VER
#pragma warning(pop)
2020-08-09 20:53:56 +08:00
#endif
} // namespace ftxui
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.