简体   繁体   English

没有显示在站点的欧洲标志

[英]Euro sign not showing on site

One of my fields (which is a latin1_swedish_ci) seems to show the euro symbol fine in PHPMYADMIN inside of the field. 我的一个字段(这是一个latin1_swedish_ci)似乎在字段内的PHPMYADMIN中显示欧元符号正常。

However, when I try to echo it in an input field on my website in a form, it shows up as the question-mark in firefox. 但是,当我尝试在表单中的网站上的输入字段中回显它时,它在firefox中显示为问号。

Heres the html/php: 继承人html / php:

$sql = mysql_query("select * from `settings`");

while ($row = mysql_fetch_assoc($sql))
    $setting[$row['field']] = htmlspecialchars($row['value'], ENT_QUOTES);

<input type="text" name="currency_symbol" id="currency_symbol" size="50" value="<?php echo $setting['currency_symbol']; ?>" />

I am using the following meta tag on the page: 我在页面上使用以下元标记:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

I've tried using utf8_general_ci for the field, but I get the same result. 我已经尝试过将utf8_general_ci用于该字段,但我得到了相同的结果。

Try using htmlentities() instead of htmlspecialchars() . 尝试使用htmlentities()而不是htmlspecialchars()

Special chars does not convert everything, just a few select characters. 特殊字符不会转换所有内容,只需几个选择字符。 The Euro symbol €, needs to be encoded really, &euro; 欧元符号€,需要真正编码, &euro; .

If you are serving the page as UTF-8, you will need to ensure you grab the string out of the database in the UTF-8 encoding before putting it on the page. 如果您以UTF-8的形式提供页面,则需要确保在将数据库放入页面之前以UTF-8编码从数据库中获取字符串。 You can do that using: 你可以这样做:

mysql_set_charset('utf8');

(If you're doing that it would also make sense to store your actual table data in UTF-8 too, eg utf8_general_ci , rather than latin1_swedish_ci , so you can deal properly with characters outside of the basic Latin-1 set.) (如果你这样做也将你的实际表数据存储在UTF-8中也是有意义的,例如utf8_general_ci ,而不是latin1_swedish_ci ,这样你就可以正确处理基本的Latin-1集之外的字符了。)

Try to change the MySQL charset to UTF-8 or to Swedish. 尝试将MySQL字符集更改为UTF-8或瑞典语。

Here it is a small example. 是一个小例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM