English 中文(简体)
未在网页上展示的英镑符号
原标题:Pound symbol not displaying on web page

我有一个用于储存国名和货币象征的神秘数据库表——CHARSET正确地将国家名称和货币编号定为UTF8。

表格中的数据就是一个例子。

insert into country ( country_name, currency_name, currency_code, currency_symbol) values 
( UK , Pounds , GBP , £ );

当我看数据库时——英镑的象征似乎是罚款的——但当我从数据库中取回,并在网站上显示时,一个圆形的方括号显示,在座标上,而不是在纸面上标出。

Edit In my.cnf - the characterset was set to latin1 - I changed it to utf8 - then I Logged in as root and ran s - it returned

Server characterset:    utf8
Client characterset:    utf8

讨论会

-- Database
SELECT default_collation_name
  FROM information_schema.schemata
 WHERE schema_name =  swipe_prod ;

THIS DOES NOT RETURN ANYTHING

-- Table
SELECT table_collation
  FROM information_schema.tables
 WHERE TABLE_NAME =  country ;

THIS RETURNS utf8_general_ci

-- Columns
SELECT collation_name
  FROM information_schema.columns
 WHERE TABLE_NAME =  country ;

THIS RETURNS 7 ROWS but all have either null or utf8_general_ci

PHP CODE

<?php
$con = mysql_connect("localhost","user","123456");
mysql_select_db("swipe_db", $con);
$result = mysql_query("SELECT * FROM country where country_name= UK ");
while($row = mysql_fetch_array($result))
{
  echo $row[ country_name ] . " " . $row[ currency_symbol ];
}
mysql_close($con);
?>

Please advice Thanks

最佳回答

当你看到“带问题标识的超级广场符号”以其他名称为,这通常是你在80-FF(128-255)范围内随附的指标,该系统正试图将其放在UTF-8。

由于UTF-8的单一特性,整个次距离都是无效的,但在ISO-8859-1等西方编码中都是很常见的。

当我看你的网页和人工转换特性,从UTF-8到ISO-8859-1( >>Character Encoding >>Western(ISO-8859-1)),则 rel=“noreferer”POUND S

因此,什么错了? 很难说——有几十个地方可以躲避。 但最有可能是在数据库一级。 普遍而言,在UTF8的桌子上设置住房和财产管理局是不够的。 你们的所有果园和会堂都需要有秩序,才能妥善地环绕系统。 常见的陷阱是:http://dev.mysql.com/doc/refman/5.0/en/charset-linkion.html” rel=“noreferer”>、联接点/a>,因此我开始这样做。

让我知道,你们是否需要更多的指导。

EDIT

为了检查这些价值实际储存的矿石,可以进行这种盘问。

SELECT hex( currency_symbol )
  FROM country
 WHERE country_name =  UK 

如果见A3,则你知道这一特性是作为ISO-8859-1储存的。 这意味着问题发生在向非行发函期间或之前。

如果见C2A3,则你知道该特性是作为UTF-8储存的。 这意味着这个问题是在从行文读到行文后,然后才写到行文。

EDIT 2

-- Database
SELECT default_collation_name
  FROM information_schema.schemata
 WHERE schema_name =  your_db_name ;

-- Table
SELECT table_collation
  FROM information_schema.tables
 WHERE TABLE_NAME =  country ;

-- Columns
SELECT collation_name
  FROM information_schema.columns
 WHERE TABLE_NAME =  country ;
问题回答

我的两点。 I use utf8_encode()从数据库中输出数据。 这似乎也考虑到其他特点。

1. 使用

&pound;

不是“英镑”的象征,而是:

<%=replace(stringWithPoundInIt,"£","&pound;"%>

我有同样的问题。 在与数据库(PHP)连接之后,我行使了这一权利:

mysql_query("SET NAMES utf8");

希望。

我也存在同样的问题,我在MySQL数据库管理SlectT查询之前,在PHP代码下添加以下内容,从而解决这个问题。

mysql_query("SET character_set_results=utf8", $link);




相关问题
How does gettext handle dynamic content?

In php (or maybe gettext in general), what does gettext do when it sees a variable to dynamic content? I have 2 cases in mind. 1) Let s say I have <?=$user1?> poked John <?=$user2?>. ...

Explain the Need for Mutexes in Locales, Please

Reading the question Why doesn’t C++ STL support atoi(const string& ) like functions?, I encountered a comment which warned that GCC (at least) has a bug that can slow down multi-threaded ...

How does Vistalizer work

How does Vistalizer manage to override the language limit in Windows Vista Home edition. Which api s does it use to allow installation of Multiple language packages.

Localized exceptions (within a Struts2 app)

I am developing a Struts 2 application with support for multiple languages. If one of the domain objects needs to throw an exception, how can it do so in such a way that the error message is no ...

Rails Globalize plugin help

Has anyone gotten the Globalize plugin to work Rails 2.3.2 or later? If so, could you direct me to some useful info?