Revisión | 7ffec3649e65ad8c3d114a0e547c755c4e19306c (tree) |
---|---|
Tiempo | 2010-10-13 23:59:26 |
Autor | miko2u <miko@cafe...> |
Commiter | miko2u |
REQUIRE: mbstring (and Drop "mbstring.php")
@@ -1,208 +0,0 @@ | ||
1 | -<?php | |
2 | -// PukiWiki - Yet another WikiWikiWeb clone. | |
3 | -// $Id: mbstring.php,v 1.4.1 2005/04/29 11:24:20 miko Exp $ | |
4 | -// Copyright (C) | |
5 | -// 2005 PukiWiki Plus! Team | |
6 | -// 2003-2005 PukiWiki Developers Team | |
7 | -// License: GPL v2 or (at your option) any later version | |
8 | -// | |
9 | -// mbstring-extension alternate functions | |
10 | -// (will work with LANG == 'ja' and EUC-JP environment only) | |
11 | - | |
12 | -if (!defined('DATA_HOME')) { exit; } | |
13 | - | |
14 | -/* | |
15 | - * mbstring extension がサーバー側に存在しない時の代替関数 | |
16 | - * | |
17 | - * 注意事項 | |
18 | - * | |
19 | - * 1. 実際に漢字コード変換を行わせるためには、別途 jcode.php | |
20 | - * (TOMO作)をインストールする必要があります。 | |
21 | - * | |
22 | - * http://www.spencernetwork.org/jcode/ よりjcodeを入手し、 | |
23 | - * 以下の様に展開してください。 | |
24 | - * | |
25 | - * -+--- mbstring.php -r-- | |
26 | - * +-+- jcode_1.34/ dr-x | |
27 | - * +--- readme.txt -r-- | |
28 | - * +--- jcode.phps -r-- | |
29 | - * +--- jcode_wrapper.php -r-- | |
30 | - * +--- code_table.ucs2jis -r-- | |
31 | - * +--- code_table.jis2ucs -r-- | |
32 | - * | |
33 | - * 2. EUC-JP専用です。(出力されるデータがEUC-JPである必要があります) | |
34 | - * | |
35 | - */ | |
36 | - | |
37 | -// jcodeの所在 | |
38 | -define('JCODE_DIR', './jcode_1.34/'); | |
39 | -define('JCODE_FILE', JCODE_DIR . 'jcode_wrapper.php'); | |
40 | - | |
41 | -if (is_readable(JCODE_FILE)) { | |
42 | - require_once(JCODE_FILE); | |
43 | -} | |
44 | - | |
45 | -// jcodeが存在しない場合、マルチバイト文字や漢字コードを扱えない | |
46 | -if (! function_exists('jcode_convert_encoding')) { | |
47 | - | |
48 | -// die_message('Multibyte functions cannot be used. Please read "mbstring.php" for an additional installation procedure of "jcode".'); | |
49 | - | |
50 | - function jstrlen($str) | |
51 | - { | |
52 | - return strlen($str); | |
53 | - } | |
54 | - | |
55 | - function jsubstr($str, $start, $length) | |
56 | - { | |
57 | - return substr($str, $start, $length); | |
58 | - } | |
59 | - | |
60 | - function AutoDetect($str) | |
61 | - { | |
62 | - return 0; | |
63 | - } | |
64 | - | |
65 | - function jcode_convert_encoding($str, $to_encoding, $from_encoding) | |
66 | - { | |
67 | - return $str; | |
68 | - } | |
69 | -} | |
70 | - | |
71 | -// mb_convert_encoding -- 文字エンコーディングを変換する | |
72 | -function mb_convert_encoding($str, $to_encoding, $from_encoding = '') | |
73 | -{ | |
74 | - // 拡張: 配列を受けられるように | |
75 | - // mb_convert_variable対策 | |
76 | - if (is_array($str)) { | |
77 | - foreach ($str as $key=>$value) { | |
78 | - $str[$key] = mb_convert_encoding($value, $to_encoding, $from_encoding); | |
79 | - } | |
80 | - return $str; | |
81 | - } | |
82 | - return jcode_convert_encoding($str, $to_encoding, $from_encoding); | |
83 | -} | |
84 | - | |
85 | -// mb_convert_variables -- 変数の文字コードを変換する | |
86 | -function mb_convert_variables($to_encoding, $from_encoding, &$vars) | |
87 | -{ | |
88 | - // 注: 可変長引数ではない。init.phpから呼ばれる1引数のパターンのみをサポート | |
89 | - // 正直に実装するなら、可変引数をリファレンスで受ける方法が必要 | |
90 | - if (is_array($from_encoding) || $from_encoding == '' || $from_encoding == 'auto') | |
91 | - $from_encoding = mb_detect_encoding(join_array(' ', $vars)); | |
92 | - | |
93 | - if ($from_encoding != 'ASCII' && $from_encoding != SOURCE_ENCODING) | |
94 | - $vars = mb_convert_encoding($vars, $to_encoding, $from_encoding); | |
95 | - | |
96 | - return $from_encoding; | |
97 | -} | |
98 | - | |
99 | -// 補助関数:配列を再帰的にjoinする | |
100 | -function join_array($glue, $pieces) | |
101 | -{ | |
102 | - $arr = array(); | |
103 | - foreach ($pieces as $piece) { | |
104 | - $arr[] = is_array($piece) ? join_array($glue, $piece) : $piece; | |
105 | - } | |
106 | - return join($glue, $arr); | |
107 | -} | |
108 | - | |
109 | -// mb_detect_encoding -- 文字エンコーディングを検出する | |
110 | -function mb_detect_encoding($str, $encoding_list = '') | |
111 | -{ | |
112 | - static $codes = array(0=>'ASCII', 1=>'EUC-JP', 2=>'SJIS', 3=>'JIS', 4=>'UTF-8'); | |
113 | - | |
114 | - // 注: $encoding_listは使用しない。 | |
115 | - $code = AutoDetect($str); | |
116 | - if (! isset($codes[$code])) $code = 0; // oh ;( | |
117 | - | |
118 | - return $codes[$code]; | |
119 | -} | |
120 | - | |
121 | -// mb_detect_order -- 文字エンコーディング検出順序の設定/取得 | |
122 | -function mb_detect_order($encoding_list = NULL) | |
123 | -{ | |
124 | - static $list = array(); | |
125 | - | |
126 | - // 注: 他の関数に影響を及ぼさない。呼んでも無意味。 | |
127 | - if ($encoding_list === NULL) return $list; | |
128 | - | |
129 | - $list = is_array($encoding_list) ? $encoding_list : explode(',', $encoding_list); | |
130 | - return TRUE; | |
131 | -} | |
132 | - | |
133 | -// mb_encode_mimeheader -- MIMEヘッダの文字列をエンコードする | |
134 | -function mb_encode_mimeheader($str, $charset = 'ISO-2022-JP', $transfer_encoding = 'B', $linefeed = "\r\n") | |
135 | -{ | |
136 | - // 注: $transfer_encodingに関わらずbase64エンコードを返す | |
137 | - $str = mb_convert_encoding($str, $charset, 'auto'); | |
138 | - return '=?' . $charset . '?B?' . $str; | |
139 | -} | |
140 | - | |
141 | -// mb_http_output -- HTTP出力文字エンコーディングの設定/取得 | |
142 | -function mb_http_output($encoding = '') | |
143 | -{ | |
144 | - return SOURCE_ENCODING; // 注: 何もしない | |
145 | -} | |
146 | - | |
147 | -// mb_internal_encoding -- 内部文字エンコーディングの設定/取得 | |
148 | -function mb_internal_encoding($encoding = '') | |
149 | -{ | |
150 | - return SOURCE_ENCODING; // 注: 何もしない | |
151 | -} | |
152 | - | |
153 | -// mb_language -- カレントの言語を設定/取得 | |
154 | -function mb_language($language = NULL) | |
155 | -{ | |
156 | - static $mb_language = FALSE; | |
157 | - | |
158 | - if ($language === NULL) return $mb_language; | |
159 | - $mb_language = $language; | |
160 | - | |
161 | - return TRUE; // 注: 常にTRUEを返す | |
162 | -} | |
163 | - | |
164 | -// mb_strimwidth -- 指定した幅で文字列を丸める | |
165 | -function mb_strimwidth($str, $start, $width, $trimmarker = '', $encoding = '') | |
166 | -{ | |
167 | - if ($start == 0 && $width <= strlen($str)) return $str; | |
168 | - | |
169 | - // 注: EUC-JP専用, $encodingを使用しない | |
170 | - $chars = unpack('C*', $str); | |
171 | - $substr = ''; | |
172 | - | |
173 | - while (! empty($chars) && $start > 0) { | |
174 | - --$start; | |
175 | - if (array_shift($chars) >= 0x80) | |
176 | - array_shift($chars); | |
177 | - } | |
178 | - if ($b_trimmarker = (count($chars) > $width)) { | |
179 | - $width -= strlen($trimmarker); | |
180 | - } | |
181 | - while (! empty($chars) && $width-- > 0) { | |
182 | - $char = array_shift($chars); | |
183 | - if ($char >= 0x80) { | |
184 | - if ($width-- == 0) break; | |
185 | - $substr .= chr($char); | |
186 | - $char = array_shift($chars); | |
187 | - } | |
188 | - $substr .= chr($char); | |
189 | - } | |
190 | - if ($b_trimmarker) $substr .= $trimmarker; | |
191 | - | |
192 | - return $substr; | |
193 | -} | |
194 | - | |
195 | -// mb_strlen -- 文字列の長さを得る | |
196 | -function mb_strlen($str, $encoding = '') | |
197 | -{ | |
198 | - // 注: EUC-JP専用, $encodingを使用しない | |
199 | - return jstrlen($str); | |
200 | -} | |
201 | - | |
202 | -// mb_substr -- 文字列の一部を得る | |
203 | -function mb_substr($str, $start, $length = NULL, $encoding = '') | |
204 | -{ | |
205 | - // 注: EUC-JP専用, $encodingを使用しない | |
206 | - return jsubstr($str, $start, ($length === NULL) ? jstrlen($str) : $length); | |
207 | -} | |
208 | -?> |
@@ -66,7 +66,7 @@ require(LIB_DIR . 'netbios.cls.php'); | ||
66 | 66 | require(LIB_DIR . 'ua/user_agent.cls.php'); |
67 | 67 | |
68 | 68 | if (! extension_loaded('mbstring')) { |
69 | - require(LIB_DIR . 'mbstring.php'); | |
69 | + die(_('PHP module "mbstring" is not found.')); | |
70 | 70 | } |
71 | 71 | if (! extension_loaded('gettext')) { |
72 | 72 | require(LIB_DIR . 'gettext.php'); |