diff options
author | hop311 <hop3114@gmail.com> | 2024-08-01 00:17:32 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-08-02 22:54:08 +0200 |
commit | 06b76612b28183f0a047dac3a4127120d2af1b39 (patch) | |
tree | 9e7af8634eafc8461bd02697dd48ae36ca924858 /extension/src/openvic-extension/utility/Utilities.hpp | |
parent | 8431914a6971cbacfb20bba13a4113d9ac4d5153 (diff) |
Use UTF8 encoding and simplify godot string conversionutf8-fix
Fixes #180: Province names do not convert non-ascii characters to Unicode
Diffstat (limited to 'extension/src/openvic-extension/utility/Utilities.hpp')
-rw-r--r-- | extension/src/openvic-extension/utility/Utilities.hpp | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/extension/src/openvic-extension/utility/Utilities.hpp b/extension/src/openvic-extension/utility/Utilities.hpp index 0cd9edc..49314ca 100644 --- a/extension/src/openvic-extension/utility/Utilities.hpp +++ b/extension/src/openvic-extension/utility/Utilities.hpp @@ -14,23 +14,11 @@ namespace OpenVic::Utilities { _FORCE_INLINE_ std::string godot_to_std_string(godot::String const& str) { - return str.ascii().get_data(); + return str.utf8().get_data(); } - _FORCE_INLINE_ godot::String std_to_godot_string(std::string const& str) { - return str.c_str(); - } - - _FORCE_INLINE_ godot::String std_view_to_godot_string(std::string_view const& str) { - return std_to_godot_string(static_cast<std::string>(str)); - } - - _FORCE_INLINE_ godot::StringName std_to_godot_string_name(std::string const& str) { - return str.c_str(); - } - - _FORCE_INLINE_ godot::StringName std_view_to_godot_string_name(std::string_view const& str) { - return std_to_godot_string_name(static_cast<std::string>(str)); + _FORCE_INLINE_ godot::String std_to_godot_string(std::string_view const& str) { + return godot::String::utf8(str.data(), str.length()); } godot::String int_to_string_suffixed(int64_t val); |