Definition at line 45 of file CleanUpTest.php.
◆ doTestBytes()
CleanUpTest::doTestBytes |
( |
|
$head, |
|
|
|
$tail |
|
) |
| |
- Todo:
- document
Definition at line 127 of file CleanUpTest.php.
References $x, UtfNormal\cleanUp(), and UTF8_REPLACEMENT.
Referenced by testAllBytes().
128 for( $i = 0x0; $i < 256; $i++ ) {
129 $char = $head . chr( $i ) . $tail;
131 $x = sprintf(
"%02X", $i );
135 ($i > 0x001f && $i < 0x80) ) {
139 "ASCII byte $x should be intact" );
140 if( $char != $clean )
return;
146 "Forbidden byte $x should be rejected" );
147 if( $norm != $clean )
return;
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C...
◆ doTestDoubleBytes()
CleanUpTest::doTestDoubleBytes |
( |
|
$head, |
|
|
|
$tail |
|
) |
| |
- Todo:
- document
Definition at line 163 of file CleanUpTest.php.
References $x, UtfNormal\cleanUp(), UtfNormal\NFC(), and UTF8_REPLACEMENT.
Referenced by testDoubleBytes().
164 for( $first = 0xc0; $first < 0x100; $first++ ) {
165 for( $second = 0x80; $second < 0x100; $second++ ) {
166 $char = $head . chr( $first ) . chr( $second ) . $tail;
168 $x = sprintf(
"%02X,%02X", $first, $second );
176 "Pair $x should be intact" );
177 if( $norm != $clean )
return;
178 } elseif( $first > 0xfd || $second > 0xbf ) {
179 # fe and ff are not legal head bytes -- expect two replacement chars 184 "Forbidden pair $x should be rejected" );
185 if( $norm != $clean )
return;
191 "Forbidden pair $x should be rejected" );
192 if( $norm != $clean )
return;
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C...
◆ doTestTripleBytes()
CleanUpTest::doTestTripleBytes |
( |
|
$head, |
|
|
|
$tail |
|
) |
| |
- Todo:
- document
Definition at line 207 of file CleanUpTest.php.
References $x, UtfNormal\cleanUp(), UtfNormal\NFC(), UTF8_REPLACEMENT, and UTF8_SURROGATE_FIRST.
Referenced by testTripleBytes().
208 for( $first = 0xc0; $first < 0x100; $first++ ) {
209 for( $second = 0x80; $second < 0x100; $second++ ) {
210 #for( $third = 0x80; $third < 0x100; $third++ ) { 211 for( $third = 0x80; $third < 0x81; $third++ ) {
212 $char = $head . chr( $first ) . chr( $second ) . chr( $third ) . $tail;
214 $x = sprintf(
"%02X,%02X,%02X", $first, $second, $third );
215 if( $first >= 0xe0 &&
219 if( $first == 0xe0 && $second < 0xa0 ) {
223 "Overlong triplet $x should be rejected" );
224 } elseif( $first == 0xed &&
229 "Surrogate triplet $x should be rejected" );
234 "Triplet $x should be intact" );
236 } elseif( $first > 0xc1 && $first < 0xe0 && $second < 0xc0 ) {
240 "Valid 2-byte $x + broken tail" );
241 } elseif( $second > 0xc1 && $second < 0xe0 && $third < 0xc0 ) {
245 "Broken head + valid 2-byte $x" );
246 } elseif( ( $first > 0xfd || $second > 0xfd ) &&
247 ( ( $second > 0xbf && $third > 0xbf ) ||
248 ( $second < 0xc0 && $third < 0xc0 ) ||
249 ( $second > 0xfd ) ||
250 ( $third > 0xfd ) ) ) {
251 # fe and ff are not legal head bytes -- expect three replacement chars 255 "Forbidden triplet $x should be rejected" );
256 } elseif( $first > 0xc2 && $second < 0xc0 && $third < 0xc0 ) {
260 "Forbidden triplet $x should be rejected" );
265 "Forbidden triplet $x should be rejected" );
const UTF8_SURROGATE_FIRST
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C...
◆ setUp()
◆ tearDown()
CleanUpTest::tearDown |
( |
| ) |
|
◆ testAllBytes()
CleanUpTest::testAllBytes |
( |
| ) |
|
◆ testAscii()
CleanUpTest::testAscii |
( |
| ) |
|
- Todo:
- document
Definition at line 55 of file CleanUpTest.php.
References $text, and UtfNormal\cleanUp().
56 $text =
'This is plain ASCII text.';
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C...
◆ testBomRegression()
CleanUpTest::testBomRegression |
( |
| ) |
|
- Todo:
- document
Definition at line 371 of file CleanUpTest.php.
References $text, and UtfNormal\cleanUp().
372 $text =
"\xef\xbf\xbe" . # U+FFFE, illegal
char 376 $expect =
"\xef\xbf\xbd" .
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C...
◆ testChunkRegression()
CleanUpTest::testChunkRegression |
( |
| ) |
|
- Todo:
- document
Definition at line 273 of file CleanUpTest.php.
References $text, and UtfNormal\cleanUp().
274 # Check for regression against a chunking bug 275 $text =
"\x46\x55\xb8" .
282 $expect =
"\x46\x55\xef\xbf\xbd" .
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C...
◆ testDoubleBytes()
CleanUpTest::testDoubleBytes |
( |
| ) |
|
◆ testForbiddenRegression()
CleanUpTest::testForbiddenRegression |
( |
| ) |
|
- Todo:
- document
Definition at line 386 of file CleanUpTest.php.
References $text, and UtfNormal\cleanUp().
387 $text =
"\xef\xbf\xbf"; # U+FFFF, illegal
char 388 $expect =
"\xef\xbf\xbd";
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C...
◆ testHangulRegression()
CleanUpTest::testHangulRegression |
( |
| ) |
|
- Todo:
- document
Definition at line 395 of file CleanUpTest.php.
References $text, and UtfNormal\cleanUp().
396 $text =
"\xed\x9c\xaf" . # Hangul
char 397 "\xe1\x87\x81"; # followed by another
final jamo
398 $expect =
$text; # Should *not* change.
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C...
◆ testInterposeRegression()
CleanUpTest::testInterposeRegression |
( |
| ) |
|
- Todo:
- document
Definition at line 296 of file CleanUpTest.php.
References $text, and UtfNormal\cleanUp().
311 $expect =
"\x4e\x30" .
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C...
◆ testLatin()
CleanUpTest::testLatin |
( |
| ) |
|
- Todo:
- document
Definition at line 70 of file CleanUpTest.php.
References $text, and UtfNormal\cleanUp().
71 $text =
"L'\xc3\xa9cole";
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C...
◆ testLatinNormal()
CleanUpTest::testLatinNormal |
( |
| ) |
|
- Todo:
- document
Definition at line 76 of file CleanUpTest.php.
References $text, and UtfNormal\cleanUp().
77 $text =
"L'e\xcc\x81cole";
78 $expect =
"L'\xc3\xa9cole";
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C...
◆ testNull()
CleanUpTest::testNull |
( |
| ) |
|
- Todo:
- document
Definition at line 61 of file CleanUpTest.php.
References $text, and UtfNormal\cleanUp().
62 $text =
"a \x00 null";
63 $expect =
"a \xef\xbf\xbd null";
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C...
◆ testOverlongRegression()
CleanUpTest::testOverlongRegression |
( |
| ) |
|
- Todo:
- document
Definition at line 331 of file CleanUpTest.php.
References $text, and UtfNormal\cleanUp().
333 "\x1a" . # forbidden ascii
335 "\xc1\xa6" . # overlong sequence
337 "\x1c" . # forbidden ascii
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C...
◆ testSurrogateRegression()
CleanUpTest::testSurrogateRegression |
( |
| ) |
|
- Todo:
- document
Definition at line 356 of file CleanUpTest.php.
References $text, and UtfNormal\cleanUp().
357 $text =
"\xed\xb4\x96" . # surrogate 0xDD16
361 $expect =
"\xef\xbf\xbd" .
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C...
◆ testTripleBytes()
CleanUpTest::testTripleBytes |
( |
| ) |
|
◆ XtestAllChars()
CleanUpTest::XtestAllChars |
( |
| ) |
|
This test is very expensive!
- Todo:
- document
Definition at line 86 of file CleanUpTest.php.
References $utfCanonicalComp, $utfCanonicalDecomp, $x, UtfNormal\cleanUp(), codepointToUtf8(), UtfNormal\NFC(), UNICODE_MAX, UNICODE_SURROGATE_FIRST, UNICODE_SURROGATE_LAST, and UTF8_REPLACEMENT.
92 $x = sprintf(
"%04X", $i );
93 if( $i % 0x1000 == 0 )
echo "U+$x\n";
99 ($i > 0xffff && $i <= UNICODE_MAX ) ) {
100 if( isset( $utfCanonicalComp[$char] ) || isset( $utfCanonicalDecomp[$char] ) ) {
105 "U+$x should be decomposed" );
110 "U+$x should be intact" );
113 $this->assertEquals( bin2hex( $rep ), bin2hex( $clean ),
$x );
const UNICODE_SURROGATE_LAST
global $utfCanonicalDecomp
codepointToUtf8( $codepoint)
Return UTF-8 sequence for a given Unicode code point.
const UNICODE_SURROGATE_FIRST
static cleanUp( $string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C...
The documentation for this class was generated from the following file: