1--TEST--
2normalizer_get_raw_decomposition()
3--EXTENSIONS--
4intl
5--SKIPIF--
6<?php if( !function_exists( 'normalizer_get_raw_decomposition' ) ) print 'skip normalizer_get_raw_decomposition function does not exist'; ?>
7--FILE--
8<?php
9
10/*
11 * Try getting raw decomposition mappings
12 * with procedural and class methods.
13 */
14
15function ut_main()
16{
17    $result = '';
18    $strings = [
19        "a",
20        "\u{FFDA}",
21        "\u{FDFA}",
22        "",
23        "aa",
24        "\xF5",
25    ];
26
27    foreach ($strings as $string) {
28        $decomposition = ut_norm_get_raw_decomposition($string, Normalizer::FORM_KC);
29        $error_code = intl_get_error_code();
30        $error_message = intl_get_error_message();
31
32        $string_hex = bin2hex($string);
33        $result .= "---------------------\n";
34
35        if ($decomposition === null) {
36            $result .= "'$string_hex' has no decomposition mapping\n" ;
37        } else {
38            $result .= "'$string_hex' has the decomposition mapping '" . bin2hex($decomposition) . "'\n" ;
39        }
40        $result .= "error info: '$error_message' ($error_code)\n";
41    }
42
43    return $result;
44}
45
46include_once( 'ut_common.inc' );
47ut_run();
48
49?>
50--EXPECT--
51---------------------
52'61' has no decomposition mapping
53error info: 'U_ZERO_ERROR' (0)
54---------------------
55'efbf9a' has the decomposition mapping 'e385a1'
56error info: 'U_ZERO_ERROR' (0)
57---------------------
58'efb7ba' has the decomposition mapping 'd8b5d984d98920d8a7d984d984d98720d8b9d984d98ad98720d988d8b3d984d985'
59error info: 'U_ZERO_ERROR' (0)
60---------------------
61'' has no decomposition mapping
62error info: 'Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR' (1)
63---------------------
64'6161' has no decomposition mapping
65error info: 'Input string must be exactly one UTF-8 encoded code point long.: U_ILLEGAL_ARGUMENT_ERROR' (1)
66---------------------
67'f5' has no decomposition mapping
68error info: 'Code point out of range: U_ILLEGAL_ARGUMENT_ERROR' (1)
69