File: update-unidata.php

package info (click to toggle)
php-symfony-polyfill 1.33.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 8,544 kB
  • sloc: php: 127,238; makefile: 69
file content (50 lines) | stat: -rwxr-xr-x 2,281 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env php
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

use Symfony\Polyfill\Internal\Compiler;

require __DIR__.'/Compiler.php';

@mkdir(__DIR__.'/unicode/data', 0777, true);

foreach (['UnicodeData.txt', 'CompositionExclusions.txt', 'CaseFolding.txt', 'SpecialCasing.txt'] as $file) {
    $data = file_get_contents('https://unicode.org/Public/UNIDATA/'.$file);
    file_put_contents(__DIR__.'/unicode/data/'.$file, $data);
}

$data = file_get_contents('https://github.com/unicode-org/cldr/raw/main/common/transforms/Latin-ASCII.xml');
file_put_contents(__DIR__.'/unicode/data/Latin-ASCII.xml', $data);

Compiler::translitMap(__DIR__.'/../src/Iconv/Resources/charset/');
Compiler::unicodeMaps(__DIR__.'/../src/Intl/Normalizer/Resources/unidata/');

rename(__DIR__.'/../src/Intl/Normalizer/Resources/unidata/lowerCase.php', __DIR__.'/../src/Mbstring/Resources/unidata/lowerCase.php');
rename(__DIR__.'/../src/Intl/Normalizer/Resources/unidata/upperCase.php', __DIR__.'/../src/Mbstring/Resources/unidata/upperCase.php');
unlink(__DIR__.'/../src/Intl/Normalizer/Resources/unidata/caseFolding_full.php');

$data = file_get_contents('http://www.unicode.org/Public/UNIDATA/NormalizationTest.txt');
file_put_contents(__DIR__.'/Intl/Normalizer/NormalizationTest.txt', $data);

$data = file_get_contents('http://www.unicode.org/Public/idna/latest/IdnaMappingTable.txt');
file_put_contents(__DIR__.'/unicode/data/IdnaMappingTable.txt', $data);

foreach (['DerivedBidiClass.txt', 'DerivedCombiningClass.txt', 'DerivedGeneralCategory.txt', 'DerivedJoiningType.txt'] as $file) {
    $data = file_get_contents('http://www.unicode.org/Public/UNIDATA/extracted/'.$file);
    file_put_contents(__DIR__.'/unicode/data/'.$file, $data);
}

Compiler::idnMaps(__DIR__.'/../src/Intl/Idn/Resources/unidata/');
Compiler::idnRegexClass(__DIR__.'/../src/Intl/Idn/Resources/unidata/');
Compiler::idnViramaMap(__DIR__.'/../src/Intl/Idn/Resources/unidata/');

$data = file_get_contents('http://www.unicode.org/Public/idna/latest/IdnaTestV2.txt');
file_put_contents(__DIR__.'/Intl/Idn/IdnaTestV2.txt', $data);