1--TEST-- 2IntlChar basic functionality 3--EXTENSIONS-- 4intl 5--FILE-- 6<?php 7 8function unicode_info($cp) { 9 $proplist = array( 10 IntlChar::PROPERTY_ALPHABETIC, 11 ); 12 $methodList = array( 13 'isUAlphabetic', 14 'isUUppercase', 'isupper', 15 'isULowercase', 'islower', 16 'isUWhiteSpace', 'isWhitespace', 17 'istitle', 'isdigit', 'isalpha', 'isalnum', 18 'isxdigit', 'ispunct', 'ispunct', 'isgraph', 19 'isblank', 'isdefined', 'isspace', 'iscntrl', 20 'isMirrored', 'isIDStart', 'isIDPart', 21 'getBlockCode', 'charName', 22 ); 23 24 $ncp = IntlChar::ord($cp); 25 printf("Codepoint U+%04x\n", $ncp); 26 27 foreach($proplist as $prop) { 28 printf(" hasBinaryProperty(%s): %s\n", 29 IntlChar::getPropertyName($prop), 30 IntlChar::hasBinaryProperty($cp, $prop) ? "true" : "false" 31 ); 32 } 33 foreach($methodList as $method) { 34 echo " $method(): "; 35 var_dump(IntlChar::$method($cp)); 36 } 37 echo " charAge(): ", implode('.', IntlChar::charAge($cp)), "\n"; 38 echo "\n"; 39} 40 41printf("Codepoint range: %04x-%04x\n", IntlChar::CODEPOINT_MIN, IntlChar::CODEPOINT_MAX); 42$codepoints = array('P', 0xDF, 0x2603); 43foreach($codepoints as $cp) { 44 unicode_info($cp); 45} 46echo "Sample range of codepoints: U+2600-U+260F\n"; 47IntlChar::enumCharNames(0x2600, 0x2610, function($cp, $nc, $name) { 48 printf("U+%04x %s\n", $cp, $name); 49}); 50echo "RECYCLING SYMBOL FOR TYPE-1 PLASTICS => "; 51var_dump(IntlChar::charFromName("RECYCLING SYMBOL FOR TYPE-1 PLASTICS")); 52?> 53--EXPECT-- 54Codepoint range: 0000-10ffff 55Codepoint U+0050 56 hasBinaryProperty(Alphabetic): true 57 isUAlphabetic(): bool(true) 58 isUUppercase(): bool(true) 59 isupper(): bool(true) 60 isULowercase(): bool(false) 61 islower(): bool(false) 62 isUWhiteSpace(): bool(false) 63 isWhitespace(): bool(false) 64 istitle(): bool(false) 65 isdigit(): bool(false) 66 isalpha(): bool(true) 67 isalnum(): bool(true) 68 isxdigit(): bool(false) 69 ispunct(): bool(false) 70 ispunct(): bool(false) 71 isgraph(): bool(true) 72 isblank(): bool(false) 73 isdefined(): bool(true) 74 isspace(): bool(false) 75 iscntrl(): bool(false) 76 isMirrored(): bool(false) 77 isIDStart(): bool(true) 78 isIDPart(): bool(true) 79 getBlockCode(): int(1) 80 charName(): string(22) "LATIN CAPITAL LETTER P" 81 charAge(): 1.1.0.0 82 83Codepoint U+00df 84 hasBinaryProperty(Alphabetic): true 85 isUAlphabetic(): bool(true) 86 isUUppercase(): bool(false) 87 isupper(): bool(false) 88 isULowercase(): bool(true) 89 islower(): bool(true) 90 isUWhiteSpace(): bool(false) 91 isWhitespace(): bool(false) 92 istitle(): bool(false) 93 isdigit(): bool(false) 94 isalpha(): bool(true) 95 isalnum(): bool(true) 96 isxdigit(): bool(false) 97 ispunct(): bool(false) 98 ispunct(): bool(false) 99 isgraph(): bool(true) 100 isblank(): bool(false) 101 isdefined(): bool(true) 102 isspace(): bool(false) 103 iscntrl(): bool(false) 104 isMirrored(): bool(false) 105 isIDStart(): bool(true) 106 isIDPart(): bool(true) 107 getBlockCode(): int(2) 108 charName(): string(26) "LATIN SMALL LETTER SHARP S" 109 charAge(): 1.1.0.0 110 111Codepoint U+2603 112 hasBinaryProperty(Alphabetic): false 113 isUAlphabetic(): bool(false) 114 isUUppercase(): bool(false) 115 isupper(): bool(false) 116 isULowercase(): bool(false) 117 islower(): bool(false) 118 isUWhiteSpace(): bool(false) 119 isWhitespace(): bool(false) 120 istitle(): bool(false) 121 isdigit(): bool(false) 122 isalpha(): bool(false) 123 isalnum(): bool(false) 124 isxdigit(): bool(false) 125 ispunct(): bool(false) 126 ispunct(): bool(false) 127 isgraph(): bool(true) 128 isblank(): bool(false) 129 isdefined(): bool(true) 130 isspace(): bool(false) 131 iscntrl(): bool(false) 132 isMirrored(): bool(false) 133 isIDStart(): bool(false) 134 isIDPart(): bool(false) 135 getBlockCode(): int(55) 136 charName(): string(7) "SNOWMAN" 137 charAge(): 1.1.0.0 138 139Sample range of codepoints: U+2600-U+260F 140U+2600 BLACK SUN WITH RAYS 141U+2601 CLOUD 142U+2602 UMBRELLA 143U+2603 SNOWMAN 144U+2604 COMET 145U+2605 BLACK STAR 146U+2606 WHITE STAR 147U+2607 LIGHTNING 148U+2608 THUNDERSTORM 149U+2609 SUN 150U+260a ASCENDING NODE 151U+260b DESCENDING NODE 152U+260c CONJUNCTION 153U+260d OPPOSITION 154U+260e BLACK TELEPHONE 155U+260f WHITE TELEPHONE 156RECYCLING SYMBOL FOR TYPE-1 PLASTICS => int(9843) 157