Skip to content

Commit

Permalink
Fix Unicode codepoint conversion from UTF-16
Browse files Browse the repository at this point in the history
This fixes conversion of codepoints like U+28000, U+F1FFF, U+100000, etc.
  • Loading branch information
alvinhochun authored and khaledhosny committed Oct 10, 2023
1 parent 266f63a commit 9d7ca9d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/raqm.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,9 @@ _raqm_get_utf16_codepoint (const void *str,
{
const uint16_t *s = (const uint16_t *)str;

if (s[0] > 0xD800 && s[0] < 0xDBFF)
if (s[0] >= 0xD800 && s[0] <= 0xDBFF)
{
if (s[1] > 0xDC00 && s[1] < 0xDFFF)
if (s[1] >= 0xDC00 && s[1] <= 0xDFFF)
{
uint32_t X = ((s[0] & ((1 << 6) -1)) << 10) | (s[1] & ((1 << 10) -1));
uint32_t W = (s[0] >> 6) & ((1 << 5) - 1);
Expand Down

0 comments on commit 9d7ca9d

Please sign in to comment.