Skip to content
Snippets Groups Projects
Commit ad9276e9 authored by Jared Hancock's avatar Jared Hancock
Browse files

charset: Consider case-insensitive charset names

Also fix bug where bogus charset names like `iso` were confused with valid
charset names starting with that text, such as `iso-8859-2`.
parent c7acea78
No related branches found
No related tags found
No related merge requests found
......@@ -24,16 +24,16 @@ class Charset {
$match = array();
switch (true) {
// Windows charsets - force correct format
case preg_match('`^Windows-?(\d+)$`', $charset, $match):
case preg_match('`^Windows-?(\d+)$`i', $charset, $match):
return 'Windows-'.$match[1];
// ks_c_5601-1987: Korean alias for cp949
case preg_match('`^ks_c_5601-1987`', $charset):
case preg_match('`^ks_c_5601-1987`i', $charset):
return 'cp949';
case preg_match('`^iso-?(\S+)$`', $charset, $match):
case preg_match('`^iso-?(\S+)$`i', $charset, $match):
return "ISO-".$match[1];
// Incorrect, bogus, ambiguous or empty charsets
// ISO-8859-1 is assumed
case preg_match('`^(default|x-user-defined|iso|us-ascii)`', $charset):
case preg_match('`^(default|x-user-defined|iso|us-ascii)$`i', $charset):
case preg_match('`^\s*$`', $charset):
return 'ISO-8859-1';
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment