MediaWiki  1.34.0
generateUpperCharTable.php
Go to the documentation of this file.
1 <?php
26 require_once __DIR__ . '/../Maintenance.php';
27 
29 
30  public function __construct() {
31  parent::__construct();
32  $this->addDescription( 'Generates the lowercase => uppercase json table' );
33  $this->addOption( 'outfile', 'Output file', true, true, 'o' );
34  }
35 
36  public function execute() {
37  $outfile = $this->getOption( 'outfile', 'upperchar.json' );
38  $toUpperTable = [];
39  for ( $i = 0; $i <= 0x10ffff; $i++ ) {
40  // skip all surrogate codepoints or json_encode would fail.
41  if ( $i >= 0xd800 && $i <= 0xdfff ) {
42  continue;
43  }
44  $char = UtfNormal\Utils::codepointToUtf8( $i );
45  $upper = mb_strtoupper( $char );
46  $toUpperTable[$char] = $upper;
47  }
48  file_put_contents( $outfile, json_encode( $toUpperTable ) );
49  }
50 }
51 
52 $maintClass = GenerateUpperCharTable::class;
53 require_once RUN_MAINTENANCE_IF_MAIN;
RUN_MAINTENANCE_IF_MAIN
const RUN_MAINTENANCE_IF_MAIN
Definition: Maintenance.php:39
Maintenance\addDescription
addDescription( $text)
Set the description text.
Definition: Maintenance.php:348
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: Maintenance.php:82
GenerateUpperCharTable\execute
execute()
Do the actual work.
Definition: generateUpperCharTable.php:36
Maintenance\addOption
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
Definition: Maintenance.php:267
GenerateUpperCharTable
Definition: generateUpperCharTable.php:28
GenerateUpperCharTable\__construct
__construct()
Default constructor.
Definition: generateUpperCharTable.php:30
Maintenance\getOption
getOption( $name, $default=null)
Get an option, or return the default.
Definition: Maintenance.php:302
$maintClass
$maintClass
Definition: generateUpperCharTable.php:52