Skip to content

Instantly share code, notes, and snippets.

@sasezaki
Created October 14, 2012 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sasezaki/3888205 to your computer and use it in GitHub Desktop.
Save sasezaki/3888205 to your computer and use it in GitHub Desktop.
For unexpected content-type KS_C_5601-1987
diff --git a/src/Diggin/Http/Charset/Detector/HtmlDetector.php b/src/Diggin/Http/Charset/Detector/HtmlDetector.ph
index 4ed6dbd..ee1b543 100644
--- a/src/Diggin/Http/Charset/Detector/HtmlDetector.php
+++ b/src/Diggin/Http/Charset/Detector/HtmlDetector.php
@@ -36,7 +36,11 @@ class HtmlDetector
private $_config = array('accept_header_ctype' => true,
'force_detect_body' => false,
- 'detect_prefer_mime' => false);
+ 'detect_prefer_mime' => false,
+ 'known_convert_targets' => array(
+ 'KS_C_5601-1987' => 'CP949', //strtoupper
+ )
+ );
/**
* configure
@@ -178,6 +182,11 @@ class HtmlDetector
//if ($wellknown = array_search($encoding, array('HZ-GB-2312' => 'GB-2312'))) {
// return $wellknown;
//}
+
+ if (in_array(strtoupper($encoding), array_keys($this->_config['known_convert_targets']))) {
+ $encoding = $this->_config['known_convert_targets'][strtoupper($encoding)];
+ }
+
return $encoding;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment