-
Notifications
You must be signed in to change notification settings - Fork 10
/
c2ct
executable file
·54 lines (44 loc) · 1.75 KB
/
c2ct
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
51
52
53
54
#!/usr/bin/env php
<?php
require __DIR__ . '/CollationToCharsetTable.php';
$c2cc = new \spinitron\c2ct\CollationToCharsetTable(require __DIR__ . '/config.php');
$script = basename(array_shift($argv));
$command = array_shift($argv);
switch ($command) {
case 'newtable':
$c2cc->createDbCharsetTable(in_array('-v', $argv));
break;
case 'editable':
echo $c2cc->getEditable(!in_array('-d', $argv), in_array('-c', $argv));
break;
case 'utf8':
case 'hex':
case 'sphinx':
case 'compressed':
if (end($argv) === '-') {
$c2cc->parseCharsetTable(file_get_contents('php://stdin'), !in_array('-d', $argv));
}
$method = 'get' . ucfirst($command);
echo $c2cc->$method();
break;
default:
echo <<<TXT
Usage:
$script { newtable [-v] | editable [-c] [-d] | { hex | utf8 | sphinx | compressed } [-d] [-] }
Commands:
- newtable : Populate the DB charset table with characters
- editable : Write the DB charset table as human-editable charset table to stdout
- hex | utf8 | sphinx | compressed : Read a raw charset table from either stdin
or the DB table, process it, and write it to stdout
- hex as hex codepoints for reading by a human
- utf8 in UTF-8 characters for reading by a human
- sphinx as a Sphinx charset_table structured for easier reading by a human
- compressed Sphinx charset_table compressed onto fewer lines
Options:
-v Write verbose information about each codepoint in the collated ranges
-c Sort output table by codepoint rather than collation
-d Codepoints in decimal rather than hex
- Read the charset table from stdin instead of the DB table
TXT;
exit(1);
}