1--TEST--
2mysqli_real_escape_string() - big5
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once __DIR__ . '/test_setup/test_helpers.inc';
8$link = mysqli_connect_or_skip();
9if (!mysqli_set_charset($link, 'big5'))
10    die(sprintf("skip Cannot set charset 'big5'"));
11?>
12--FILE--
13<?php
14    require_once 'connect.inc';
15
16    if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
17{
18        printf("[001] Cannot connect to the server using host=%s, user=%s,
19passwd=***, dbname=%s, port=%s, socket=%s - [%d] %s\n", $host, $user, $db,
20$port, $socket, mysqli_connect_errno(), mysqli_connect_error());
21    }
22
23    if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
24        printf("Failed to drop old test table: [%d] %s\n", mysqli_errno($link),
25mysqli_error($link));
26    }
27
28    if (!mysqli_query($link, 'CREATE TABLE test(id INT, label CHAR(1), PRIMARY
29KEY(id)) ENGINE=' . $engine . " DEFAULT CHARSET=big5")) {
30        printf("Failed to create test table: [%d] %s\n", mysqli_errno($link),
31mysqli_error($link));
32    }
33
34    var_dump(mysqli_set_charset($link, "big5"));
35
36    if ('���H�U���e\\\\���H�U���e' !== ($tmp = mysqli_real_escape_string($link,
37'���H�U���e\\���H�U���e')))
38        printf("[004] Expecting \\\\, got %s\n", $tmp);
39
40    if ('���H�U���e\"���H�U���e' !== ($tmp = mysqli_real_escape_string($link,
41'���H�U���e"���H�U���e')))
42        printf("[005] Expecting \", got %s\n", $tmp);
43
44    if ("���H�U���e\'���H�U���e" !== ($tmp = mysqli_real_escape_string($link,
45"���H�U���e'���H�U���e")))
46        printf("[006] Expecting ', got %s\n", $tmp);
47
48    if ("���H�U���e\\n���H�U���e" !== ($tmp = mysqli_real_escape_string($link,
49"���H�U���e\n���H�U���e")))
50        printf("[007] Expecting \\n, got %s\n", $tmp);
51
52    if ("���H�U���e\\r���H�U���e" !== ($tmp = mysqli_real_escape_string($link,
53"���H�U���e\r���H�U���e")))
54        printf("[008] Expecting \\r, got %s\n", $tmp);
55
56    if ("���H�U���e\\0���H�U���e" !== ($tmp = mysqli_real_escape_string($link, "���H�U���e"
57. chr(0) . "���H�U���e")))
58        printf("[009] Expecting %s, got %s\n", "���H�U���e\\0���H�U���e", $tmp);
59
60    var_dump(mysqli_query($link, "INSERT INTO test(id, label) VALUES (100,
61'��')"));
62
63    mysqli_close($link);
64    print "done!";
65?>
66--CLEAN--
67<?php
68    require_once 'clean_table.inc';
69?>
70--EXPECT--
71bool(true)
72bool(true)
73done!
74