|
@@ -21,10 +21,7 @@ class Fun { |
|
@@ -21,10 +21,7 @@ class Fun { |
21
|
*/
|
21
|
*/
|
22
|
public static function mb_convert_encoding($str, $to, $from = null){
|
22
|
public static function mb_convert_encoding($str, $to, $from = null){
|
23
|
|
23
|
|
24
|
- // 这个好像是阿拉伯编码
|
|
|
25
|
- if($from == 'iso-8859-8-i'){
|
|
|
26
|
- $from = 'iso-8859-8';
|
|
|
27
|
- }
|
24
|
+ $from = self::getEncodingAliases($from);
|
28
|
|
25
|
|
29
|
|
26
|
|
30
|
try {
|
27
|
try {
|
|
@@ -35,4 +32,28 @@ class Fun { |
|
@@ -35,4 +32,28 @@ class Fun { |
35
|
}
|
32
|
}
|
36
|
|
33
|
|
37
|
|
34
|
|
|
|
35
|
+ /**
|
|
|
36
|
+ * 只有发现一个处理一个
|
|
|
37
|
+ * 获取编码
|
|
|
38
|
+ * @author:dc
|
|
|
39
|
+ * @time 2024/10/25 17:24
|
|
|
40
|
+ */
|
|
|
41
|
+ public static function getEncodingAliases($coding){
|
|
|
42
|
+ $alias = [
|
|
|
43
|
+ "iso-8859-8-i" => "ISO-8859-8",
|
|
|
44
|
+ "iso-8859-8-e" => "ISO-8859-8",
|
|
|
45
|
+ "iso-8859-6-i" => "ISO-8859-6",
|
|
|
46
|
+ "iso-8859-6-e" => "ISO-8859-6",
|
|
|
47
|
+ ];
|
|
|
48
|
+
|
|
|
49
|
+ $coding = strtolower($coding);
|
|
|
50
|
+ if(isset($alias[$coding])){
|
|
|
51
|
+ return $alias[$coding];
|
|
|
52
|
+ }
|
|
|
53
|
+
|
|
|
54
|
+ return $coding;
|
|
|
55
|
+
|
|
|
56
|
+ }
|
|
|
57
|
+
|
|
|
58
|
+
|
38
|
} |
59
|
} |