| 97 | |
| 98 | /** |
| 99 | * @ticket 24661 |
| 100 | */ |
| 101 | public function test_remove_accents_combining_marks() { |
| 102 | // Creates a string with all the combining marks. |
| 103 | $code_points = array_merge( |
| 104 | range( 0x0300, 0x036F ), // Combining Diacritical Marks |
| 105 | range( 0x1DC0, 0x1DFF ), // Combining Diacritical Marks Supplement |
| 106 | range( 0x20D0, 0x20FF ), // Combining Diacritical Marks for Symbols |
| 107 | range( 0xFE20, 0xFE2F ) // Combining Half Marks |
| 108 | ); |
| 109 | $combining_marks = ''; |
| 110 | foreach ( $code_points as $code_point ) |
| 111 | if ( $code_point <= 0x07ff ) |
| 112 | $combining_marks .= chr( 0xc0 | ( $code_point >> 6 ) ) . chr( 0x80 | ( $code_point & 0x003f ) ); |
| 113 | else |
| 114 | $combining_marks .= chr( 0xe0 | ( $code_point >> 12 ) ) . chr( 0x80 | ( ( $code_point >> 6 ) & 0x003f ) ) . chr( 0x80 | ( $code_point & 0x003f ) ); |
| 115 | // Performs the test: all the characters should be removed. |
| 116 | $this->assertEquals( '', remove_accents( $combining_marks ) ); |
| 117 | |
| 118 | // test a collection of filenames that could have problems |
| 119 | $test1 = remove_accents( 'Capture d’écran 2013-02-20 à 23.36.06.png' ); |
| 120 | $test1_no_accents = 'Capture d’ecran 2013-02-20 a 23.36.06.png'; |
| 121 | |
| 122 | $this->assertEquals( $test1, $test1_no_accents ); |
| 123 | |
| 124 | $test2 = remove_accents( 'Buttermödeli.jpg' ); |
| 125 | $test2_no_accents = 'Buttermodeli.jpg'; |
| 126 | |
| 127 | $this->assertEquals( $test2, $test2_no_accents ); |
| 128 | |
| 129 | $test3 = remove_accents( 'Münsterl.Mai13a.jpg' ); |
| 130 | $test3_no_accents = 'Munsterl.Mai13a.jpg'; |
| 131 | |
| 132 | $this->assertEquals( $test3, $test3_no_accents ); |
| 133 | } |
| 134 | |