summaryrefslogtreecommitdiffstats
path: root/jv_unicode.c
diff options
context:
space:
mode:
authorWilliam Langford <wlangfor@gmail.com>2014-06-18 19:49:38 -0400
committerNicolas Williams <nico@cryptonector.com>2014-06-18 21:02:47 -0500
commit8ff935c01a6e9a16e0d84b29c548dc621bc8ff98 (patch)
treed6fa5ce55d7fdee31080f92148c9b9f0613f3f84 /jv_unicode.c
parent5d9d1b1020b5d7f5fe11d81eb641197bb98819d9 (diff)
Added regex support as per issue #164.
jq now depends on oniguruma for regex support. Modified configure.ac accordingly. Added valgrind suppression file for oniguruma to prevent one-time and bounded leaks from causing tests to fail. Signed-off-by: Nicolas Williams <nico@cryptonector.com>
Diffstat (limited to 'jv_unicode.c')
-rw-r--r--jv_unicode.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/jv_unicode.c b/jv_unicode.c
index 907e9855..c3f9f111 100644
--- a/jv_unicode.c
+++ b/jv_unicode.c
@@ -59,6 +59,13 @@ int jvp_utf8_is_valid(const char* in, const char* end) {
return 1;
}
+int jvp_utf8_decode_length(char startchar) {
+ if ((startchar & 0x80) == 0) return 1;
+ else if ((startchar & 0xC0) == 0xC0) return 2;
+ else if ((startchar & 0xE0) == 0xE0) return 3;
+ else return 4;
+}
+
int jvp_utf8_encode_length(int codepoint) {
if (codepoint <= 0x7F) return 1;
else if (codepoint <= 0x7FF) return 2;