字符串的序数是什么? [英] What is an ordinal value of a String?
问题描述
我对php文档中字符或字符串的序数值感到困惑. 有人可以告诉我什么是序数值吗?
I'm confused about the term Ordinal value of a character or a string in php documentation. Can somebody tell me what exactly an ordinal value is?
推荐答案
PHP中的一个字符"是一个 byte .请注意,这会误导多字节字符,其中一个字符(例如汉")被编码为多个字节.无论如何,字节是8位,可以表示0到255之间的数字. character 字节的序数就是这个数值.
One "character" in PHP is one byte. Note that this is misleading for multi-byte characters, in which one character (say "漢") is encoded in multiple bytes. Anyway though, a byte is 8 bits and can represent a number between 0 and 255. The ordinal value of a character byte is simply this numerical value.
ord('a') -> 97
如果需要有关字节/字符/编码的更多背景信息,请阅读 http://kunststube.net/encoding .
Read http://kunststube.net/encoding if you need more background information about bytes/characters/encodings.
这篇关于字符串的序数是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!