1--TEST--
2UConverter::convert() w/ Callback Return Values
3--SKIPIF--
4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5--FILE--
6<?php
7class MyConverter extends UConverter {
8  public function toUCallback($reason, $source, $codeUnits, &$error) {
9    $error = U_ZERO_ERROR;
10    switch ($codeUnits) {
11      case "\x80": return NULL;
12      case "\x81": return 'a';
13      case "\x82": return ord('b');
14      case "\x83": return array('c');
15    }
16  }
17
18  /**
19   * Called during conversion from internal UChar to destination encoding
20   */
21  public function fromUCallback($reason, $source, $codePoint, &$error) {
22    $error = U_ZERO_ERROR;
23    switch ($codePoint) {
24      case 0x00F1: return "A";
25      case 0x00F2: return ord("B");
26      case 0x00F3: return array("C");
27      case 0x00F4: return NULL;
28    }
29  }
30
31}
32
33$c = new MyConverter('ascii', 'utf-8');
34// This line will trigger toUCallback
35var_dump($c->convert("\x80\x81\x82\x83"));
36// This line will trigger fromUCallback
37var_dump($c->convert("\xC3\xB1\xC3\xB2\xC3\xB3\xC3\xB4"));
38--EXPECT--
39string(3) "abc"
40string(3) "ABC"
41