Create UTF-16 string from char*

后端 未结 3 1201
面向向阳花
面向向阳花 2021-01-25 02:31

So I have standard C string:

char* name = \"Jakub\";

And I want to convert it to UTF-16. I figured out, that UTF-16 will be twice as lo

3条回答
  •  旧时难觅i
    2021-01-25 02:59

    output[i] = input[i];
    

    This will assign every other byte of the input, because you increment i by 2. So no wonder that you obtain "Jkb". You probably wanted to write:

    output[i] = input[i / 2];
    

提交回复
热议问题