从MySQL输出的特殊字符工作,但是当我添加charset-utf8它doesnt。为什么? [英] Special characters outputed from MySQL works, but when I add charset-utf8 it doesnt. Why?

查看:128
本文介绍了从MySQL输出的特殊字符工作,但是当我添加charset-utf8它doesnt。为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个网页,需要使用特殊字符Æ,Ø和Å。这些都在UTF-8内。

I'm creating a webpage where I need to use the special characters "Æ", "Ø", and "Å". These are all within UTF-8.

我设置了一个newsfeed,我从MySQL输出文本。我的MySQL表设置为UTF-8,文本工作完美,没有奇怪的字符或任何东西。虽然,在我的页面上的纯HTML,这些字符是有奇怪的迹象,如Ã而不是ø。

I've set up a newsfeed where I output text from MySQL. My MySQL table is set to UTF-8, and the text works perfectly fine, no weird characters or anything. Though, the pure HTML on my page where these characters are there are weird signs like "ø" instead of "ø".

所以我决定添加以下内容我的头:

So I decided to add the following in my head:

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

当然,现在ø输出为ø。虽然,现在我的文本,从MySQL回声响起,并显示问号,如 ,而不是。

Sure, now the "ø" is outputted as an "ø". Though, now my text that is echoed from the MySQL screws up and displays question marks like "�" this instead.

所以我基本上坚持一个选择其中一个显示错误。有任何建议吗?

So I'm basically stuck with a choice of having one of them display wrong. Any suggestions?

网页: http:/ /lasse.orangee.me/o/bestevent/
现在,如果我使用charset = utf8添加元标记,标题文本会正确显示,但左下方的消息无法正确显示。

The webpage: http://lasse.orangee.me/o/bestevent/ Now, if I add the meta tag with charset=utf8 the header text displays correctly, but the news on the bottom left doesn't display correctly.

推荐答案

您需要告诉数据库连接使用UTF-8。
如何做到这一点取决于你的设置,即编程语言。

You need to tell the database connection to use UTF-8. How to do this depends on your setup, i.e. programming language.

这篇关于从MySQL输出的特殊字符工作,但是当我添加charset-utf8它doesnt。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆