function Cleantalk::stringToUTF8 in Anti Spam by CleanTalk 8.4
Same name and namespace in other branches
- 9.1.x src/lib/Cleantalk/Antispam/Cleantalk.php \Cleantalk\Antispam\Cleantalk::stringToUTF8()
Function convert string to UTF8 and removes non UTF8 characters param string param string
Return value
string
1 call to Cleantalk::stringToUTF8()
- Cleantalk::createMsg in src/
lib/ Cleantalk/ Antispam/ Cleantalk.php - Create msg for cleantalk server
File
- src/
lib/ Cleantalk/ Antispam/ Cleantalk.php, line 687
Class
- Cleantalk
- Cleantalk class create request
Namespace
Cleantalk\AntispamCode
function stringToUTF8($str, $data_codepage = null) {
if (!preg_match('//u', $str) && function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) {
if ($data_codepage !== null) {
return mb_convert_encoding($str, 'UTF-8', $data_codepage);
}
$encoding = mb_detect_encoding($str);
if ($encoding) {
return mb_convert_encoding($str, 'UTF-8', $encoding);
}
}
return $str;
}