Hướng dẫn get encoding string php
(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8) mb_detect_encoding — Detect character encoding Descriptionmb_detect_encoding(string Automatic detection of the intended character encoding can never be entirely reliable; without some additional information, it is similar to decoding an encrypted string without the key. It is always preferable to use an indication of character encoding stored or transmitted with the data, such as a "Content-Type" HTTP header. This function is most useful with multibyte encodings, where not all sequences of bytes form a valid string. If the input string contains such a sequence, that encoding will be rejected, and the next encoding checked. Parametersstring The string being inspected. encodings A list of character encodings to try, in order. The list may be specified as an array of strings, or a single string separated by commas. If strict Controls the behaviour when The default value for Return Values The detected character encoding, or ExamplesExample #1 mb_detect_encoding() example
Example #2 Effect of
The above example will output: string(5) "UTF-8" bool(false) string(10) "ISO-8859-1" string(10) "ISO-8859-1" In some cases, the same sequence of bytes may form a valid string in multiple character encodings, and it is impossible to know which interpretation was intended. For instance, among many others, the byte sequence "\xC4\xA2" could be:
Example #3 Effect of order when multiple encodings match
The above example will output: string(5) "UTF-8" string(10) "ISO-8859-1" string(10) "ISO-8859-5" Gerg Tisza ¶ 11 years ago
Chrigu ¶ 17 years ago
chris AT w3style.co DOT uk ¶ 16 years ago
rl at itfigures dot nl ¶ 15 years ago
nat3738 at gmail dot com ¶ 13 years ago
detect_utf_encoding($filename) {$text = file_get_contents($filename); php-note-2005 at ryandesign dot com ¶ 17 years ago
// function is_utf8?>
hmdker at gmail dot com ¶ 14 years ago
recentUser at example dot com ¶ 4 years ago
garbage at iglou dot eu ¶ 5 years ago
bmrkbyet at web dot de ¶ 9 years ago
$list = array('utf-8', 'iso-8859-1', 'windows-1251'); emoebel at web dot de ¶ 8 years ago
$enclist = array( d_maksimov ¶ 5 months ago
telemach ¶ 17 years ago
maarten ¶ 17 years ago
yaqy at qq dot com ¶ 14 years ago
iconv("gbk","utf-8",$str);
Anonymous ¶ 8 years ago
matthijs at ischen dot nl ¶ 13 years ago
jaaks at playtech dot com ¶ 17 years ago
lexonight at yahoo dot com ¶ 5 years ago
prgss at bk dot ru ¶ 13 years ago
$list as $item) { sunggsun ¶ 16 years ago
|