diff options
author | 2016-09-19 08:25:10 -0400 | |
---|---|---|
committer | 2016-09-19 08:25:10 -0400 | |
commit | 1a017c93023f489772d53221cda2248f930636ce (patch) | |
tree | ea7f48c10c4950abbd8f6aa4a3510daacb878ce0 /src/lib/util/unicode.cpp | |
parent | ea15eb91112bff6dc9976d192bf2527b1fe8c37a (diff) |
Consolidated code that inputs characters into buffers
Diffstat (limited to 'src/lib/util/unicode.cpp')
-rw-r--r-- | src/lib/util/unicode.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/util/unicode.cpp b/src/lib/util/unicode.cpp index 535207e2431..4613fa76350 100644 --- a/src/lib/util/unicode.cpp +++ b/src/lib/util/unicode.cpp @@ -23,6 +23,33 @@ bool uchar_isvalid(unicode_char uchar) //------------------------------------------------- +// uchar_is_printable - tests to see if a unicode +// char is printable +//------------------------------------------------- + +bool uchar_is_printable(unicode_char uchar) +{ + return + !(0x0001f >= uchar) && // C0 control + !((0x0007f <= uchar) && (0x0009f >= uchar)) && // DEL and C1 control + !((0x0fdd0 <= uchar) && (0x0fddf >= uchar)) && // noncharacters + !(0x0fffe == (uchar & 0x0ffff)) && // byte-order detection noncharacter + !(0x0ffff == (uchar & 0x0ffff)); // the other noncharacter +} + + +//------------------------------------------------- +// uchar_is_digit - tests to see if a unicode +// char is a digit +//------------------------------------------------- + +bool uchar_is_digit(unicode_char uchar) +{ + return uchar >= '0' && uchar <= '9'; +} + + +//------------------------------------------------- // uchar_from_utf8 - convert a UTF-8 sequence // into a unicode character //----------------------------------------------- |