Get Unicode code point of character

mb_ord

(PHP 7 >= 7.2.0, PHP 8)

mb_ordGet Unicode code point of character

說明

mb_ord(string $string, ?string $encoding = null): int|false

Returns 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.

更新日誌

版本 說明
8.0.0 現在 encoding 可以為 null。

範例

<?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)

參見

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *