* Fix a couple mistakes in generateUcfirstOverrides.php
* Skip surrogate codepoints as they can't be converted to json.
Change-Id: I5eddd90f7b348806d502dfbac08c367701d17f25
foreach ( $from as $lc => $uc ) {
$ref = $to[$lc] ?? null;
if ( $ref !== null && $ref !== $uc ) {
foreach ( $from as $lc => $uc ) {
$ref = $to[$lc] ?? null;
if ( $ref !== null && $ref !== $uc ) {
+ $overrides[$lc] = $ref;
}
}
$writer = new StaticArrayWriter();
}
}
$writer = new StaticArrayWriter();
$msg = sprintf( "Could not load data from file '%s'\n", $filename );
$this->fatalError( $msg );
}
$msg = sprintf( "Could not load data from file '%s'\n", $filename );
$this->fatalError( $msg );
}
- $json = json_decode( $data );
- if ( $result === null ) {
+ $json = json_decode( $data, true );
+ if ( $json === null ) {
$msg = sprintf( "Invalid json in the data file %s\n", $filename );
$this->fatalError( $msg, 2 );
}
$msg = sprintf( "Invalid json in the data file %s\n", $filename );
$this->fatalError( $msg, 2 );
}
$outfile = $this->getOption( 'outfile', 'upperchar.json' );
$toUpperTable = [];
for ( $i = 0; $i <= 0x10ffff; $i++ ) {
$outfile = $this->getOption( 'outfile', 'upperchar.json' );
$toUpperTable = [];
for ( $i = 0; $i <= 0x10ffff; $i++ ) {
+ // skip all surrogate codepoints or json_encode would fail.
+ if ( $i >= 0xd800 && $i <= 0xdfff ) {
+ continue;
+ }
$char = UtfNormal\Utils::codepointToUtf8( $i );
$upper = mb_strtoupper( $char );
$toUpperTable[$char] = $upper;
$char = UtfNormal\Utils::codepointToUtf8( $i );
$upper = mb_strtoupper( $char );
$toUpperTable[$char] = $upper;