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