php - Why are there � on my page -
i've set page default charset , mysql table charset utf8. works on of pages, on pages when output chinese characters '全' , '公' appears � while on other pages can output normally.
the difference between pages , error pages realize used ereg_replace before output on error page.
$sounds = nl2br($model->sounds); $sounds= preg_replace('/(\v|\s)+/', ' ', $sounds); $sounds= preg_replace("#(<br />|<br /> )+[< b r > \ ]*[<br />| <br /> ]+#","<br>",$sounds); $pattern='#[\d]+[\-]*[\d]*[\.]+#'; if(preg_match($pattern,$sounds)&&!preg_match('#<br />|<br />|<br>#',$sounds)) { $sounds= preg_replace("#[\d]+[\-]*[\d]*[\.]+#","<br>",$sounds); }
could these functions reason? or else reason be?
update:
found when comment $sounds= preg_replace('/(\v|\s)+/', ' ', $sounds);
works fine, want use line delete multiple white spaces in data. what's alternative way this?
that reason. use u
(utf-8) modifier, otherwise regular expression match parts of unicode characters.
also, noticed mentioned ereg_*
using preg_*
. that's good, prefer using preg_*
instead of old, slow , deprecated ereg_*
functions.
Comments
Post a Comment