Skip to content

Instantly share code, notes, and snippets.

@suzuki
Created April 3, 2012 00:05
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 suzuki/2288154 to your computer and use it in GitHub Desktop.
Save suzuki/2288154 to your computer and use it in GitHub Desktop.
Detect charset from MIME string
/**
* Detect charset from MIME string
*
* @params string
* @return mixed found a charset string (upper case) or couldn't found false
*/
public function getCharsetFromMimeString($mimeString) {
$mimeString = trim($mimeString);
if (preg_match('/^=\?([^?]+)\?(:?B|Q)\?[^?]+\?=$/', $mimeString, $matched)){
return strtoupper($matched[1]);
}
return false;
}
@suzuki
Copy link
Author

suzuki commented Apr 3, 2012

ツッコミありがとうございます! false にします。
実はソコのところを迷ってたのですが、とりあえず null にしてました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment