diff --git a/meson.build b/meson.build index b0cc9cc..59e925e 100644 --- a/meson.build +++ b/meson.build @@ -11,7 +11,8 @@ project('lel-guecs', 'cpp', # use this for common options only for our executables cpp_args=[ - '-Wno-deprecated-declarations' + '-Wno-deprecated-declarations', + '-I../subprojects/utf8cpp-4.0.9/source', ] link_args=[] # these are passed as override_defaults @@ -50,6 +51,7 @@ catch2 = subproject('catch2').get_variable('catch2_with_main_dep') fmt = subproject('fmt').get_variable('fmt_dep') json = subproject('nlohmann_json').get_variable('nlohmann_json_dep') freetype2 = subproject('freetype2').get_variable('freetype_dep') +utf8cpp = subproject('utf8cpp').get_variable('utf8cpp_dep') flac = subproject('flac').get_variable('flac_dep') ogg = subproject('ogg').get_variable('libogg_dep') @@ -64,7 +66,7 @@ sfml_window = subproject('sfml').get_variable('sfml_window_dep') lib_depends = [ fmt, sfml_graphics, sfml_system, sfml_window ] lib_sfml_depends = [ - fmt, json, freetype2, flac, ogg, + fmt, json, freetype2, flac, ogg, utf8cpp, vorbis, vorbisfile, vorbisenc, sfml_audio, ] diff --git a/src/guecs/ui.cpp b/src/guecs/ui.cpp index 74ad78d..7fe3f58 100644 --- a/src/guecs/ui.cpp +++ b/src/guecs/ui.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace guecs { using std::make_shared; @@ -237,7 +238,14 @@ namespace guecs { } wstring to_wstring(const string& str) { - std::wstring_convert> $converter; - return $converter.from_bytes(str); + std::wstring result = L""; + + try { + utf8::utf8to32(str.begin(), str.end(), std::back_inserter(result)); + } catch(const utf8::exception& e) { + std::cerr << e.what() << std::endl; + } + + return result; } } diff --git a/wraps/utf8cpp.wrap b/wraps/utf8cpp.wrap new file mode 100644 index 0000000..c1ae900 --- /dev/null +++ b/wraps/utf8cpp.wrap @@ -0,0 +1,9 @@ +[wrap-git] +directory=utf8cpp-4.0.9 +url=https://github.com/nemtrif/utfcpp.git +revision=v4.0.9 +depth=1 +method=cmake + +[provide] +utf8cpp = utf8cpp_dep