PHP 8.3.4 Released!

IntlChar::charDigitValue

(PHP 7, PHP 8)

IntlChar::charDigitValue10進数の桁の文字を桁の値として取得する

説明

public static IntlChar::charDigitValue(int|string $codepoint): ?int

10進数の桁の文字を、桁の値として取得します。

対象となる文字は、一般カテゴリ "Nd" (decimal digit numbers) と a Numeric_Type of Decimal に属するものです。

パラメータ

codepoint

コードポイントを表す int 型の値 (例: U+2603 SNOWMAN を表す 0x2603)、あるいは UTF-8 文字列としてエンコードされた文字 (例: "\u{2603}")。

戻り値

codepoint の10進数の桁の値を返します。 10進数の桁の文字でない場合は、-1 を返します。 失敗した場合は、null を返します。

例1 さまざまなコードポイントの例

<?php
var_dump
(IntlChar::charDigitValue("1"));
var_dump(IntlChar::charDigitValue("\u{0662}"));
var_dump(IntlChar::charDigitValue("\u{0E53}"));
?>

上の例の出力は以下となります。

int(1)
int(2)
int(3)

参考

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top