What encoding is the white space character in this string? Cannot be replaced with "s"-php Tutorial

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; www. google. comigcalculator? Hlen & amp; q1USD? Tzs; $ str & nbsp; @ file_get_contents (& nbsp; $ url & nbsp;); $ st 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.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.