Skip to content
Related Articles

Related Articles

PHP | IntlChar enumCharNames() Function

View Discussion
Improve Article
Save Article
  • Last Updated : 28 Jul, 2022
View Discussion
Improve Article
Save Article

The IntlChar::enumCharNames() function is an inbuilt function in PHP which is used to give a catalog of all the assigned Unicode characters that are available within a range. The list will have the Unicode characters that are available between the start code points (start inclusive) and the limit code points (limit exclusive). A function is going to be called for each and the code point value will be passed on along with the character name. Those who are different from the new & modern names, only those will get cataloged, for Unicode 1.0 names.
Syntax: 

void IntlChar::enumCharNames( $start, $limit, $callback,
$nameChoice = IntlChar::UNICODE_CHAR_NAME )  

Parameters: This function accepts four parameters as mentioned and described below: 

  • start: This parameter holds the first code point in the enumeration range.
  • limit: This parameter holds the one more than the last point in the range.
  • callback: For each character name the function that is supposed to be called. This function accepts three parameters which are listed below: 
    • $codepoint: It holds the value of numeric code point.
    • $nameChoice: It holds the value of nameChoice.
    • $name: It holds the name of the character.
  • nameChoice: The kinds of name, that has to be enumerated. It could be any of these five given constants: 
    • IntlChar::UNICODE_CHAR_NAME (the default constant)
    • IntlChar::CHAR_NAME_ALIAS
    • IntlChar::CHAR_NAME_CHOICE_COUNT
    • IntlChar::EXTENDED_CHAR_NAME
    • IntlChar::UNICODE_10_CHAR_NAME

Return Values: This function does not return any value.
Below program illustrates the IntlChar::enumCharNames() function in PHP:
Program: 

php




<?php
 
// PHP program to uses IntlChar::enumCharNames()
// function
IntlChar::enumCharNames(0x2700, 0x2710,
    function($codepoint, $nameChoice, $name) {
        printf("U+%04x %s\n", $codepoint, $name);
});
 
?>

Output: 

U+2700 BLACK SAFETY SCISSORS
U+2701 UPPER BLADE SCISSORS
U+2702 BLACK SCISSORS
U+2703 LOWER BLADE SCISSORS
U+2704 WHITE SCISSORS
U+2705 WHITE HEAVY CHECK MARK
U+2706 TELEPHONE LOCATION SIGN
U+2707 TAPE DRIVE
U+2708 AIRPLANE
U+2709 ENVELOPE
U+270a RAISED FIRST
U+270b RAISED HAND
U+270c VICTORY HAND
U+270d WRITING HAND
U+270e LOWER RIGHT PENCIL
U+270f PENCIL

Reference: https://www.php.net/manual/en/intlchar.enumcharnames.php

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!