Skip to content

Commit 3a9cc61

Browse files
committed
Remove mbstring extension dependency
1 parent 739fc54 commit 3a9cc61

File tree

2 files changed

+84
-2
lines changed

2 files changed

+84
-2
lines changed

src/Encoding/Encoding.php

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,92 @@
66

77
final class Encoding implements EncodingInterface
88
{
9+
private const ENCODINGS = [
10+
'BASE64',
11+
'UUENCODE',
12+
'HTML-ENTITIES',
13+
'Quoted-Printable',
14+
'7bit',
15+
'8bit',
16+
'UCS-4',
17+
'UCS-4BE',
18+
'UCS-4LE',
19+
'UCS-2',
20+
'UCS-2BE',
21+
'UCS-2LE',
22+
'UTF-32',
23+
'UTF-32BE',
24+
'UTF-32LE',
25+
'UTF-16',
26+
'UTF-16BE',
27+
'UTF-16LE',
28+
'UTF-8',
29+
'UTF-7',
30+
'UTF7-IMAP',
31+
'ASCII',
32+
'EUC-JP',
33+
'SJIS',
34+
'eucJP-win',
35+
'EUC-JP-2004',
36+
'SJIS-Mobile#DOCOMO',
37+
'SJIS-Mobile#KDDI',
38+
'SJIS-Mobile#SOFTBANK',
39+
'SJIS-mac',
40+
'SJIS-2004',
41+
'UTF-8-Mobile#DOCOMO',
42+
'UTF-8-Mobile#KDDI-A',
43+
'UTF-8-Mobile#KDDI-B',
44+
'UTF-8-Mobile#SOFTBANK',
45+
'CP932',
46+
'SJIS-win',
47+
'CP51932',
48+
'JIS',
49+
'ISO-2022-JP',
50+
'ISO-2022-JP-MS',
51+
'GB18030',
52+
'Windows-1252',
53+
'Windows-1254',
54+
'ISO-8859-1',
55+
'ISO-8859-2',
56+
'ISO-8859-3',
57+
'ISO-8859-4',
58+
'ISO-8859-5',
59+
'ISO-8859-6',
60+
'ISO-8859-7',
61+
'ISO-8859-8',
62+
'ISO-8859-9',
63+
'ISO-8859-10',
64+
'ISO-8859-13',
65+
'ISO-8859-14',
66+
'ISO-8859-15',
67+
'ISO-8859-16',
68+
'EUC-CN',
69+
'CP936',
70+
'HZ',
71+
'EUC-TW',
72+
'BIG-5',
73+
'CP950',
74+
'EUC-KR',
75+
'UHC',
76+
'ISO-2022-KR',
77+
'Windows-1251',
78+
'CP866',
79+
'KOI8-R',
80+
'KOI8-U',
81+
'ArmSCII-8',
82+
'CP850',
83+
'ISO-2022-JP-2004',
84+
'ISO-2022-JP-MOBILE#KDDI',
85+
'CP50220',
86+
'CP50221',
87+
'CP50222',
88+
];
89+
990
public function __construct(
1091
private readonly string $value
1192
) {
12-
if (!in_array($value, mb_list_encodings())) {
13-
throw new \Exception(sprintf('Invalid encoding "%s"', $value));
93+
if (!in_array($value, self::ENCODINGS)) {
94+
throw new \Exception(sprintf('Invalid encoding "%s": choose one of '.implode(', ', self::ENCODINGS), $value));
1495
}
1596
}
1697

src/Writer/SvgWriter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ private function formatNumber(float $number): string
117117
$string = number_format($number, self::DECIMAL_PRECISION, '.', '');
118118
$string = rtrim($string, '0');
119119
$string = rtrim($string, '.');
120+
120121
return $string;
121122
}
122123
}

0 commit comments

Comments
 (0)