1--TEST-- 2normalize() NFKC_Casefold 3--EXTENSIONS-- 4intl 5--SKIPIF-- 6<?php if (!defined('Normalizer::FORM_KC_CF')) print 'skip Normalizer::FORM_KC_CF constant not defined'; ?> 7--FILE-- 8<?php 9 10/* 11 * Try normalization and test normalization 12 * with Procedural and Object methods. 13 */ 14 15function ut_main() 16{ 17 $res_str = ''; 18 19 $forms = array( 20 Normalizer::FORM_KC_CF, 21 ); 22 23 $forms_str = array ( 24 Normalizer::FORM_KC_CF => 'UNORM_FORM_KC_CF', 25 ); 26 27 /* just make sure all the form constants are defined as in the api spec */ 28 if (Normalizer::FORM_C != Normalizer::NFC) { 29 $res_str .= "Invalid normalization form declarations!\n"; 30 } 31 32 $char_a_diaeresis = "\xC3\xA4"; // 'LATIN SMALL LETTER A WITH DIAERESIS' (U+00E4) 33 $char_a_ring = "\xC3\xA5"; // 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) 34 $char_o_diaeresis = "\xC3\xB6"; // 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) 35 36 $char_angstrom_sign = "\xE2\x84\xAB"; // 'ANGSTROM SIGN' (U+212B) 37 $char_A_ring = "\xC3\x85"; // 'LATIN CAPITAL LETTER A WITH RING ABOVE' (U+00C5) 38 39 $char_ohm_sign = "\xE2\x84\xA6"; // 'OHM SIGN' (U+2126) 40 $char_omega = "\xCE\xA9"; // 'GREEK CAPITAL LETTER OMEGA' (U+03A9) 41 42 $char_combining_ring_above = "\xCC\x8A"; // 'COMBINING RING ABOVE' (U+030A) 43 44 $char_fi_ligature = "\xEF\xAC\x81"; // 'LATIN SMALL LIGATURE FI' (U+FB01) 45 46 $char_long_s_dot = "\xE1\xBA\x9B"; // 'LATIN SMALL LETTER LONG S WITH DOT ABOVE' (U+1E9B) 47 48 $strs = array( 49 'ABC', 50 'abc', 51 $char_a_diaeresis . '||' . $char_a_ring . '||' . $char_o_diaeresis, 52 $char_angstrom_sign . '||' . $char_A_ring . '||' . 'A' . $char_combining_ring_above, 53 $char_ohm_sign . '||' . $char_omega, 54 $char_fi_ligature, 55 $char_long_s_dot, 56 ); 57 58 foreach( $forms as $form ) 59 { 60 foreach( $strs as $str ) 61 { 62 $str_norm = ut_norm_normalize( $str, $form ); 63 $error_code = intl_get_error_code(); 64 $error_message = intl_get_error_message(); 65 66 $str_hex = urlencode($str); 67 $str_norm_hex = urlencode($str_norm); 68 $res_str .= "'$str_hex' normalized to form '{$forms_str[$form]}' is '$str_norm_hex'" 69 . "\terror info: '$error_message' ($error_code)\n" 70 . ""; 71 72 $is_norm = ut_norm_is_normalized( $str, $form ); 73 $error_code = intl_get_error_code(); 74 $error_message = intl_get_error_message(); 75 76 $res_str .= " is in form '{$forms_str[$form]}'? = " . ($is_norm ? "yes" : "no") 77 . "\terror info: '$error_message' ($error_code)\n" 78 . ""; 79 } 80 } 81 82 return $res_str; 83} 84 85include_once( 'ut_common.inc' ); 86ut_run(); 87 88?> 89--EXPECT-- 90'ABC' normalized to form 'UNORM_FORM_KC_CF' is 'abc' error info: 'U_ZERO_ERROR' (0) 91 is in form 'UNORM_FORM_KC_CF'? = no error info: 'U_ZERO_ERROR' (0) 92'abc' normalized to form 'UNORM_FORM_KC_CF' is 'abc' error info: 'U_ZERO_ERROR' (0) 93 is in form 'UNORM_FORM_KC_CF'? = yes error info: 'U_ZERO_ERROR' (0) 94'%C3%A4%7C%7C%C3%A5%7C%7C%C3%B6' normalized to form 'UNORM_FORM_KC_CF' is '%C3%A4%7C%7C%C3%A5%7C%7C%C3%B6' error info: 'U_ZERO_ERROR' (0) 95 is in form 'UNORM_FORM_KC_CF'? = yes error info: 'U_ZERO_ERROR' (0) 96'%E2%84%AB%7C%7C%C3%85%7C%7CA%CC%8A' normalized to form 'UNORM_FORM_KC_CF' is '%C3%A5%7C%7C%C3%A5%7C%7C%C3%A5' error info: 'U_ZERO_ERROR' (0) 97 is in form 'UNORM_FORM_KC_CF'? = no error info: 'U_ZERO_ERROR' (0) 98'%E2%84%A6%7C%7C%CE%A9' normalized to form 'UNORM_FORM_KC_CF' is '%CF%89%7C%7C%CF%89' error info: 'U_ZERO_ERROR' (0) 99 is in form 'UNORM_FORM_KC_CF'? = no error info: 'U_ZERO_ERROR' (0) 100'%EF%AC%81' normalized to form 'UNORM_FORM_KC_CF' is 'fi' error info: 'U_ZERO_ERROR' (0) 101 is in form 'UNORM_FORM_KC_CF'? = no error info: 'U_ZERO_ERROR' (0) 102'%E1%BA%9B' normalized to form 'UNORM_FORM_KC_CF' is '%E1%B9%A1' error info: 'U_ZERO_ERROR' (0) 103 is in form 'UNORM_FORM_KC_CF'? = no error info: 'U_ZERO_ERROR' (0) 104