开发者

Character set ISO-8859-1 displaying improperly

开发者 https://www.devze.com 2023-01-20 10:36 出处:网络
My default character encoding is Western (ISO latin 1, ISO-8859-1).I am using this code to change the character set:

My default character encoding is Western (ISO latin 1, ISO-8859-1). I am using this code to change the character set:

<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" />

My website only displays properly when I click on "Text Encoding" then "Western开发者_StackOverflow (ISO latin 1)" in the Safari view menu. Even when set on default (Safari text encoding menu), it still doesn't display properly (weird black-diamond question marks). I am using ruby on rails, if that might be an issue with the encoding.


You should add the following to your application_controller :

before_filter :headers_iso

def headers_iso
  headers["content-type"]= "text/html;charset=ISO-8859-1"
end


I think this is a safari problem. In PHP you can solve this by adding :

<?php header('Content-type: text/html; charset=iso-8859-1'); ?>

BEFORE any text output or echo().

I maintain a site witch is done like this :

<?php header('Content-type: text/html; charset=iso-8859-1'); ?>
<!DOCTYPE HTML ...
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号