mb_ord
(PHP 7 >= 7.2.0, PHP 8)
mb_ord — Get Unicode code point of character
说明
mb_ord
( string
$string
, string|null $encoding
= null
) : int|falseReturns the Unicode code point value of the given character.
This function complements mb_chr().
参数
-
string
-
A string
-
encoding
-
encoding
参数为字符编码。如果省略或是null
,则使用内部字符编码。
返回值
The Unicode code point for the first character of string
或者在失败时返回 false
.
范例
<?php
var_dump(mb_ord("A", "UTF-8"));
var_dump(mb_ord("🐘", "UTF-8"));
var_dump(mb_ord("\x80", "ISO-8859-1"));
var_dump(mb_ord("\x80", "Windows-1252"));
?>
以上例程会输出:
int(65)
int(128024)
int(128)
int(8364)
更新日志
版本 | 说明 |
---|---|
8.0.0 |
现在 encoding 可以为 null。
|
参见
- mb_internal_encoding() - 设置/获取内部字符编码
- mb_chr() - Return character by Unicode code point value
- IntlChar::ord() - Return Unicode code point value of character
- ord() - 转换字符串第一个字节为 0-255 之间的值