我正在使用substr()函数来剪切字符串.它使用普通字符串工作正常但是如果字符串带有重音符号,它会在剪切前显示有趣的字符,如下所示:
这是代码:
$rawtitle ="Tin ??ng c?a giangvy1011 tin c?a dtdd";
$title = substr($rawtitle,0,36).'...';
echo $title;
Run Code Online (Sandbox Code Playgroud)
这是我得到的回声结果:

有没有办法围绕这个或不同的功能来实现这一目标?非常感谢
我想在html()里面设置文本样式color:red; font-weight:bold.我怎么能在jQuery本身内做到这一点?我可以id=login_result在html中设置div的样式,但这里的每个文本都是红色和粗体.我只是希望下面这些错误文本只是红色.非常感谢
var login_result = $('#login_result');
if ($.trim(email.val()).length == 0) {
email.focus(); // focus to the filed
login_result.html('<span> Email field is required</span>');
return false;
}
Run Code Online (Sandbox Code Playgroud)