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