Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
GenerateUpperCharTable | |
0.00% |
0 / 16 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
30 |
1 | <?php |
2 | /** |
3 | * Generate a json file containing an array of |
4 | * utf8_lowercase => utf8_uppercase |
5 | * for all of the utf-8 range. This provides the input for generateUcfirstOverrides.php |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or |
10 | * (at your option) any later version. |
11 | * |
12 | * This program is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * GNU General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU General Public License along |
18 | * with this program; if not, write to the Free Software Foundation, Inc., |
19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
20 | * http://www.gnu.org/copyleft/gpl.html |
21 | * |
22 | * @file |
23 | * @ingroup MaintenanceLanguage |
24 | */ |
25 | |
26 | // @codeCoverageIgnoreStart |
27 | require_once __DIR__ . '/../Maintenance.php'; |
28 | // @codeCoverageIgnoreEnd |
29 | |
30 | class GenerateUpperCharTable extends Maintenance { |
31 | |
32 | public function __construct() { |
33 | parent::__construct(); |
34 | $this->addDescription( 'Generates the lowercase => uppercase json table' ); |
35 | $this->addOption( 'outfile', 'Output file', true, true, 'o' ); |
36 | $this->addOption( 'titlecase', 'Use title case instead of upper case' ); |
37 | } |
38 | |
39 | public function execute() { |
40 | $outfile = $this->getOption( 'outfile', 'upperchar.json' ); |
41 | $toUpperTable = []; |
42 | $titlecase = $this->getOption( 'titlecase' ); |
43 | for ( $i = 0; $i <= 0x10ffff; $i++ ) { |
44 | // skip all surrogate codepoints or json_encode would fail. |
45 | if ( $i >= 0xd800 && $i <= 0xdfff ) { |
46 | continue; |
47 | } |
48 | $char = UtfNormal\Utils::codepointToUtf8( $i ); |
49 | if ( $titlecase ) { |
50 | $upper = mb_convert_case( $char, MB_CASE_TITLE ); |
51 | } else { |
52 | $upper = mb_strtoupper( $char ); |
53 | } |
54 | $toUpperTable[$char] = $upper; |
55 | } |
56 | file_put_contents( $outfile, json_encode( $toUpperTable ) ); |
57 | } |
58 | } |
59 | |
60 | // @codeCoverageIgnoreStart |
61 | $maintClass = GenerateUpperCharTable::class; |
62 | require_once RUN_MAINTENANCE_IF_MAIN; |
63 | // @codeCoverageIgnoreEnd |