cutef8 icon indicating copy to clipboard operation
cutef8 copied to clipboard

u8_unescape() swallows character

Open 7890 opened this issue 5 years ago • 0 comments

Hi, I found this library and I like it since it's very compact.

Something that boggles my mind, with this test program:

#include <stdio.h> //printf
#include <stdlib.h> //malloc
#include <locale.h>
#include "utf8.h"

//gcc -o testutf8 testutf8.c utf8.o

int main(int argc, char *args[])
{
        char *locale;
        locale = setlocale(LC_ALL, "");
        char *str="a£b\\u2620";
        char *un=malloc(100);
        u8_unescape(un, 100, str);
        printf("%s\n", str);
        printf("%s\n", un);
        return 0;
}

I get the following output:

$ ./testutf8 
a£b\u2620
ab☠

Expected output was:

a£b☠

Why is the char '£' removed after u8_unescape(), is there anything wrong with the example code? Thanks for any hints.

7890 avatar Apr 23 '19 14:04 7890