summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-07-15 04:09:18 +1000
committer Vas Crabb <cuavas@users.noreply.github.com>2021-07-15 13:54:40 +1000
commit37157461313b13a691722b83c87df8d2315457da (patch)
tree8034c6f33776f5a8bfc8f6c69af879975061bd0a /src/lib
parent66554d3b84f5fec60dcf5d896283a1a04487c0e0 (diff)
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.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/util/unicode.cpp32
-rw-r--r--src/lib/util/unicode.h3
2 files changed, 13 insertions, 22 deletions
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;
}
@@ -485,17 +488,6 @@ std::string utf8_from_wstring(const std::wstring &string)
// 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
-//-------------------------------------------------
-
std::string normalize_unicode(const char *s, unicode_normalization_form normalization_form, bool fold_case)
{
return internal_normalize_unicode(s, 0, normalization_form, fold_case, true);
diff --git a/src/lib/util/unicode.h b/src/lib/util/unicode.h
index e2788b5e2ab..d6f577289c4 100644
--- a/src/lib/util/unicode.h
+++ b/src/lib/util/unicode.h
@@ -59,7 +59,7 @@ int uchar_from_utf8(char32_t *uchar, const char *utf8char, size_t count);
int uchar_from_utf8(char32_t *uchar, std::string_view utf8str);
int uchar_from_utf16(char32_t *uchar, const char16_t *utf16char, size_t count);
int uchar_from_utf16f(char32_t *uchar, const char16_t *utf16char, size_t count);
-std::u32string ustr_from_utf8(const std::string &utf8str);
+std::u32string ustr_from_utf8(std::string_view utf8str);
// converting 32-bit Unicode chars to strings
int utf8_from_uchar(char *utf8string, size_t count, char32_t uchar);
@@ -72,7 +72,6 @@ std::wstring wstring_from_utf8(const std::string &utf8string);
std::string utf8_from_wstring(const std::wstring &string);
// unicode normalization
-std::string normalize_unicode(const std::string &s, unicode_normalization_form normalization_form, bool fold_case = false);
std::string normalize_unicode(const char *s, unicode_normalization_form normalization_form, bool fold_case = false);
std::string normalize_unicode(std::string_view s, unicode_normalization_form normalization_form, bool fold_case = false);