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 s:
$ 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!


Reply to discussion (solution)

Echo htmlspecialchars ($ str );
The object html is not a space, and the display effect is a space.

Thank you for your reply.

Can I add something to the regular expression preg_replace in the above code, and then remove this invisible blank space?

Then replace it.

Add a row...

$ 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 );
$ Str = preg_replace ("//", "", $ str );
Echo "str: $ str
";

It is also a blank HTML symbol

I know that "" is a blank sign. I don't know what to add to the above regular expression to remove the blank space after "1" in the string.

You just need to copy it. it's not a space character.

There is a large comment in the first part of the php page. how can I find out which one was written,
The content of the comment is as follows:

You just need to copy it. it's not a space character.

Moderator,
The blank is not a space, but I don't know how to remove it?

Change all double quotes to single quotes and try again.

Change all double quotes to single quotes and try again.

Changed. Similarly, the blank space cannot be removed.

Code:

$url = 'http://www.google.com/ig/calculator?hl=en&q=1USD=?tzs';$str = @file_get_contents( $url );$str = preg_replace('/"/', '\'', $str);$str = preg_replace('/[\s\v\t\r\n ]+/', '', $str);$str = preg_replace('/ /', '', $str);echo "str:$str";


Output result:
Str: {lhs: '1u. S. dollar ', rhs: '1 631.32137Tanzanianshillings', error: '', icc: true}

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.

Oh, you can!
Thank you!

Related Article

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.