Search code examples
cunicodeicustrdup

Is there a strdup equivalent in icu unicode?


The question is self-explanatory. I'm using the C API.


Solution

  • No, but it's easy to implement. It's just:

    UChar *u_strdup(UChar *in) {
        uint32_t len = u_strlen(in) + 1;
        UChar *result = malloc(sizeof(UChar) * len);
        u_memcpy(result, in, len);
        return result;
    }