forked from yangweijie/SublimeThinkPHP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iconv.php
433 lines (416 loc) · 13 KB
/
iconv.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
<?php
// Start of iconv v.
/**
* (PHP 4 >= 4.0.5, PHP 5)<br/>
* Convert string to requested character encoding
* @link http://php.net/manual/en/function.iconv.php
* @param string $in_charset <p>
* The input charset.
* </p>
* @param string $out_charset <p>
* The output charset.
* </p>
* <p>
* If you append the string //TRANSLIT to
* <i>out_charset</i> transliteration is activated. This
* means that when a character can't be represented in the target charset,
* it can be approximated through one or several similarly looking
* characters. If you append the string //IGNORE,
* characters that cannot be represented in the target charset are silently
* discarded. Otherwise, <i>str</i> is cut from the first
* illegal character and an <b>E_NOTICE</b> is generated.
* </p>
* @param string $str <p>
* The string to be converted.
* </p>
* @return string the converted string or <b>FALSE</b> on failure.
*/
function iconv ($in_charset, $out_charset, $str) {}
/**
* (PHP 4 >= 4.0.5, PHP 5)<br/>
* Retrieve internal configuration variables of iconv extension
* @link http://php.net/manual/en/function.iconv-get-encoding.php
* @param string $type [optional] <p>
* The value of the optional <i>type</i> can be:
* all
* input_encoding
* output_encoding
* internal_encoding
* </p>
* @return mixed the current value of the internal configuration variable if
* successful or <b>FALSE</b> on failure.
* </p>
* <p>
* If <i>type</i> is omitted or set to "all",
* <b>iconv_get_encoding</b> returns an array that
* stores all these variables.
*/
function iconv_get_encoding ($type = "all") {}
/**
* (PHP 4 >= 4.0.5, PHP 5)<br/>
* Set current setting for character encoding conversion
* @link http://php.net/manual/en/function.iconv-set-encoding.php
* @param string $type <p>
* The value of <i>type</i> can be any one of these:
* input_encoding
* output_encoding
* internal_encoding
* </p>
* @param string $charset <p>
* The character set.
* </p>
* @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure.
*/
function iconv_set_encoding ($type, $charset) {}
/**
* (PHP 5)<br/>
* Returns the character count of string
* @link http://php.net/manual/en/function.iconv-strlen.php
* @param string $str <p>
* The string.
* </p>
* @param string $charset [optional] <p>
* If <i>charset</i> parameter is omitted,
* <i>str</i> is assumed to be encoded in
* iconv.internal_encoding.
* </p>
* @return int the character count of <i>str</i>, as an integer.
*/
function iconv_strlen ($str, $charset = 'ini_get("iconv.internal_encoding")') {}
/**
* (PHP 5)<br/>
* Cut out part of a string
* @link http://php.net/manual/en/function.iconv-substr.php
* @param string $str <p>
* The original string.
* </p>
* @param int $offset <p>
* If <i>offset</i> is non-negative,
* <b>iconv_substr</b> cuts the portion out of
* <i>str</i> beginning at <i>offset</i>'th
* character, counting from zero.
* </p>
* <p>
* If <i>offset</i> is negative,
* <b>iconv_substr</b> cuts out the portion beginning
* at the position, <i>offset</i> characters
* away from the end of <i>str</i>.
* </p>
* @param int $length [optional] <p>
* If <i>length</i> is given and is positive, the return
* value will contain at most <i>length</i> characters
* of the portion that begins at <i>offset</i>
* (depending on the length of <i>string</i>).
* </p>
* <p>
* If negative <i>length</i> is passed,
* <b>iconv_substr</b> cuts the portion out of
* <i>str</i> from the <i>offset</i>'th
* character up to the character that is
* <i>length</i> characters away from the end of the string.
* In case <i>offset</i> is also negative, the start position
* is calculated beforehand according to the rule explained above.
* </p>
* @param string $charset [optional] <p>
* If <i>charset</i> parameter is omitted,
* <i>string</i> are assumed to be encoded in
* iconv.internal_encoding.
* </p>
* <p>
* Note that <i>offset</i> and <i>length</i>
* parameters are always deemed to represent offsets that are
* calculated on the basis of the character set determined by
* <i>charset</i>, whilst the counterpart
* <b>substr</b> always takes these for byte offsets.
* </p>
* @return string the portion of <i>str</i> specified by the
* <i>offset</i> and <i>length</i> parameters.
* </p>
* <p>
* If <i>str</i> is shorter than <i>offset</i>
* characters long, <b>FALSE</b> will be returned.
*/
function iconv_substr ($str, $offset, $length = 'iconv_strlen($str, $charset)', $charset = 'ini_get("iconv.internal_encoding")') {}
/**
* (PHP 5)<br/>
* Finds position of first occurrence of a needle within a haystack
* @link http://php.net/manual/en/function.iconv-strpos.php
* @param string $haystack <p>
* The entire string.
* </p>
* @param string $needle <p>
* The searched substring.
* </p>
* @param int $offset [optional] <p>
* The optional <i>offset</i> parameter specifies
* the position from which the search should be performed.
* </p>
* @param string $charset [optional] <p>
* If <i>charset</i> parameter is omitted,
* <i>string</i> are assumed to be encoded in
* iconv.internal_encoding.
* </p>
* @return int the numeric position of the first occurrence of
* <i>needle</i> in <i>haystack</i>.
* </p>
* <p>
* If <i>needle</i> is not found,
* <b>iconv_strpos</b> will return <b>FALSE</b>.
*/
function iconv_strpos ($haystack, $needle, $offset = 0, $charset = 'ini_get("iconv.internal_encoding")') {}
/**
* (PHP 5)<br/>
* Finds the last occurrence of a needle within a haystack
* @link http://php.net/manual/en/function.iconv-strrpos.php
* @param string $haystack <p>
* The entire string.
* </p>
* @param string $needle <p>
* The searched substring.
* </p>
* @param string $charset [optional] <p>
* If <i>charset</i> parameter is omitted,
* <i>string</i> are assumed to be encoded in
* iconv.internal_encoding.
* </p>
* @return int the numeric position of the last occurrence of
* <i>needle</i> in <i>haystack</i>.
* </p>
* <p>
* If <i>needle</i> is not found,
* <b>iconv_strrpos</b> will return <b>FALSE</b>.
*/
function iconv_strrpos ($haystack, $needle, $charset = 'ini_get("iconv.internal_encoding")') {}
/**
* (PHP 5)<br/>
* Composes a MIME header field
* @link http://php.net/manual/en/function.iconv-mime-encode.php
* @param string $field_name <p>
* The field name.
* </p>
* @param string $field_value <p>
* The field value.
* </p>
* @param array $preferences [optional] <p>
* You can control the behaviour of <b>iconv_mime_encode</b>
* by specifying an associative array that contains configuration items
* to the optional third parameter <i>preferences</i>.
* The items supported by <b>iconv_mime_encode</b> are
* listed below. Note that item names are treated case-sensitive.
* <table>
* Configuration items supported by <b>iconv_mime_encode</b>
* <tr valign="top">
* <td>Item</td>
* <td>Type</td>
* <td>Description</td>
* <td>Default value</td>
* <td>Example</td>
* </tr>
* <tr valign="top">
* <td>scheme</td>
* <td>string</td>
* <td>
* Specifies the method to encode a field value by. The value of
* this item may be either "B" or "Q", where "B" stands for
* base64 encoding scheme and "Q" stands for
* quoted-printable encoding scheme.
* </td>
* <td>B</td>
* <td>B</td>
* </tr>
* <tr valign="top">
* <td>input-charset</td>
* <td>string</td>
* <td>
* Specifies the character set in which the first parameter
* <i>field_name</i> and the second parameter
* <i>field_value</i> are presented. If not given,
* <b>iconv_mime_encode</b> assumes those parameters
* are presented to it in the
* iconv.internal_encoding
* ini setting.
* </td>
* <td>
* iconv.internal_encoding
* </td>
* <td>ISO-8859-1</td>
* </tr>
* <tr valign="top">
* <td>output-charset</td>
* <td>string</td>
* <td>
* Specifies the character set to use to compose the
* MIME header.
* </td>
* <td>
* iconv.internal_encoding
* </td>
* <td>UTF-8</td>
* </tr>
* <tr valign="top">
* <td>line-length</td>
* <td>integer</td>
* <td>
* Specifies the maximum length of the header lines. The resulting
* header is "folded" to a set of multiple lines in case
* the resulting header field would be longer than the value of this
* parameter, according to
* RFC2822 - Internet Message Format.
* If not given, the length will be limited to 76 characters.
* </td>
* <td>76</td>
* <td>996</td>
* </tr>
* <tr valign="top">
* <td>line-break-chars</td>
* <td>string</td>
* <td>
* Specifies the sequence of characters to append to each line
* as an end-of-line sign when "folding" is performed on a long header
* field. If not given, this defaults to "\r\n"
* (CR LF). Note that
* this parameter is always treated as an ASCII string regardless
* of the value of input-charset.
* </td>
* <td>\r\n</td>
* <td>\n</td>
* </tr>
* </table>
* </p>
* @return string an encoded MIME field on success,
* or <b>FALSE</b> if an error occurs during the encoding.
*/
function iconv_mime_encode ($field_name, $field_value, array $preferences = null) {}
/**
* (PHP 5)<br/>
* Decodes a MIME header field
* @link http://php.net/manual/en/function.iconv-mime-decode.php
* @param string $encoded_header <p>
* The encoded header, as a string.
* </p>
* @param int $mode [optional] <p>
* <i>mode</i> determines the behaviour in the event
* <b>iconv_mime_decode</b> encounters a malformed
* MIME header field. You can specify any combination
* of the following bitmasks.
* <table>
* Bitmasks acceptable to <b>iconv_mime_decode</b>
* <tr valign="top">
* <td>Value</td>
* <td>Constant</td>
* <td>Description</td>
* </tr>
* <tr valign="top">
* <td>1</td>
* <td>ICONV_MIME_DECODE_STRICT</td>
* <td>
* If set, the given header is decoded in full conformance with the
* standards defined in RFC2047.
* This option is disabled by default because there are a lot of
* broken mail user agents that don't follow the specification and don't
* produce correct MIME headers.
* </td>
* </tr>
* <tr valign="top">
* <td>2</td>
* <td>ICONV_MIME_DECODE_CONTINUE_ON_ERROR</td>
* <td>
* If set, <b>iconv_mime_decode_headers</b>
* attempts to ignore any grammatical errors and continue to process
* a given header.
* </td>
* </tr>
* </table>
* </p>
* @param string $charset [optional] <p>
* The optional <i>charset</i> parameter specifies the
* character set to represent the result by. If omitted,
* iconv.internal_encoding
* will be used.
* </p>
* @return string a decoded MIME field on success,
* or <b>FALSE</b> if an error occurs during the decoding.
*/
function iconv_mime_decode ($encoded_header, $mode = 0, $charset = 'ini_get("iconv.internal_encoding")') {}
/**
* (PHP 5)<br/>
* Decodes multiple MIME header fields at once
* @link http://php.net/manual/en/function.iconv-mime-decode-headers.php
* @param string $encoded_headers <p>
* The encoded headers, as a string.
* </p>
* @param int $mode [optional] <p>
* <i>mode</i> determines the behaviour in the event
* <b>iconv_mime_decode_headers</b> encounters a malformed
* MIME header field. You can specify any combination
* of the following bitmasks.
* <table>
* Bitmasks acceptable to <b>iconv_mime_decode_headers</b>
* <tr valign="top">
* <td>Value</td>
* <td>Constant</td>
* <td>Description</td>
* </tr>
* <tr valign="top">
* <td>1</td>
* <td>ICONV_MIME_DECODE_STRICT</td>
* <td>
* If set, the given header is decoded in full conformance with the
* standards defined in RFC2047.
* This option is disabled by default because there are a lot of
* broken mail user agents that don't follow the specification and don't
* produce correct MIME headers.
* </td>
* </tr>
* <tr valign="top">
* <td>2</td>
* <td>ICONV_MIME_DECODE_CONTINUE_ON_ERROR</td>
* <td>
* If set, <b>iconv_mime_decode_headers</b>
* attempts to ignore any grammatical errors and continue to process
* a given header.
* </td>
* </tr>
* </table>
* </p>
* @param string $charset [optional] <p>
* The optional <i>charset</i> parameter specifies the
* character set to represent the result by. If omitted,
* iconv.internal_encoding
* will be used.
* </p>
* @return array an associative array that holds a whole set of
* MIME header fields specified by
* <i>encoded_headers</i> on success, or <b>FALSE</b>
* if an error occurs during the decoding.
* </p>
* <p>
* Each key of the return value represents an individual
* field name and the corresponding element represents a field value.
* If more than one field of the same name are present,
* <b>iconv_mime_decode_headers</b> automatically incorporates
* them into a numerically indexed array in the order of occurrence.
*/
function iconv_mime_decode_headers ($encoded_headers, $mode = 0, $charset = 'ini_get("iconv.internal_encoding")') {}
/**
* string
* @link http://php.net/manual/en/iconv.constants.php
*/
define ('ICONV_IMPL', "glibc");
/**
* string
* @link http://php.net/manual/en/iconv.constants.php
*/
define ('ICONV_VERSION', 2.15);
/**
* integer
* @link http://php.net/manual/en/iconv.constants.php
*/
define ('ICONV_MIME_DECODE_STRICT', 1);
/**
* integer
* @link http://php.net/manual/en/iconv.constants.php
*/
define ('ICONV_MIME_DECODE_CONTINUE_ON_ERROR', 2);
// End of iconv v.
?>