No garbled characters are found in Chinese and English sentences. Idea: 1. encode the string with urlencode. 2. use regular expressions to search for statements ending with transcoding punctuation. 3. urldecode decoding data [code] [PHP] Code 1 echourlencode (,-.-? -! -;-,-. Ideas:
1. encode the string with urlencode.
2. use regular expressions to search for statements ending with transcoding punctuation.
3. urldecode decoding data
[Code][PHP] code
1
echo
urlencode(
',-.-?-!-;-,-。-?-!-;-......'
).PHP_EOL;
2
$str
=
"Test,
Test
.
Test
?
Test
!
Test
;
Test
,
Test
。
Test
? Test! Test and test ......"
;
3
echo
$str
;
4
$str
= urlencode(
$str
);
5
preg_match_all (
'/(.*?)(\.{3,6}|%2C|\.|%3F|%21|%3B|%EF%BC%8C|%E3%80%82|%EF%BC%9F|%EF%BC%81|%EF%BC%9B)/'
,
$str
,
$matchs
);
6
foreach
(
$matchs
[0]
as
$v
){
7
$newArr
[] = urldecode(
$v
);
8
}
9
var_dump(
$newArr
);
Encoding 1. encode the string with urlencode. 2. use regular expressions to search for statements ending with transcoding punctuation. 3. urldecode decoding data [code] [PHP] Code 1 echo urlencode (,-.-? -! -;-,-....