Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
--TEST--
2
negotiateCharset() with default
3
--GET--
4
--ENV--
5
HTTP_HOST=example.org
6
SERVER_NAME=example.org
7
QUERY_STRING=
8
SERVER_PORT=80
9
HTTPS=off
10
REQUEST_URI=/subdir/test.php
11
SCRIPT_NAME=/subdir/test.php
12
HTTP_ACCEPT_CHARSET=ISO-8859-1, Big5;q=0.6,utf-8;q=0.7, *;q=0.5
13
--FILE--
14
<?php
15
/**
16
 * This test checks for charset negotiation
17
 *
18
 * PHP version 4 and 5
19
 *
20
 * @category HTTP
21
 * @package  HTTP
22
 * @author   Philippe Jausions <jausions@php.net>
23
 * @license  http://www.opensource.org/licenses/bsd-license.php New BSD License
24
 * @link     http://pear.php.net/package/HTTP
25
 */
26
require_once  'HTTP.php';
27
 
28
// The --ENV-- Accept sets the following order
29
// (preferred charsets first)
30
// 1. ISO-8859-1 (Latin1 - Western Europe)
31
// 2. UTF-8
32
// 3. Big5 (Traditional Chinese)
33
// 3. * (any other)
34
 
35
$sets = array(
36
    1 => array(
37
        'utf-8',
38
        'big5',
39
        'iso-8859-1',
40
        'shift-jis',
41
    ),
42
    2 => array(
43
        'utf-8',
44
        'big5',
45
        'shift-jis',
46
    ),
47
    3 => array(
48
        'Big5',
49
        'shift-jis',
50
    ),
51
    4 => array(
52
        'shift-jis',
53
    ),
54
    5 => array(
55
    ),
56
);
57
foreach ($sets as $i => $supported) {
58
    echo $i.' => '.HTTP::negotiateCharset($supported, 'us-ascii')
59
         ."\n";
60
}
61
 
62
?>
63
--EXPECT--
64
1 => iso-8859-1
65
2 => utf-8
66
3 => Big5
67
4 => shift-jis
68
5 => us-ascii