如何处理外语? [英] How to handle with foreign languages?

查看:169
本文介绍了如何处理外语?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个巴西网站,该网站必须支持外部字符,如á,à,ó,íú,ê等等。它也使用AJAX,所以我认为最好使用charset UTF-8 '因为我总是得到 字符,我不知道如何解决这个问题。



当使用 UTF-8 (因为它正在查询数据库来渲染整个菜单)时,我的导航菜单正确显示,但我不不知道它是如何做的。以下是数据库的一些截图以及它如何呈现:



目前为止这么好。麻烦的是,我开始使用Zend_Navigation来渲染面包屑,我不知道该怎么做才能得到我得到的 字符:



我该怎么办?将字符集更改为ISO-8858-1?我已经这样做了,但它看起来像这样一切都是错误的:





编辑



另外,当我将它改为 miss& atilde; o 例如它显示 miss& atilde; o 而不是missão。此外,我不能手动改变它,因为它在数据库中,我需要一个函数来处理这个



编辑2



我将数据库中的特殊字符(如çã)更改为& ccedil;& atilde; 现在HTML呈现正常。虽然,我将Zend_Navigation用于breadcrumb,并且它的渲染 miss& atilde; o 而不是missão就像这样:





我还使用Zend_Config_Writer_Xml编写了一个XML文件,并且我看到它打印了< label> Informa&#xE7;&#xF5; es< / label> 而不是< label>信息< / label> 。以防万一,有助于



我该如何继续?

这是一篇非常好的文章,帮助我开始Web开发。我在多语言环境中工作,所以我经常碰到这种东西(只是为了增加文章的优点)。

绝对最低限度每个软件开发人员绝对积极地必须了解Unicode和字符集(没有借口!)



我总是确保我的文件以UTF8行编码保存,我的PHP头文件将字符集声明为utf8,我的数据库使用utf8_general_ci进行排序,并且我的html头标记包含元标签声明内容为utf8。我认为这涵盖了它。



HTH:)

编辑:只需添加(更加旨在你的具体问题)检查你的PHP代码是否将你的结果视为utf8。数据可能会正确存储在数据库中,但可以在服务时进行转换。


I'm developing a brazilian website which has to support foreign characters like á, à, ó, í ú, ê, etc. It also uses AJAX so I thought better to use charset UTF-8 'cause I always get the � character and I don't know how to fix this.

My navigation menu appears correctly when using UTF-8 (since it's querying the database to render the whole menu), but I don't know how it does. Here are some screenshots of the database and how it renders:

So far so good. The trouble is that I started using Zend_Navigation for rendering breadcrumbs and I don't know what to do to get over with the � character i'm getting:

What should I do? Change the charset to ISO-8858-1? I have already done this but it appears everything wrong like this:

EDIT

In addition, when I change it to miss&atilde;o for example it displays miss&atilde;o instead of missão. Besides, I can't change it manually 'cause it is in the database, I need sort of a function which will handle this

EDIT 2

I changed the special character in my database like çã to &ccedil;&atilde; and now the HTML is rendering fine. Although, I'm using the Zend_Navigation for breadcrumb and it's rendering miss&atilde;o instead of missão just like this:

I also wrote a XML file using Zend_Config_Writer_Xml and I see it printed <label>Informa&#xE7;&#xF5;es</label> instead of <label>Informações</label>. Just in case that helps

How should I proceed?

解决方案

Here's a really good article that helped me when I started web development. I work in a multilingual environment so I bump into this stuff constantly (just to add to how great the article was :)

The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

I always make sure that my files are saved in UTF8 line encoding, that my php header files declare the charset as utf8, that my db uses utf8_general_ci for it's collation, and that my html head tag contains the meta tag declaring the content as utf8. I think that covers it.

HTH :)

edit: just to add (to be more aimed at your specific problem) check to see if your PHP code treats your results as utf8. The data might be stored correctly on the DB but could be converted when it's being served.

这篇关于如何处理外语?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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