The following figure shows the php5.5.11macosx10.9.2, win7, and centOS6.3 codes: {code ...} the test results are as follows: Mac garbled windows and linux are normal after adding the pattern modifier, as follows: {code ...} search for information, so it is said: u (PCRE_UTF8 )...
The situation is as follows:
- Php 5.5.11
- Mac osx 10.9.2, win7, centOS 6.3
The Code is as follows:
Echo preg_replace ('/[\ s-] +/', '-', 'ashboard '). "\ n ";
The test results are as follows:
- Mac garbled
- Windows and linux are normal
After adding a pattern modifier, it is normal as follows:
Echo preg_replace ('/[\ s-] +/U','-', 'aku'). "\ n ";
Search for information:
U (PCRE_UTF8)
This modifier enables additional features that are not compatible with Perl in a pcre. The pattern string is treated as a UTF-8. This modifier is available in Unix from PHP 4.1.0 and win32 from PHP 4.2.3. Check the validity of the UTF-8 in the mode from PHP 4.3.5.
Excuse me:
- Does u mean to treat the matched characters as utf8? Is there any other function?
- My code is utf8, but why is it garbled only on mac (Unix?
Reply content:
The situation is as follows:
- Php 5.5.11
- Mac osx 10.9.2, win7, centOS 6.3
The Code is as follows:
Echo preg_replace ('/[\ s-] +/', '-', 'ashboard '). "\ n ";
The test results are as follows:
- Mac garbled
- Windows and linux are normal
After adding a pattern modifier, it is normal as follows:
Echo preg_replace ('/[\ s-] +/U','-', 'aku'). "\ n ";
Search for information:
U (PCRE_UTF8)
This modifier enables additional features that are not compatible with Perl in a pcre. The pattern string is treated as a UTF-8. This modifier is available in Unix from PHP 4.1.0 and win32 from PHP 4.2.3. Check the validity of the UTF-8 in the mode from PHP 4.3.5.
Excuse me:
- Does u mean to treat the matched characters as utf8? Is there any other function?
- My code is utf8, but why is it garbled only on mac (Unix?
The tree's utf8 indicates yese6 a0 91. Sensitive words should be understood here.
Second bytea0And\nIt is the same, so it is replaced with-, and the remaining two bytes on both sides become invalid ASCII and are displayed as question marks. As for platform differences, it is estimated that it is a so-called PCRE problem, if you are interested, you can go into and check it.