4 * Utility to generate mapping file used in phpCharToUpper.js
6 * Compares output of String.toUpperCase in JavaScript with
7 * mb_strtoupper in PHP, and outputs a list of lower:upper
8 * mappings where they differ. This is then used by Title.js
9 * to provide the same normalization in the client as on
15 // phpcs:disable MediaWiki.Usage.ForbiddenFunctions.exec
16 $jsUpperChars = json_decode( exec( 'node generateJsToUpperCaseList.js' ) );
17 // phpcs:enable MediaWiki.Usage.ForbiddenFunctions.exec
19 for ( $i = 0; $i < 65536; $i++
) {
20 if ( $i >= 0xd800 && $i <= 0xdfff ) {
21 // Skip surrogate pairs
24 $char = mb_convert_encoding( '&#' . $i . ';', 'UTF-8', 'HTML-ENTITIES' );
25 $phpUpper = mb_strtoupper( $char );
26 $jsUpper = $jsUpperChars[$i];
27 if ( $jsUpper !== $phpUpper ) {
28 $data[$char] = $phpUpper;
32 echo 'var toUpperMapping = ' . str_replace( '"', "'",
33 str_replace( ' ', "\t",
34 json_encode( $data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE
)