char* uescape( const char* string, int size, int full_escape ) {
growing_buffer* buf = buffer_init(size + 64);
- int clen = 1;
+ int clen = 0;
int idx = 0;
unsigned long int c = 0x0;
clen = 1;
if (((unsigned char)string[idx] & 0xF0) == 0xF0) {
- clen = 4;
+ clen = 3;
c = (unsigned char)string[idx] ^ 0xF0;
} else if (((unsigned char)string[idx] & 0xE0) == 0xE0) {
- clen = 3;
+ clen = 2;
c = (unsigned char)string[idx] ^ 0xE0;
} else if (((unsigned char)string[idx] & 0xC0) == 0xC0) {
- clen = 2;
+ clen = 1;
c = (unsigned char)string[idx] ^ 0xC0;
}
- for (;clen;--clen) {
+ for (;clen;clen--) {
idx++; // look at the next byte
c = (c << 6) | ((unsigned char)string[idx] & 0x3F); // add this byte worth