From 1a017c93023f489772d53221cda2248f930636ce Mon Sep 17 00:00:00 2001 From: Nathan Woods Date: Mon, 19 Sep 2016 08:25:10 -0400 Subject: Consolidated code that inputs characters into buffers --- src/lib/util/unicode.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/lib/util/unicode.cpp') 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 @@ -22,6 +22,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 -- cgit v1.2.3-70-g09d2