Điều gì sẽ xảy ra nếu bằng "Xóa HTML đặc biệt Chars" Bạn có nghĩa là "thay thế một cách thích hợp"?
Rốt cuộc, chỉ cần nhìn vào ví dụ của bạn ...
& ©
Nếu bạn đang tước thứ này cho nguồn cấp dữ liệu RSS, bạn có nên muốn tương đương không?
" ", &, ©
Hoặc có thể bạn không chính xác muốn tương đương. Có thể bạn muốn có
chỉ bị bỏ qua [để ngăn chặn quá nhiều không gian], nhưng sau đó ©
thực sự bị thay thế. Hãy tìm ra một giải pháp giải quyết phiên bản vấn đề này của bất kỳ ai ...
Cách chọn lọc HTML đặc biệt HTML
Logic rất đơn giản: preg_match_all['/[[0-9]+;]/'
lấy tất cả các trận đấu, và sau đó chúng tôi chỉ cần xây dựng một danh sách các đồ phù hợp và thay thế, chẳng hạn như str_replace[[searchlist], [replacelist], $term]
. Trước khi chúng tôi làm điều này, chúng tôi cũng cần chuyển đổi các thực thể được đặt tên thành các đối tác số của họ, tức là, " "
là không thể chấp nhận được, nhưng "A0;"
là tốt. [Nhờ giải pháp của nó-Alien cho phần này của vấn đề.]
Bản demo làm việc
Trong bản demo này, tôi thay thế
" ", &, ©
0 bằng " ", &, ©
1. Tất nhiên, bạn có thể tinh chỉnh điều này với bất kỳ loại tìm kiếm nào bạn muốn cho trường hợp của bạn.Tại sao tôi lại làm điều này? Tôi sử dụng nó với việc tạo định dạng văn bản phong phú từ HTML được mã hóa theo ký tự UTF8.
Xem bản demo làm việc đầy đủ:
Bản demo làm việc trực tuyến đầy đủ
function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
Input:
2" ", &, ©
Đầu ra:
3" ", &, ©
Chủ đề: PHP / mysqlprev | Tiếp theoPrev|Next
Trả lời: Sử dụng chức năng Php " ", &, ©
4
" ", &, ©
Một số ký tự như [
" ", &, ©
5, " ", &, ©
6, " ", &, ©
7, " ", &, ©
8, " ", &, ©
9] có ý nghĩa đặc biệt trong HTML và nên được chuyển đổi thành các thực thể HTML. Bạn có thể sử dụng chức năng PHP " ", &, ©
4 để chuyển đổi các ký tự đặc biệt trong một chuỗi thành các thực thể HTML. Hãy xem một ví dụ:
Nếu bạn xem mã nguồn của đầu ra, bạn sẽ chuỗi "Chuỗi có ký tự đặc biệt". được chuyển đổi thành "Chuỗi với & lt; b & gt; đặc biệt & lt;/b & gt; ký tự."special characters." converted to "String with special characters."
Câu hỏi thường gặp liên quan
Dưới đây là một số Câu hỏi thường gặp liên quan đến chủ đề này:
- Cách chuyển đổi các thực thể HTML đặc biệt trở lại các ký tự trong PHP
- Cách thay thế phần của chuỗi bằng chuỗi khác trong PHP
- Cách loại bỏ khoảng trắng khỏi chuỗi trong PHP
1 năm trước
Kenneth Kin Lum ¶ — Convert special characters to HTML entities
14 năm trước
Felix D. ¶[
string
1, function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
int
2 = ENT_QUOTES | ENT_SUBSTITUTE |
ENT_HTML401, function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
?string
3 = function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
4, function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
bool
5 = function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
6 function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
]: string
8 năm trướchtmlentities[] [which only encodes substrings that have named entity equivalents] may be insufficient. You may have to use mb_encode_numericentity[] instead.
Ivan tại Lutrov dot comDaniel Klein ¶ | 4 tháng trước |
Ryan tại Ryano Dot Net | 21 năm trước 1 is set
|
POV ¶ | 7 năm trước 4] or 5 [for 6, 7 or 8], but only when 9 is set
|
Killian Leroux ¶ | 8 tháng trước |
Minder at ufive dot unibe dot ch ¶ | php dot net tại orakio dot net ¶ |
năng lượng mặt trời ¶
15 năm trướcHỗ trợ tại PlayNext Dot Ru ¶string being converted.
nachitox2000 [at] hotmail [dot] com ¶12 năm trước
_____ tại Luukku dot com 8
| Felix D. ¶ |
9
| 8 năm trước |
1
| Ivan tại Lutrov dot com |
© 1
| Ẩn danh ¶ |
© 2
| Thay thế các chuỗi đơn vị mã không hợp lệ bằng ký tự thay thế Unicode U+FFFD [UTF-8] hoặc � [nếu không] thay vì trả về một chuỗi trống. |
© 3
| Thay thế các điểm mã không hợp lệ cho loại tài liệu đã cho bằng ký tự thay thế Unicode U+FFFD [UTF-8] hoặc � [nếu không] thay vì để chúng như là. Điều này có thể hữu ích, ví dụ, để đảm bảo tính được hình thành tốt của các tài liệu XML với nội dung bên ngoài được nhúng. |
4
| Xử lý mã là HTML 4.01. |
6
| Xử lý mã là XML 1. |
7
| Xử lý mã là XHTML. |
8
| Xử lý mã là HTML 5. |
©
8Một đối số tùy chọn xác định mã hóa được sử dụng khi chuyển đổi các ký tự.
Nếu bị bỏ qua, ©
8 mặc định vào giá trị của tùy chọn cấu hình default_charset.
Mặc dù đối số này là tùy chọn về mặt kỹ thuật, bạn rất được khuyến khích chỉ định giá trị chính xác cho mã của bạn nếu tùy chọn cấu hình default_charset có thể được đặt không chính xác cho đầu vào đã cho.
Đối với các mục đích của chức năng này, các mã hóa preg_match_all['/[[0-9]+;]/'
0, preg_match_all['/[[0-9]+;]/'
1, preg_match_all['/[[0-9]+;]/'
2, preg_match_all['/[[0-9]+;]/'
3, preg_match_all['/[[0-9]+;]/'
4, preg_match_all['/[[0-9]+;]/'
5 và preg_match_all['/[[0-9]+;]/'
6 có hiệu quả tương đương, với điều kiện là chính xác Tất cả các mã hóa này.htmlspecialchars[] occupy the same positions in all
of these encodings.
Các bộ ký tự sau được hỗ trợ:
CharSets được hỗ trợISO-8859-1 | ISO8859-1 | Tây Âu, Latin-1. |
ISO-8859-5 | ISO8859-5 | Ít hơn sử dụng ký tự cyrillic [Latin/Cyrillic]. |
ISO-8859-15 | ISO8859-15 | Tây Âu, Latin-9. Thêm dấu hiệu đồng euro, các chữ cái Pháp và Phần Lan bị thiếu trong Latin-1 [ISO-8859-1]. |
UTF-8 | & nbsp; | ASCII tương thích đa byte 8 bit unicode. |
CP866 | IBM866, 866 | Charset Cyrillic dành riêng cho DOS. |
CP1251 | Windows-1251, Win-1251, 1251 | Windows dành riêng cho Cyrillic Charset. |
CP1252 | Windows-1252, 1252 | Windows Charset cụ thể cho Tây Âu. |
Koi8-r | Koi8-Ru, Koi8r | Tiếng Nga. |
5 LỚN | 950 | Trung Quốc truyền thống, chủ yếu được sử dụng ở Đài Loan. |
GB2312 | 936 | Đơn giản hóa Trung Quốc, bộ nhân vật tiêu chuẩn quốc gia. |
BIG5-HKSCS | & nbsp; | ASCII tương thích đa byte 8 bit unicode. |
CP866 | IBM866, 866 | Charset Cyrillic dành riêng cho DOS. |
CP1251 | Windows-1251, Win-1251, 1251 | Charset Cyrillic dành riêng cho DOS. |
CP1251 | & nbsp; | ASCII tương thích đa byte 8 bit unicode. |
CP866 | & nbsp; | ASCII tương thích đa byte 8 bit unicode.nl_langinfo[] and setlocale[]], in this order. Not recommended. |
IBM866, 866CP866: Any other character sets are not recognized. The default encoding will be used instead and a warning will be emitted.
Charset Cyrillic dành riêng cho DOS.
CP1251
Windows-1251, Win-1251, 1251string.
Windows dành riêng cho Cyrillic Charset.©
1 or ©
2 flags are set.
CP1252
8.1.0 | ISO-8859-1 8 to 9 | © 2 | 4.
|
ISO8859-1
Tây Âu, Latin-1.htmlspecialchars[] example
" "
0
ISO-8859-5
ISO8859-5:
Ít hơn sử dụng ký tự cyrillic [Latin/Cyrillic].htmlentities[].
ISO8859-5:
Ít hơn sử dụng ký tự cyrillic [Latin/Cyrillic].
- ISO-8859-15
8,
9,1 is present, the default is1.- ISO8859-15
8,
9,1 is present,9 takes the highest precedence, followed by8.
- Tây Âu, Latin-9. Thêm dấu hiệu đồng euro, các chữ cái Pháp và Phần Lan bị thiếu trong Latin-1 [ISO-8859-1].
4,8,7,6 is present, the default is4.- UTF-8
4,8,7,6 is present,8 takes the highest precedence, followed by7,6 and4.- & nbsp;
©
3,©
1,©
2 are present,©
1 takes the highest precedence, followed by©
2.
ASCII tương thích đa byte 8 bit unicode.
- CP866
- IBM866, 866
- Charset Cyrillic dành riêng cho DOS.
- CP1251
- Windows-1251, Win-1251, 1251
Windows dành riêng cho Cyrillic Charset. ¶
CP1252
" ", &, ©
09" ", &, ©
10" ", &, ©
11" ", &, ©
12" ", &, ©
13Windows-1252, 1252 ¶
CP1252
" ", &, ©
14" ", &, ©
15" ", &, ©
16" ", &, ©
17" ", &, ©
18Windows-1252, 1252 ¶
Windows Charset cụ thể cho Tây Âu.
" ", &, ©
19" ", &, ©
20" ", &, ©
21" ", &, ©
22" ", &, ©
13Aschmidt tại Anamera Dot Net ¶
1 năm trước
" ", &, ©
24" ", &, ©
25" ", &, ©
26" ", &, ©
27" ", &, ©
28" ", &, ©
29Kenneth Kin Lum ¶ ¶
14 năm trước
" ", &, ©
30" ", &, ©
31" ", &, ©
13Felix D. ¶ ¶
8 năm trước
" ", &, ©
33Ivan tại Lutrov dot com ¶
11 năm trước
" ", &, ©
34Ẩn danh ¶ ¶
13 năm trước
" ", &, ©
35" ", &, ©
36" ", &, ©
37" ", &, ©
38Ẩn danh ¶ ¶
13 năm trước
" ", &, ©
39" ", &, ©
40" ", &, ©
41" ", &, ©
42" ", &, ©
43" ", &, ©
44" ", &, ©
45" ", &, ©
46" ", &, ©
13
Daniel Klein ¶ ¶
4 tháng trước
" ", &, ©
48" ", &, ©
49" ", &, ©
50" ", &, ©
49" ", &, ©
52" ", &, ©
53" ", &, ©
13Ryan tại Ryano Dot Net ¶
21 năm trước
" ", &, ©
55" ", &, ©
56" ", &, ©
13POV ¶ ¶
7 năm trước
" ", &, ©
58" ", &, ©
59" ", &, ©
60" ", &, ©
61" ", &, ©
62" ", &, ©
13Killian Leroux ¶ ¶
8 tháng trước
" ", &, ©
64" ", &, ©
65" ", &, ©
66" ", &, ©
67" ", &, ©
68" ", &, ©
69" ", &, ©
13Minder at ufive dot unibe dot ch ¶ ¶
9 năm trước
" ", &, ©
71" ", &, ©
72" ", &, ©
73" ", &, ©
74" ", &, ©
75" ", &, ©
76" ", &, ©
77" ", &, ©
78" ", &, ©
79" ", &, ©
80" ", &, ©
81" ", &, ©
82" ", &, ©
83" ", &, ©
84" ", &, ©
85" ", &, ©
86" ", &, ©
13php dot net tại orakio dot net ¶ ¶
14 năm trước
" ", &, ©
88" ", &, ©
89" ", &, ©
90" ", &, ©
91" ", &, ©
92" ", &, ©
93" ", &, ©
94" ", &, ©
95" ", &, ©
13Felix D. ¶ ¶
8 năm trước
" ", &, ©
97" ", &, ©
98" ", &, ©
99 function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
00 function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
01 function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
02" ", &, ©
13Ivan tại Lutrov dot com ¶
9 năm trước
function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
04 function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
05 function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
06 function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
07 function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
08 function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
09 function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
10" ", &, ©
13php dot net tại orakio dot net ¶ ¶
năng lượng mặt trời ¶
function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
12 function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
13" ", &, ©
1315 năm trước ¶
Hỗ trợ tại PlayNext Dot Ru ¶
function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
15nachitox2000 [at] hotmail [dot] com ¶ ¶
12 năm trước
function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
16 function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
17 function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
18" ", &, ©
13Ẩn danh ¶ ¶
13 năm trước
function FixUTF8[$args] {
$output = $args['input'];
$output = convertNamedHTMLEntitiesToNumeric[['input'=>$output]];
preg_match_all['/[[0-9]+;]/', $output, $matches, PREG_OFFSET_CAPTURE];
$full_matches = $matches[0];
$found = [];
$search = [];
$replace = [];
for[$i = 0; $i < count[$full_matches]; $i++] {
$match = $full_matches[$i];
$word = $match[0];
if[!$found[$word]] {
$found[$word] = TRUE;
$search[] = $word;
$replacement = str_replace[['', ';'], ['HTML Entity #', ''], $word];
$replace[] = $replacement;
}
}
$new_output = str_replace[$search, $replace, $output];
return $new_output;
}
function convertNamedHTMLEntitiesToNumeric[$args] {
$input = $args['input'];
return preg_replace_callback["/[&[a-zA-Z][a-zA-Z0-9]*;]/",function[$m]{
$c = html_entity_decode[$m[0],ENT_HTML5,"UTF-8"];
# return htmlentities[$c,ENT_XML1,"UTF-8"]; -- see update below
$convmap = array[0x80, 0xffff, 0, 0xffff];
return mb_encode_numericentity[$c, $convmap, 'UTF-8'];
}, $input];
}
print[FixUTF8[['input'=>"Oggi è un bel giorno"]]];
20