MediaWiki REL1_39
generateUpperCharTable.php
Go to the documentation of this file.
1<?php
26require_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;
53require_once RUN_MAINTENANCE_IF_MAIN;
__construct()
Default constructor.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.