diff options
author | 2020-12-15 13:36:55 -0500 | |
---|---|---|
committer | 2020-12-15 13:36:55 -0500 | |
commit | 2ca5f3a386a1ca63433d6d13bb66f5e46fb2a854 (patch) | |
tree | efc52a61e29ab44d0996e97e01782591e891f646 /src/lib/util/unicode.h | |
parent | 35bec8d2731fb775248ff3634bde538d77d6f2a0 (diff) |
unicode.h: Updates
- Remove from emu.h (except for UTF8_xxx macros, which have been transplanted to emucore.h since a lot of drivers use them) and osdepend.h
- Add std::string_view overrides for uchar_from_utf8 and normalize_unicode
Diffstat (limited to 'src/lib/util/unicode.h')
-rw-r--r-- | src/lib/util/unicode.h | 44 |
1 files changed, 3 insertions, 41 deletions
diff --git a/src/lib/util/unicode.h b/src/lib/util/unicode.h index 9c727041db8..37821122998 100644 --- a/src/lib/util/unicode.h +++ b/src/lib/util/unicode.h @@ -22,6 +22,7 @@ #include "osdcore.h" #include <string> +#include <string_view> #include <cstdlib> @@ -36,46 +37,6 @@ #define UTF8_CHAR_MAX 6 #define UTF16_CHAR_MAX 2 -// these are UTF-8 encoded strings for common characters -#define UTF8_NBSP "\xc2\xa0" /* non-breaking space */ - -#define UTF8_MULTIPLY "\xc3\x97" /* multiplication sign */ -#define UTF8_DIVIDE "\xc3\xb7" /* division sign */ -#define UTF8_SQUAREROOT "\xe2\x88\x9a" /* square root symbol */ -#define UTF8_PLUSMINUS "\xc2\xb1" /* plusminus symbol */ - -#define UTF8_POW_2 "\xc2\xb2" /* superscript 2 */ -#define UTF8_POW_X "\xcb\xa3" /* superscript x */ -#define UTF8_POW_Y "\xca\xb8" /* superscript y */ -#define UTF8_PRIME "\xca\xb9" /* prime symbol */ -#define UTF8_DEGREES "\xc2\xb0" /* degrees symbol */ - -#define UTF8_SMALL_PI "\xcf\x80" /* Greek small letter pi */ -#define UTF8_CAPITAL_SIGMA "\xce\xa3" /* Greek capital letter sigma */ -#define UTF8_CAPITAL_DELTA "\xce\x94" /* Greek capital letter delta */ - -#define UTF8_MACRON "\xc2\xaf" /* macron symbol */ -#define UTF8_NONSPACE_MACRON "\xcc\x84" /* nonspace macron, use after another char */ - -#define a_RING "\xc3\xa5" /* small a with a ring */ -#define a_UMLAUT "\xc3\xa4" /* small a with an umlaut */ -#define o_UMLAUT "\xc3\xb6" /* small o with an umlaut */ -#define u_UMLAUT "\xc3\xbc" /* small u with an umlaut */ -#define e_ACUTE "\xc3\xa9" /* small e with an acute */ -#define n_TILDE "\xc3\xb1" /* small n with a tilde */ - -#define A_RING "\xc3\x85" /* capital A with a ring */ -#define A_UMLAUT "\xc3\x84" /* capital A with an umlaut */ -#define O_UMLAUT "\xc3\x96" /* capital O with an umlaut */ -#define U_UMLAUT "\xc3\x9c" /* capital U with an umlaut */ -#define E_ACUTE "\xc3\x89" /* capital E with an acute */ -#define N_TILDE "\xc3\x91" /* capital N with a tilde */ - -#define UTF8_LEFT "\xe2\x86\x90" /* cursor left */ -#define UTF8_RIGHT "\xe2\x86\x92" /* cursor right */ -#define UTF8_UP "\xe2\x86\x91" /* cursor up */ -#define UTF8_DOWN "\xe2\x86\x93" /* cursor down */ - enum class unicode_normalization_form { C, D, KC, KD }; @@ -95,6 +56,7 @@ bool uchar_is_digit(char32_t uchar); // converting strings to 32-bit Unicode chars 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); @@ -112,7 +74,7 @@ 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(const char *s, size_t length, 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); // upper and lower case char32_t uchar_toupper(char32_t ch); |