1--TEST--
2UConverter::convert() w/ Callback Reasons
3--SKIPIF--
4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5<?php if (version_compare(INTL_ICU_VERSION, '60.1') < 0) die('skip for ICU >= 60.1'); ?>
6--FILE--
7<?php
8class MyConverter extends UConverter {
9  /**
10   * Called during conversion from source encoding to internal UChar representation
11   */
12  public function toUCallback($reason, $source, $codeUnits, &$error) {
13    echo "toUCallback(", UConverter::reasonText($reason), ", ...)\n";
14    return parent::toUCallback($reason, $source, $codeUnits, $error);
15  }
16
17  /**
18   * Called during conversion from internal UChar to destination encoding
19   */
20  public function fromUCallback($reason, $source, $codePoint, &$error) {
21    echo "fromUCallback(", UConverter::reasonText($reason), ", ...)\n";
22    return parent::fromUCallback($reason, $source, $codePoint, $error);
23  }
24
25}
26
27$c = new MyConverter('ascii', 'utf-8');
28foreach(array("regular", "irregul\xC1\xA1r", "\xC2\xA1unsupported!") as $word) {
29  $c->convert($word);
30}
31--EXPECT--
32toUCallback(REASON_RESET, ...)
33toUCallback(REASON_RESET, ...)
34fromUCallback(REASON_RESET, ...)
35fromUCallback(REASON_RESET, ...)
36toUCallback(REASON_RESET, ...)
37toUCallback(REASON_ILLEGAL, ...)
38toUCallback(REASON_ILLEGAL, ...)
39toUCallback(REASON_RESET, ...)
40toUCallback(REASON_ILLEGAL, ...)
41toUCallback(REASON_ILLEGAL, ...)
42fromUCallback(REASON_RESET, ...)
43fromUCallback(REASON_UNASSIGNED, ...)
44fromUCallback(REASON_UNASSIGNED, ...)
45fromUCallback(REASON_RESET, ...)
46fromUCallback(REASON_UNASSIGNED, ...)
47fromUCallback(REASON_UNASSIGNED, ...)
48toUCallback(REASON_RESET, ...)
49toUCallback(REASON_RESET, ...)
50fromUCallback(REASON_RESET, ...)
51fromUCallback(REASON_UNASSIGNED, ...)
52fromUCallback(REASON_RESET, ...)
53fromUCallback(REASON_UNASSIGNED, ...)
54toUCallback(REASON_CLOSE, ...)
55fromUCallback(REASON_CLOSE, ...)
56toUCallback(REASON_CLOSE, ...)
57fromUCallback(REASON_CLOSE, ...)
58