I'm pulling some text from a database, which contains some carriage returns. When I put them s开发者_开发问答traight into html, they get interpreted as � . I've tried a bunch of different ways to remove them, but haven't seemed to have any luck.
Any thoughts?
It sounds like character encoding conflicts. Other previous suggestions are fine for a quick fix, but if you control the data I think you'd be better off figuring out and sticking to a single character set. If you read from a UTF-8 database and include that text on a website, don't tell the browser that you're serving ISO-8859-1 or Windows-1252.
select Replace(myColumn,CHAR(13),'')
Have you tried this? What else have you tried?
Well, if you want to keep the carriage returns, use nl2br
otherwise use $val = str_replace(array('\r\n', '\r', '\n'), ' ', $val);
精彩评论