Skip to content

Commit

Permalink
Restore historical definition of isValidDchar() until the matter of n…
Browse files Browse the repository at this point in the history
…on-character code points can be resolved
  • Loading branch information
dheld committed Jun 10, 2012
1 parent 1285c26 commit a6bd0ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/test/UTFTest.cpp
Expand Up @@ -74,12 +74,14 @@ class UTFValidationTest : public CppUnit::TestFixture

void testIsValidNonCharacter1()
{
CPPUNIT_ASSERT(!utf_isValidDchar(0x03FFFE));
// TODO: Review this!
CPPUNIT_ASSERT(utf_isValidDchar(0x03FFFE));
}

void testIsValidNonCharacter2()
{
CPPUNIT_ASSERT(!utf_isValidDchar(0x00FDD9));
// TODO: Review this!
CPPUNIT_ASSERT(utf_isValidDchar(0x00FDD9));
}

void testIsValidPrivateUse1()
Expand Down
8 changes: 5 additions & 3 deletions src/utf.c
Expand Up @@ -79,10 +79,12 @@ using namespace Unicode;
/// and non-characters (which end in 0xFFFE or 0xFFFF).
bool utf_isValidDchar(dchar_t c)
{
return c <= 0x10FFFD // largest character code point
// TODO: Whether non-char code points should be rejected is pending review
return c <= 0x10FFFF // largest character code point
&& !(0xD800 <= c && c <= 0xDFFF) // surrogate pairs
&& (c & 0xFFFE) != 0xFFFE // non-characters
&& !(0x00FDD0 <= c && c <= 0x00FDEF) // non-characters
&& (c & 0xFFFFFE) != 0x00FFFE // non-characters
// && (c & 0xFFFE) != 0xFFFE // non-characters
// && !(0x00FDD0 <= c && c <= 0x00FDEF) // non-characters
;
}

Expand Down

0 comments on commit a6bd0ca

Please sign in to comment.