From 37157461313b13a691722b83c87df8d2315457da Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Thu, 15 Jul 2021 04:09:18 +1000 Subject: API cleanups and miscellaneous fixes. emu/ioport.cpp: Allow controller files to override input sequences for inputs that don't use defaults, and to override the toggle setting for digital inputs. emu/config.cpp: Expose configuration level (mostly matters for controller files), improved verbose diagnostic messages, and moved a few things out of the global and preprocessor namespaces. docs: Added documentation for some controller configuration file features. The device mapping feature documentation will be merged in at some point. util/unicode.cpp, emu/input.cpp: API cleanups. --- src/lib/util/unicode.cpp | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'src/lib/util/unicode.cpp') diff --git a/src/lib/util/unicode.cpp b/src/lib/util/unicode.cpp index c4ee6c56cde..a375224fd1e 100644 --- a/src/lib/util/unicode.cpp +++ b/src/lib/util/unicode.cpp @@ -281,18 +281,21 @@ int uchar_from_utf16f(char32_t *uchar, const char16_t *utf16char, size_t count) // into a Unicode string //------------------------------------------------- -std::u32string ustr_from_utf8(const std::string &utf8str) +std::u32string ustr_from_utf8(std::string_view utf8str) { std::u32string result; - char const *utf8char(utf8str.c_str()); - size_t remaining(utf8str.length()); - while (remaining) + if (!utf8str.empty()) { - char32_t ch; - int const consumed(uchar_from_utf8(&ch, utf8char, remaining)); - result.append(1, (consumed > 0) ? ch : char32_t(0x00fffdU)); - utf8char += (consumed > 0) ? consumed : 1; - remaining -= (consumed > 0) ? consumed : 1; + char const *utf8char(&utf8str[0]); + auto remaining(utf8str.length()); + while (remaining) + { + char32_t ch; + int const consumed(uchar_from_utf8(&ch, utf8char, remaining)); + result.append(1, (consumed > 0) ? ch : char32_t(0x00fffdU)); + utf8char += (consumed > 0) ? consumed : 1; + remaining -= (consumed > 0) ? consumed : 1; + } } return result; } @@ -480,17 +483,6 @@ std::string utf8_from_wstring(const std::wstring &string) } -//------------------------------------------------- -// normalize_unicode - uses utf8proc to normalize -// unicode -//------------------------------------------------- - -std::string normalize_unicode(const std::string &s, unicode_normalization_form normalization_form, bool fold_case) -{ - return internal_normalize_unicode(s.c_str(), s.length(), normalization_form, fold_case, false); -} - - //------------------------------------------------- // normalize_unicode - uses utf8proc to normalize // unicode -- cgit v1.2.3-70-g09d2