From 94335d10e1134e444e3049eda0f68dcc692f5beb Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 22 Nov 2006 20:23:59 +0000 Subject: [PATCH] new unicode stuff compiles now git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@799 9efc2488-bf62-4759-914b-345cdb29e865 --- src/utils/utils.c | 8 ++++---- src/utils/utils.h | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/utils/utils.c b/src/utils/utils.c index e4963ba..69d6093 100644 --- a/src/utils/utils.c +++ b/src/utils/utils.c @@ -261,11 +261,11 @@ char* uescape( const char* string, int size, int full_escape ) { c ^= c; - if (!OSRF_UTF8_IS_ASCII(string[idx])) { - if (OSRF_UTF8_IS_START) { + if (!OSRF_UTF8_IS_ASCII((char)string[idx])) { + if (OSRF_UTF8_IS_START((char)string[idx])) { do { - OSRF_UTF8_ACCUMULATE(c, string[idx]); - } while (OSRF_UTF8_IS_CONTINUATION(string[idx++])); + c = OSRF_UTF8_ACCUMULATE(c, string[idx]); + } while (OSRF_UTF8_IS_CONTINUATION(string[idx + 1] && idx++)); buffer_fadd(buf, "\\u%0.4x", c); } else return NULL; } else { diff --git a/src/utils/utils.h b/src/utils/utils.h index 97224ba..8003bea 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -31,14 +31,14 @@ GNU General Public License for more details. #include "md5.h" -#define OSRF_UTF8_IS_ASCII(_c) ((_c) < 0x80) -#define OSRF_UTF8_IS_START(_c) ((_c) >= 0xc0 && ((_c) <= 0xfd)) -#define OSRF_UTF8_IS_CONTINUATION(_c) ((_c) >= 0x80 && ((_c) <= 0xbf)) -#define OSRF_UTF8_IS_CONTINUED(_c) ((_c) & 0x80) +#define OSRF_UTF8_IS_ASCII(_c) (((char)_c) < 0x80) +#define OSRF_UTF8_IS_START(_c) (((char)_c) >= 0xc0 && (((char)_c) <= 0xfd)) +#define OSRF_UTF8_IS_CONTINUATION(_c) (((char)_c) >= 0x80 && (((char)_c) <= 0xbf)) +#define OSRF_UTF8_IS_CONTINUED(_c) (((char)_c) & 0x80) #define OSRF_UTF8_CONTINUATION_MASK (0x3f) #define OSRF_UTF8_ACCUMULATION_SHIFT 6 -#define OSRF_UTF8_ACCUMULATE(_o, _n) (((_o) << OSRF_UTF8_ACCUMULATION_SHIFT) | ((_n) & OSRF_UTF8_CONTINUATION_MASK)) +#define OSRF_UTF8_ACCUMULATE(_o, _n) (((_o) << OSRF_UTF8_ACCUMULATION_SHIFT) | (((char)_n) & OSRF_UTF8_CONTINUATION_MASK)) #define OSRF_MALLOC(ptr, size) \ ptr = (void*) malloc( size ); \ -- 2.11.0