Skip to content

Commit 9234862

Browse files
authored
Merge pull request #286 from boxingnguyen/master
add check and convert encoding type SJIS
2 parents 5977d0c + 7807edc commit 9234862

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Http/Response.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ public function getHtmlContent()
6969
'<head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">',
7070
$content
7171
);
72+
} elseif (mb_detect_encoding($content, 'SJIS', true) === 'SJIS') {
73+
$content = mb_convert_encoding($content, 'HTML-ENTITIES', 'SJIS');
74+
$content = preg_replace('/<head[^>]*>/', '<head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=shift_jis">', $content);
7275
} elseif (mb_detect_encoding($content, 'ISO-8859-1', true) === 'ISO-8859-1') {
7376
$content = mb_convert_encoding($content, 'HTML-ENTITIES', 'ISO-8859-1');
7477
$content = preg_replace('/<head[^>]*>/', '<head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">', $content);

0 commit comments

Comments
 (0)