mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
Add formatter class and associated unit tests
This commit is contained in:
parent
2b008f7be6
commit
ed50a57f9c
31 changed files with 692 additions and 0 deletions
|
|
@ -519,6 +519,27 @@ function utf8_check($str)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove BOM and invalid UTF-8 sequences from file content.
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
function utf8_clean($str)
|
||||
{
|
||||
if (strlen($str) >= 3 && substr($str, 0, 3) === "\xEF\xBB\xBF")
|
||||
{
|
||||
$str = substr($str, 3);
|
||||
}
|
||||
|
||||
if (!utf8_check($str))
|
||||
{
|
||||
$str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode UTF-8 characters outside of the Basic Multilingual Plane in the &#xxxxxx format.
|
||||
* This allows emoticons and other characters to be stored in MySQL without utf8mb4 support.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue