What encoding is the white space character in this string? Cannot be replaced with "\ s"
Source: Internet
Author: User
What encoding is the white space character in this string? The test code cannot be replaced with & quot; \ s & quot;: $ url & nbsp ;=& nbsp; 'http: // www.google.com/ig/calculator? Hl = en & amp; q = 1 USD =? Tzs '; $ str & nbsp; = & nbsp; @ file_get_c what encoding is the blank character in this string? Cannot be replaced with "\ s"
Test code:
$ Url = 'http: // www.google.com/ig/calculator? Hl = en & q = 1 USD =? Tzs ';
$ Str = @ file_get_contents ($ url );
$ Str = preg_replace ("/[\ s \ v \ t \ r \ n] +/", "", $ str );
Echo "str: $ str ";
In the output result, the blank character after "1" at the beginning of "1 631.32137 Tanzanianshillings" cannot become old.
Please give me some advice. thank you! Share:
------ Solution --------------------
Echo htmlspecialchars ($ str );
The object html is not a space, and the display effect is a space.
------ Solution --------------------
Then replace it.
------ Solution --------------------
It is also a blank HTML symbol
------ Solution --------------------
You just need to copy it. it's not a space character.
------ Solution --------------------
Change all double quotes to single quotes and try again.
------ Solution --------------------
Add $ str = @ file_get_contents ($ url );
$ Str = iconv ("GBK", "UTF-8 // IGNORE", $ str );
With this added, you can replace it by converting it. this is because there are unrecognizable characters in the acceptance process, so that the conversion can be recognized.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.