mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Fix mbrtowc decoding surrogates.
This commit is contained in:
parent
8fabfc5f7b
commit
ffe59b9c7c
1 changed files with 6 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
/*******************************************************************************
|
||||
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2012, 2014.
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2012, 2014, 2015.
|
||||
|
||||
This file is part of the Sortix C Library.
|
||||
|
||||
|
@ -114,6 +114,11 @@ size_t utf8_mbrtowc(wchar_t* restrict pwc,
|
|||
return errno = EILSEQ, (size_t) -1;
|
||||
#endif
|
||||
|
||||
// The definition of UTF-8 prohibits encoding character numbers between
|
||||
// U+D800 and U+DFFF, which are reserved for use with the UTF-16 encoding
|
||||
// form (as surrogate pairs) and do not directly represent characters.
|
||||
if ( 0xD800 <= ps->wch && ps->wch <= 0xDFFF )
|
||||
return errno = EILSEQ, (size_t) -1;
|
||||
// RFC 3629 limits UTF-8 to 0x0 through 0x10FFFF.
|
||||
if ( 0x10FFFF <= ps->wch )
|
||||
return errno = EILSEQ, (size_t) -1;
|
||||
|
|
Loading…
Reference in a new issue