请问,用于php字符串的默认字符编码是什么?是UTF8吗? [英] Please, what is the default character encoding used for php string? Is it UTF8?

查看:308
本文介绍了请问,用于php字符串的默认字符编码是什么?是UTF8吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于php字符串的默认字符编码是什么?是UTF8吗?

What is the default character encoding used for php string? Is it UTF8?

推荐答案

请参阅: PHP:字符编码 - 手册 [ ^ ] 。



这并不像看起来那么简单;而且,与此同时,它不会产生任何问题。你是什​​么意思PHP?这不是标准语言。所有这些都基于这样的PHP权限,如 PHP:Hypertext Preprocessor [ ^ ]。如果您也从相同的源代码下载PHP,您可以确定它,但是什么阻止任何其他方提供PHP的替代实现?



这是事情:它并不重要。 Unicode是Unicode,它不是UTF-8,UTF-16LE或UTF-32。 Unicode是从编码或任何计算机数据表示中抽象出来的。它简单地将字符之间的映射定义为纯文化实体,并将代码点理解为抽象整数,因为它们在数学中被理解。这些数字如何在某些计算机内存,变量,网络/文件流中表示,以UTF定义。现在,你必须明白正确使用编程不应该基于程序变量/成员/对象访问的内存中Unicode表示的知识。文本数据可以来自不同的来源。该程序可能或可能不是基于数据附带的一些元数据。例如,XML编码附带 XML prolog ,HTML编码附带HTTP-EQUIV内容类型声明(我总是重复使用HTTP-EQUIV甚至是至关重要的如果将encoding设置为HTTP服务器的默认值;请想一想:如果页面保存在文件中会发生什么?)。这些数据会进入PHP数据,您应该使用适当的PHP函数处理这些数据,而不知道代码点是如何编码的。例如,如果在字符串中找到子字符串,则源字符串和子字符串都以相同的编码表示;这一切都很重要。



-SA
Please see: PHP: Character Encoding — Manual[^].

This is not so simple as it may seem; and, at the same time, it does not create any problems. What do you mean by "PHP"? This is not a standard language. All such things are based on such PHP authority as PHP: Hypertext Preprocessor[^]. If you also download PHP from the same source, you can be certain about it, but what prevents any other party from providing some alternative implementation of PHP?

Here is the thing: it is not really important. Unicode is Unicode, it is not UTF-8, UTF-16LE or UTF-32. Unicode is abstracted from encoding or any computer representation of data. It simply define mapping between characters as pure cultural entities, and code points understood as abstract integer number as they are understood in mathematics. How those numbers are represented in some computer memory, variables, network/file streams, is defined in UTFs. And now, you have to understand that correct use of programming should not be based on the knowledge of the representation of Unicode in memory accessed by program variables/members/objects. The text data can come from different sources. The program may or may not be based on some metadata which comes with data. For example, XML encoding comes with XML prolog, and HTML encoding comes with HTTP-EQUIV "content-type" declaration (I always repeat that using HTTP-EQUIV is critically important even if encoding is set as the HTTP server's default; think at this: what happens if the page is saved in a file?). This data goes into the PHP data, which you should process using appropriate PHP functions, without knowing how the code points are encoding. For example, if you find a sub-string in a string, both source string and sub-string are represented in the same encoding; this is all that matters.

—SA


这篇关于请问,用于php字符串的默认字符编码是什么?是UTF8吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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