c ^= c;
- if (!OSRF_UTF8_IS_ASCII((char)string[idx])) {
- if (OSRF_UTF8_IS_START((char)string[idx])) {
+ if (!(string[idx] < 0x80)) { // not ASCII
+ if (string[idx]>= 0xc0 && string[idx] <= 0xfd) { // starts a UTF8 string
do {
- c = OSRF_UTF8_ACCUMULATE(c, string[idx]);
- } while (OSRF_UTF8_IS_CONTINUATION(string[idx + 1] && idx++));
+ c = (c << 6) | (string[idx] & 0x3f); // add this byte worth
+ } while ((string[idx + 1] >= 0x80 && string[idx + 1] <= 0xbf) && idx++); // and continue if there's more
buffer_fadd(buf, "\\u%0.4x", c);
} else return NULL;
} else {
#include "md5.h"
-#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) | (((char)_n) & OSRF_UTF8_CONTINUATION_MASK))
-
#define OSRF_MALLOC(ptr, size) \
ptr = (void*) malloc( size ); \
if( ptr == NULL ) { \