diff options
author | 2016-10-22 11:31:49 +0200 | |
---|---|---|
committer | 2016-10-22 11:31:49 +0200 | |
commit | 23ad94073f4c2f7131fa0c95b6202f2f9027db41 (patch) | |
tree | 4f4e1e27a22ace8fea49b63030d4462db7cb68a1 /src/lib/util/unicode.cpp | |
parent | 255bf78b316a9dc9e4c53a65143000471a6927d3 (diff) |
use standard types uintptr_t, char16_t and char32_t instead of FPTR, utf16_char, unicode_char (nw)
Diffstat (limited to 'src/lib/util/unicode.cpp')
-rw-r--r-- | src/lib/util/unicode.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/lib/util/unicode.cpp b/src/lib/util/unicode.cpp index 65936e10b48..a6c5515fbf6 100644 --- a/src/lib/util/unicode.cpp +++ b/src/lib/util/unicode.cpp @@ -16,7 +16,7 @@ // character is a legitimate unicode character //------------------------------------------------- -bool uchar_isvalid(unicode_char uchar) +bool uchar_isvalid(char32_t uchar) { return (uchar < 0x110000) && !((uchar >= 0xd800) && (uchar <= 0xdfff)); } @@ -27,7 +27,7 @@ bool uchar_isvalid(unicode_char uchar) // char is printable //------------------------------------------------- -bool uchar_is_printable(unicode_char uchar) +bool uchar_is_printable(char32_t uchar) { return !(0x0001f >= uchar) && // C0 control @@ -43,7 +43,7 @@ bool uchar_is_printable(unicode_char uchar) // char is a digit //------------------------------------------------- -bool uchar_is_digit(unicode_char uchar) +bool uchar_is_digit(char32_t uchar) { return uchar >= '0' && uchar <= '9'; } @@ -54,9 +54,9 @@ bool uchar_is_digit(unicode_char uchar) // into a unicode character //----------------------------------------------- -int uchar_from_utf8(unicode_char *uchar, const char *utf8char, size_t count) +int uchar_from_utf8(char32_t *uchar, const char *utf8char, size_t count) { - unicode_char c, minchar; + char32_t c, minchar; int auxlen, i; char auxchar; @@ -149,7 +149,7 @@ int uchar_from_utf8(unicode_char *uchar, const char *utf8char, size_t count) // into a unicode character //------------------------------------------------- -int uchar_from_utf16(unicode_char *uchar, const utf16_char *utf16char, size_t count) +int uchar_from_utf16(char32_t *uchar, const char16_t *utf16char, size_t count) { int rc = -1; @@ -184,9 +184,9 @@ int uchar_from_utf16(unicode_char *uchar, const utf16_char *utf16char, size_t co // byte order //------------------------------------------------- -int uchar_from_utf16f(unicode_char *uchar, const utf16_char *utf16char, size_t count) +int uchar_from_utf16f(char32_t *uchar, const char16_t *utf16char, size_t count) { - utf16_char buf[2] = {0}; + char16_t buf[2] = {0}; if (count > 0) buf[0] = flipendian_int16(utf16char[0]); if (count > 1) @@ -200,7 +200,7 @@ int uchar_from_utf16f(unicode_char *uchar, const utf16_char *utf16char, size_t c // into a UTF-8 sequence //------------------------------------------------- -int utf8_from_uchar(char *utf8string, size_t count, unicode_char uchar) +int utf8_from_uchar(char *utf8string, size_t count, char32_t uchar) { int rc = 0; @@ -278,7 +278,7 @@ int utf8_from_uchar(char *utf8string, size_t count, unicode_char uchar) // into a UTF-8 sequence //------------------------------------------------- -std::string utf8_from_uchar(unicode_char uchar) +std::string utf8_from_uchar(char32_t uchar) { char buffer[UTF8_CHAR_MAX]; auto len = utf8_from_uchar(buffer, ARRAY_LENGTH(buffer), uchar); @@ -291,7 +291,7 @@ std::string utf8_from_uchar(unicode_char uchar) // into a UTF-16 sequence //------------------------------------------------- -int utf16_from_uchar(utf16_char *utf16string, size_t count, unicode_char uchar) +int utf16_from_uchar(char16_t *utf16string, size_t count, char32_t uchar) { int rc; @@ -304,7 +304,7 @@ int utf16_from_uchar(utf16_char *utf16string, size_t count, unicode_char uchar) // single word case if (count < 1) return -1; - utf16string[0] = (utf16_char) uchar; + utf16string[0] = (char16_t) uchar; rc = 1; } else if (uchar < 0x100000) @@ -330,10 +330,10 @@ int utf16_from_uchar(utf16_char *utf16string, size_t count, unicode_char uchar) // into a UTF-16 sequence with flipped endianness //------------------------------------------------- -int utf16f_from_uchar(utf16_char *utf16string, size_t count, unicode_char uchar) +int utf16f_from_uchar(char16_t *utf16string, size_t count, char32_t uchar) { int rc; - utf16_char buf[2] = { 0, 0 }; + char16_t buf[2] = { 0, 0 }; rc = utf16_from_uchar(buf, count, uchar); @@ -390,7 +390,7 @@ bool utf8_is_valid_string(const char *utf8string) while (*utf8string != 0) { - unicode_char uchar = 0; + char32_t uchar = 0; int charlen; // extract the current character and verify it |