开发者

Native Encode Support

A simple and stupid question that im wondering.

I saw in the PHP Manul that PHP only supports a 256-character set. But is not specified if is the ASCII code.

From the PHP manual i found This page That confuse me more.

I wanna know if depends of the operating syst开发者_JAVA技巧em.

Native support from PHP are the ASCII code? One document that stipulate it?

What about This Encode supports?


PHP uses ASCI characters each of a byte containing 8 bit. That's all.

PHP doesn't care about the interpretation of each byte, it just reads from a source or writes to a sink.

To which specific code-page these bytes belong doesn't matter. PHP doesn't care about it.

If your PHP-Script interacts with a web-server, each page should contain a hint, which defines the correct interpreation in the <head> of a <html> page:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

The above declaration defines, that the characters of the HTML-page should be interpreted as ISO Latin-1 codes. Additionally, if the page sends back characters to the PHP-script, the browser sends them as ISO Latin-1 encoded ASCII characters.

If you forget to define a Content-Type, it's up to the browser to use a code page / text encoding.

That said, you are free to use any ASCII text-encoding that best fits your needs. But never forget to set a Content-Type in a web-page.

Extensions like iconv help out, in case you need to process e.g. UTF-8 characters.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜