PHP函数iconv字符编码从iso-8859-1到utf-8 [英] PHP function iconv character encoding from iso-8859-1 to utf-8

查看:460
本文介绍了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 returns a charachter that is a square with two number inside.

我该如何解决这个问题?

How can I solve this issue?

推荐答案

我认为您要查找的编码是

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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