Browse Source

Partial Shift_JIS implementation

multi-byte
J. King 4 years ago
parent
commit
85f06186f2
  1. 129
      lib/Encoding/ShiftJIS.php
  2. 169
      tests/cases/Encoding/TestShiftJIS.php
  3. 3
      tests/phpunit.xml
  4. 9
      tools/mkindex.php

129
lib/Encoding/ShiftJIS.php

File diff suppressed because one or more lines are too long

169
tests/cases/Encoding/TestShiftJIS.php

File diff suppressed because one or more lines are too long

3
tests/phpunit.xml

@ -17,7 +17,7 @@
<testsuites>
<testsuite name="Encoding">
<file>cases/Encoding/TestUTF8.php</file>
<!--<file>cases/Encoding/TestUTF8.php</file>
<file>cases/Encoding/TestUTF16LE.php</file>
<file>cases/Encoding/TestUTF16BE.php</file>
<file>cases/Encoding/TestSingleByte.php</file>
@ -26,6 +26,7 @@
<file>cases/Encoding/TestGB18030.php</file>
<file>cases/Encoding/TestBig5.php</file>
<file>cases/Encoding/TestEUCKR.php</file>
--><file>cases/Encoding/TestShiftJIS.php</file>
<file>cases/TestEncoding.php</file>
</testsuite>

9
tools/mkindex.php

@ -25,7 +25,7 @@ $labels = [
'koi8-r' => "single_byte",
'koi8-u' => "single_byte",
'macintosh' => "single_byte",
//'shift-jis' => "shiftjis",
'shift-jis' => "shiftjis",
'windows-1250' => "single_byte",
'windows-1251' => "single_byte",
'windows-1252' => "single_byte",
@ -41,7 +41,7 @@ $labels = [
$label = $argv[1] ?? "";
$label = trim(strtolower($label));
if (!isset($labels[$label])) {
die("Invalid label specified. Must be one of: ".json_encode(array_keys($labels)));
die("Invalid label specified. Must be one of: ".json_encode(array_keys($labels))."\n");
}
($labels[$label])($label);
@ -141,6 +141,11 @@ function eucjp(string $label) {
echo "const TABLE_JIS0212 = $jis0212;\n";
}
function shiftjis(string $label) {
$codes = make_decoder_point_array(read_index($label, "https://encoding.spec.whatwg.org/index-jis0208.txt"));
echo "const TABLE_CODES = $codes;\n";
}
// generic helper functions
function read_index(string $label, string $url): array {

Loading…
Cancel
Save