1--TEST--
2mysqli_real_escape_string() - sjis
3--SKIPIF--
4<?php
5if (version_compare(PHP_VERSION, '5.9.9', '>') == 1) {
6	die('skip set character set not functional with PHP 6 (fomerly PHP 6 && unicode.semantics=On)');
7}
8
9require_once('skipif.inc');
10require_once('skipifemb.inc');
11require_once('skipifconnectfailure.inc');
12require_once('connect.inc');
13
14if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
15	die(sprintf("skip Cannot connect to MySQL, [%d] %s\n",
16		mysqli_connect_errno(), mysqli_connect_error()));
17}
18if (!mysqli_set_charset($link, 'sjis'))
19	die(sprintf("skip Cannot set charset 'sjis'"));
20mysqli_close($link);
21?>
22--FILE--
23<?php
24
25	require_once("connect.inc");
26	require_once('table.inc');
27
28	var_dump(mysqli_set_charset($link, "sjis"));
29
30	if ('?p??\\\\?p??' !== ($tmp = mysqli_real_escape_string($link, '?p??\\?p??')))
31		printf("[004] Expecting \\\\, got %s\n", $tmp);
32
33	if ('?p??\"?p??' !== ($tmp = mysqli_real_escape_string($link, '?p??"?p??')))
34		printf("[005] Expecting \", got %s\n", $tmp);
35
36	if ("?p??\'?p??" !== ($tmp = mysqli_real_escape_string($link, "?p??'?p??")))
37		printf("[006] Expecting ', got %s\n", $tmp);
38
39	if ("?p??\\n?p??" !== ($tmp = mysqli_real_escape_string($link, "?p??\n?p??")))
40		printf("[007] Expecting \\n, got %s\n", $tmp);
41
42	if ("?p??\\r?p??" !== ($tmp = mysqli_real_escape_string($link, "?p??\r?p??")))
43		printf("[008] Expecting \\r, got %s\n", $tmp);
44
45	if ("?p??\\0?p??" !== ($tmp = mysqli_real_escape_string($link, "?p??" . chr(0) . "?p??")))
46		printf("[009] Expecting %s, got %s\n", "?p??\\0?p??", $tmp);
47
48	var_dump(mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, '?p')"));
49
50	mysqli_close($link);
51	print "done!";
52?>
53--EXPECTF--
54bool(true)
55bool(true)
56done!
57