![](/img/trans.png)
[英]iconv - Notice: iconv() [function.iconv]: Detected an illegal character in input string
[英]Error while Creating title Slug Notice: iconv(): Detected an illegal character in input string in
我使用了Stackoverflow的这段代码从一个字符串创建了一个标题条
function slugify($text)
{
// replace non letter or digits by -
$text = preg_replace('~[^\pL\d]+~u', '-', $text);
// transliterate
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
// remove unwanted characters
$text = preg_replace('~[^-\w]+~', '', $text);
// trim
$text = trim($text, '-');
// remove duplicate -
$text = preg_replace('~-+~', '-', $text);
// lowercase
$text = strtolower($text);
if (empty($text))
{
return 'n-a';
}
return $text;
}
对于大多数字符串来说,它工作正常。 但可以使用诸如“АзуриАзмар/ Azur et Asmar”之类的字符串来获取。 我现在应该改变什么?
Notice: iconv(): Detected an illegal character in input string in
只是尝试改变
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
至
$text = iconv('utf-8', 'us-ascii//IGNORE', $text);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.