1--TEST-- 2IntlChar basic functionality 3--SKIPIF-- 4<?php if (!extension_loaded('intl')) die("skip requires ext/intl") ?> 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--EXPECT-- 53Codepoint range: 0000-10ffff 54Codepoint U+0050 55 hasBinaryProperty(Alphabetic): true 56 isUAlphabetic(): bool(true) 57 isUUppercase(): bool(true) 58 isupper(): bool(true) 59 isULowercase(): bool(false) 60 islower(): bool(false) 61 isUWhiteSpace(): bool(false) 62 isWhitespace(): bool(false) 63 istitle(): bool(false) 64 isdigit(): bool(false) 65 isalpha(): bool(true) 66 isalnum(): bool(true) 67 isxdigit(): bool(false) 68 ispunct(): bool(false) 69 ispunct(): bool(false) 70 isgraph(): bool(true) 71 isblank(): bool(false) 72 isdefined(): bool(true) 73 isspace(): bool(false) 74 iscntrl(): bool(false) 75 isMirrored(): bool(false) 76 isIDStart(): bool(true) 77 isIDPart(): bool(true) 78 getBlockCode(): int(1) 79 charName(): string(22) "LATIN CAPITAL LETTER P" 80 charAge(): 1.1.0.0 81 82Codepoint U+00df 83 hasBinaryProperty(Alphabetic): true 84 isUAlphabetic(): bool(true) 85 isUUppercase(): bool(false) 86 isupper(): bool(false) 87 isULowercase(): bool(true) 88 islower(): bool(true) 89 isUWhiteSpace(): bool(false) 90 isWhitespace(): bool(false) 91 istitle(): bool(false) 92 isdigit(): bool(false) 93 isalpha(): bool(true) 94 isalnum(): bool(true) 95 isxdigit(): bool(false) 96 ispunct(): bool(false) 97 ispunct(): bool(false) 98 isgraph(): bool(true) 99 isblank(): bool(false) 100 isdefined(): bool(true) 101 isspace(): bool(false) 102 iscntrl(): bool(false) 103 isMirrored(): bool(false) 104 isIDStart(): bool(true) 105 isIDPart(): bool(true) 106 getBlockCode(): int(2) 107 charName(): string(26) "LATIN SMALL LETTER SHARP S" 108 charAge(): 1.1.0.0 109 110Codepoint U+2603 111 hasBinaryProperty(Alphabetic): false 112 isUAlphabetic(): bool(false) 113 isUUppercase(): bool(false) 114 isupper(): bool(false) 115 isULowercase(): bool(false) 116 islower(): bool(false) 117 isUWhiteSpace(): bool(false) 118 isWhitespace(): bool(false) 119 istitle(): bool(false) 120 isdigit(): bool(false) 121 isalpha(): bool(false) 122 isalnum(): bool(false) 123 isxdigit(): bool(false) 124 ispunct(): bool(false) 125 ispunct(): bool(false) 126 isgraph(): bool(true) 127 isblank(): bool(false) 128 isdefined(): bool(true) 129 isspace(): bool(false) 130 iscntrl(): bool(false) 131 isMirrored(): bool(false) 132 isIDStart(): bool(false) 133 isIDPart(): bool(false) 134 getBlockCode(): int(55) 135 charName(): string(7) "SNOWMAN" 136 charAge(): 1.1.0.0 137 138Sample range of codepoints: U+2600-U+260F 139U+2600 BLACK SUN WITH RAYS 140U+2601 CLOUD 141U+2602 UMBRELLA 142U+2603 SNOWMAN 143U+2604 COMET 144U+2605 BLACK STAR 145U+2606 WHITE STAR 146U+2607 LIGHTNING 147U+2608 THUNDERSTORM 148U+2609 SUN 149U+260a ASCENDING NODE 150U+260b DESCENDING NODE 151U+260c CONJUNCTION 152U+260d OPPOSITION 153U+260e BLACK TELEPHONE 154U+260f WHITE TELEPHONE 155RECYCLING SYMBOL FOR TYPE-1 PLASTICS => int(9843) 156