本文介绍了PHP函数iconv字符编码从iso-8859-1到utf-8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将字符串从iso-8859-1转换为utf-8.但是当我找到这两个字符€和•函数返回时一个内有两个数字的正方形的字符.

I'm trying to convert a string from iso-8859-1 to utf-8.But when I find these two charachter € and • the function returnsa charachter that is a square with two number inside.

我该如何解决这个问题?

How can I solve this issue?

推荐答案

我认为您要查找的编码是 Windows代码页1252 (西欧).它与ISO-8859-1(或8859-15)不同; 0xA0-0xFF范围内的字符与8859-1匹配,但是cp1252在0x80-0x9F范围内添加了一系列额外的字符,其中ISO-8859-1分配了很少使用的控制代码.

I think the encoding you are looking for is Windows code page 1252 (Western European). It is not the same as ISO-8859-1 (or 8859-15 for that matter); the characters in the range 0xA0-0xFF match 8859-1, but cp1252 adds an assortment of extra characters in the range 0x80-0x9F where ISO-8859-1 assigns little-used control codes.

之所以会造成混乱,是因为出于历史原因,当您将页面用作text/html;charset=iso-8859-1时,浏览器实际上 使用cp1252(因此也会在cp1252中提交表单).

The confusion comes about because when you serve a page as text/html;charset=iso-8859-1, for historical reasons, browsers actually use cp1252 (and will hence submit forms in cp1252 too).

iconv('cp1252', 'utf-8', "\x80 and \x95")
-> "\xe2\x82\xac and \xe2\x80\xa2"

这篇关于PHP函数iconv字符编码从iso-8859-1到utf-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 21:10