From 34ca477b353a48b315ef8dc598c35f9ddca20370 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Tue, 1 Mar 2016 00:34:49 +0100 Subject: Move UTF-8 string length function to fitz. --- source/fitz/string.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'source/fitz/string.c') diff --git a/source/fitz/string.c b/source/fitz/string.c index d22efe8e..025b612c 100644 --- a/source/fitz/string.c +++ b/source/fitz/string.c @@ -352,6 +352,24 @@ fz_runelen(int c) return fz_runetochar(str, c); } +int +fz_utflen(const char *s) +{ + int c, n, rune; + n = 0; + for(;;) { + c = *(const unsigned char*)s; + if(c < Runeself) { + if(c == 0) + return n; + s++; + } else + s += fz_chartorune(&rune, s); + n++; + } + return 0; +} + float fz_atof(const char *s) { float result; -- cgit v1.2.3