summaryrefslogtreecommitdiff
path: root/fribidi_char_sets_utf8.c
diff options
context:
space:
mode:
Diffstat (limited to 'fribidi_char_sets_utf8.c')
-rw-r--r--fribidi_char_sets_utf8.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/fribidi_char_sets_utf8.c b/fribidi_char_sets_utf8.c
index 8537fd5..aba3ee9 100644
--- a/fribidi_char_sets_utf8.c
+++ b/fribidi_char_sets_utf8.c
@@ -80,16 +80,22 @@ fribidi_unicode_to_utf8 (FriBidiChar *us, int length, char *s)
}
else if (mychar <= 0x7FF) /* 11 sig bits */
{
- *t++ = 0xC0 | (uint8) ((mychar >> 6) & 0x1F); /* upper 5 bits */
- *t++ = 0x80 | (uint8) (mychar & 0x3F); /* lower 6 bits */
+ *t++ = 0xC0 | (unsigned char) ((mychar >> 6) & 0x1F); /* upper 5 bits */
+ *t++ = 0x80 | (unsigned char) (mychar & 0x3F); /* lower 6 bits */
}
else if (mychar <= 0xFFFF)
{ /* 16 sig bits */
- *t++ = 0xE0 | (uint8) ((mychar >> 12) & 0x0F); /* upper 4 bits */
- *t++ = 0x80 | (uint8) ((mychar >> 6) & 0x3F); /* next 6 bits */
- *t++ = 0x80 | (uint8) (mychar & 0x3F); /* lowest 6 bits */
+ *t++ = 0xE0 | (unsigned char) ((mychar >> 12) & 0x0F); /* upper 4 bits */
+ *t++ = 0x80 | (unsigned char) ((mychar >> 6) & 0x3F); /* next 6 bits */
+ *t++ = 0x80 | (unsigned char) (mychar & 0x3F); /* lowest 6 bits */
+ }
+ else if (mychar < FRIBIDI_UNICODE_CHARS)
+ { /* 21 sig bits */
+ *t++ = 0xF0 | (unsigned char) ((mychar >> 18) & 0x07); /* upper 3 bits */
+ *t++ = 0x80 | (unsigned char) ((mychar >> 12) & 0x3F); /* next 6 bits */
+ *t++ = 0x80 | (unsigned char) ((mychar >> 6) & 0x3F); /* next 6 bits */
+ *t++ = 0x80 | (unsigned char) (mychar & 0x3F); /* lowest 6 bits */
}
- /* TODO */
}
*t = 0;