mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 01:07:43 +00:00
Add CVarCommons; hecl-light library
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
namespace hecl
|
||||
{
|
||||
static logvisor::Module Log("hecl-wsconv");
|
||||
|
||||
std::string WideToUTF8(std::wstring_view src)
|
||||
{
|
||||
@@ -14,7 +15,7 @@ std::string WideToUTF8(std::wstring_view src)
|
||||
utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb);
|
||||
if (c < 0)
|
||||
{
|
||||
LogModule.report(logvisor::Warning, "invalid UTF-8 character while encoding");
|
||||
Log.report(logvisor::Warning, "invalid UTF-8 character while encoding");
|
||||
return retval;
|
||||
}
|
||||
retval.append(reinterpret_cast<char*>(mb), c);
|
||||
@@ -32,7 +33,7 @@ std::string Char16ToUTF8(std::u16string_view src)
|
||||
utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb);
|
||||
if (c < 0)
|
||||
{
|
||||
LogModule.report(logvisor::Warning, "invalid UTF-8 character while encoding");
|
||||
Log.report(logvisor::Warning, "invalid UTF-8 character while encoding");
|
||||
return retval;
|
||||
}
|
||||
retval.append(reinterpret_cast<char*>(mb), c);
|
||||
@@ -51,7 +52,7 @@ std::wstring UTF8ToWide(std::string_view src)
|
||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||
if (len < 0)
|
||||
{
|
||||
LogModule.report(logvisor::Warning, "invalid UTF-8 character while decoding");
|
||||
Log.report(logvisor::Warning, "invalid UTF-8 character while decoding");
|
||||
return retval;
|
||||
}
|
||||
buf += len;
|
||||
@@ -71,7 +72,7 @@ std::u16string UTF8ToChar16(std::string_view src)
|
||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||
if (len < 0)
|
||||
{
|
||||
LogModule.report(logvisor::Warning, "invalid UTF-8 character while decoding");
|
||||
Log.report(logvisor::Warning, "invalid UTF-8 character while decoding");
|
||||
return retval;
|
||||
}
|
||||
buf += len;
|
||||
|
||||
Reference in New Issue
Block a user