|
|
@ -3,7 +3,7 @@
|
|
|
|
size_t fmt_utf8(char *dest,uint32_t n) {
|
|
|
|
size_t fmt_utf8(char *dest,uint32_t n) {
|
|
|
|
size_t i,j;
|
|
|
|
size_t i,j;
|
|
|
|
if (n<=0x7f) {
|
|
|
|
if (n<=0x7f) {
|
|
|
|
if (dest) *dest=n;
|
|
|
|
if (dest) *dest=(char)n;
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i=0x3f,j=1; i<0x7fffffff; i=(i<<5)|0x1f, ++j) {
|
|
|
|
for (i=0x3f,j=1; i<0x7fffffff; i=(i<<5)|0x1f, ++j) {
|
|
|
@ -11,9 +11,9 @@ size_t fmt_utf8(char *dest,uint32_t n) {
|
|
|
|
--j;
|
|
|
|
--j;
|
|
|
|
if (dest) {
|
|
|
|
if (dest) {
|
|
|
|
size_t k=j*6;
|
|
|
|
size_t k=j*6;
|
|
|
|
*dest++=((char)0xc0 >> (j-1)) | (n >> k);
|
|
|
|
*dest++=(char)(((char)0xc0 >> (j-1)) | (char)(n >> k));
|
|
|
|
while (k) {
|
|
|
|
while (k) {
|
|
|
|
*dest++=0x80 | ((n >> (k-6)) & 0x3f);
|
|
|
|
*dest++=(char)(0x80 | ((n >> (k-6)) & 0x3f));
|
|
|
|
k-=6;
|
|
|
|
k-=6;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|