字符编码,UTF或ANSI? [英] Character Encoding, UTF or ANSI?

查看:153
本文介绍了字符编码,UTF或ANSI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Ubuntu中使用Eclipse编辑PHP文件。

I'm using Eclipse in Ubuntu to edit PHP files.

但是,不幸的是,其中一些PHP文件是在Windows XP中的Notepad ++中创建的,

But, unfortunately, some of these PHP files were created in Notepad++ in Windows XP, with ANSI encoding defined.

此外,这些文件会生成包含charset = ISO-8859-1的HTML代码。

Also, these files generates HTML codes with charset=ISO-8859-1.

配置的Eclipse到ISO-8859-1,许多特殊字符丢失并更改为'???',当我尝试保存文件与ISO enconding,Eclipse显示一个错误,是不可能保存文件,因为一些字符

When I configured Eclipse to ISO-8859-1, many special characters were lost and changed to '???', and when I try to save a file with ISO enconding, Eclipse displays an error that was not possible to save the file because some characters aren't compatible with the charset.

如何在不更改编码的情况下保存这些文件,或者如何在不丢失字符的情况下更改编码。

How can I save these files without changing the encoding, or how can I change the encoding without lose characters.

推荐答案

为此,您需要使用 ANSI 编码,然后使用 ISO-8859-1 编码这些文件。在记事本++中,您可以通过格式菜单选项更改编码。不幸的是,没有 ISO-8859-1 选项,但 UTF-8 应该已经足够,现在也是世界统治,因为 ISO-8859-1 编码只涵盖拉丁字符,而不是西里尔语,希腊语,中文,阿拉伯语等。

To the point, you need to read those files using ANSI encoding and then write those files using ISO-8859-1 encoding. In Notepad++ you can change the encoding by Format menu option. Unfortunately there's no ISO-8859-1 option, but UTF-8 should suffice and is nowadays also the preferred choice for world domination since the ISO-8859-1 encoding only covers latin characters, not for example Cyrillic, Greek, Chinese, Arabic, etcetera.

这篇关于字符编码,UTF或ANSI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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