Unicode在PHP中? [英] Unicode in PHP?

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

问题描述

我听说PHP有非常差的Unicode支持。
那么在PHP 5.3+下支持PHP 5构建的应用程序Unicode需要什么呢?
mbstring是唯一的选择吗?
Facebook或Yahoo如何解决这个PHP限制?

解决方案

PHP没有低级别的支持对于任何编码。但实际上这意味着它不关心语言级别。 PHP中的字符串是原始字节序列,可以是您喜欢的任何编码。当处理多字节字符串时,您需要注意使用正确的字符串操作功能,而不是直接用字节流来拧紧字符串。所以Unicode的唯一不支持是它不包括编码到核心语言本身的概念,但是您仍然可以通过使用适当的字符串函数操纵字符串来完美地处理任何编码。



其实,如果你只是小心谨慎地保持UTF-8的一切,那么你几乎不用担心任何关于编码的事情。 PHP可以使用Unicode。



有关此主题的广泛报道,请参阅


I heard PHP has very poor Unicode support. So what does it take to make a PHP 5 built application Unicode supported under PHP 5.3+? Would mbstring be the only option here? How has Facebook or Yahoo gotten around this PHP limitation?

解决方案

PHP has no low-level support for any encoding. But all that actually means is that it doesn't care on a language level. Strings in PHP are raw byte sequences, which can be in any encoding you like. When handling multi-byte strings, you need to take care to use the right string manipulation function instead of possibly screwing with the byte stream directly. So the only "non-support" of Unicode is that it doesn't include the concept of encodings into the core language itself, but you can still work with any encoding perfectly fine by manipulating strings using the appropriate string function.

Actually, if you just take a little care to keep everything in UTF-8 all the time, you will rarely have to worry about anything regarding encodings. PHP works just fine with Unicode.

For extensive coverage of this topic, please see What Every Programmer Absolutely, Positively Needs To Know About Encodings And Character Sets To Work With Text.

这篇关于Unicode在PHP中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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