Skip to content

Commit

Permalink
unichar: Use surrogate macros in ucs4 validity check
Browse files Browse the repository at this point in the history
  • Loading branch information
cmouse committed Oct 23, 2017
1 parent 2bb5b67 commit c47167d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/unichar.h
Expand Up @@ -49,8 +49,9 @@ extern const uint8_t *const uni_utf8_non1_bytes;

static inline bool ATTR_PURE uni_is_valid_ucs4(unichar_t chr)
{
return (chr & 0xfff800) != UTF16_SURROGATE_HIGH_FIRST &&
chr <= UNICHAR_T_MAX;
return (!UTF16_VALID_HIGH_SURROGATE(chr) &&
!UTF16_VALID_LOW_SURROGATE(chr) &&
chr <= UNICHAR_T_MAX);
};

/* Returns number of characters in a NUL-terminated unicode string */
Expand Down

0 comments on commit c47167d

Please sign in to comment.