MediaWiki
master
Toggle main menu visibility
generateUpperCharTable.php
Go to the documentation of this file.
1
<?php
11
12
use
MediaWiki\Maintenance\Maintenance
;
13
14
// @codeCoverageIgnoreStart
15
require_once __DIR__ .
'/../Maintenance.php'
;
16
// @codeCoverageIgnoreEnd
17
18
class
GenerateUpperCharTable
extends
Maintenance
{
19
20
public
function
__construct
() {
21
parent::__construct();
22
$this->addDescription(
'Generates the lowercase => uppercase json table'
);
23
$this->addOption(
'outfile'
,
'Output file'
,
true
,
true
,
'o'
);
24
$this->addOption(
'titlecase'
,
'Use title case instead of upper case'
);
25
}
26
27
public
function
execute
() {
28
$outfile = $this->getOption(
'outfile'
,
'upperchar.json'
);
29
$toUpperTable = [];
30
$titlecase = $this->getOption(
'titlecase'
);
31
for
( $i = 0; $i <= 0x10ffff; $i++ ) {
32
// skip all surrogate codepoints or json_encode would fail.
33
if
( $i >= 0xd800 && $i <= 0xdfff ) {
34
continue
;
35
}
36
$char = UtfNormal\Utils::codepointToUtf8( $i );
37
if
( $titlecase ) {
38
$upper = mb_convert_case( $char, MB_CASE_TITLE );
39
}
else
{
40
$upper = mb_strtoupper( $char );
41
}
42
$toUpperTable[$char] = $upper;
43
}
44
file_put_contents( $outfile, json_encode( $toUpperTable ) );
45
}
46
}
47
48
// @codeCoverageIgnoreStart
49
$maintClass
= GenerateUpperCharTable::class;
50
require_once RUN_MAINTENANCE_IF_MAIN;
51
// @codeCoverageIgnoreEnd
$maintClass
$maintClass
Definition
addChangeTag.php:56
GenerateUpperCharTable
Definition
generateUpperCharTable.php:18
GenerateUpperCharTable\__construct
__construct()
Definition
generateUpperCharTable.php:20
GenerateUpperCharTable\execute
execute()
Definition
generateUpperCharTable.php:27
MediaWiki\Maintenance
Definition
applyChangeTag.php:11
maintenance
language
generateUpperCharTable.php
Generated on
for MediaWiki by
1.18.0