PHP Code Conversion

Source: Internet
Author: User
Want to put
\xc3\xa6\xc2\x9d\xc2\x8e\xc3\xa5\xc2\x86\xc2\xac\xc3\xa5\xc2\x8f\xc2\x91

Turn into Chinese characters, how to turn?


Reply to discussion (solution)

It's like a code. You can't see what code encryption can only be written by the person to know that even if you know the password seems to be two times encrypted

$a = ' \xc3\xa6\xc2\x9d\xc2\x8e\xc3\xa5\xc2\x86\xc2\xac\xc3\xa5\xc2\x8f\xc2\x91 '; $a = str_split ($a, 4); $b = "; foreach ($a as $key = $value) {$b. = Chr (Hexdec ($value));} Var_dump (Iconv (' GBK ', ' utf-8 ', $b));


If it turns out wrong, it's coding.

Header (' content-type:text/html;charset=utf-8 '); $s = "\xc3\xa6\xc2\x9d\xc2\x8e\xc3\xa5\xc2\x86\xc2\xac\xc3\xa5\ Xc2\x8f\xc2\x91 "; Echo iconv (' Utf-8 ', ' latin1 ', $s);//must be read from the database $s = ' \xc3\xa6\xc2\x9d\xc2\x8e\xc3\xa5\xc2\x86\xc2\ Xac\xc3\xa5\xc2\x8f\xc2\x91 '; $s = str_replace (' \x ', ' ", $s); Echo iconv (' Utf-8 ', ' latin1 ', hex2bin ($s));
Li Dong hair li Dong Hair

The moderator of this section is worthy

Moderator

%c3%a4%c2%b8%c2%89%c3%a5%c2%8a%c2%a0%c3%a4%c2%b8%c2%80

What's the solution?

See more and know wide

$s = '%c3%a4%c2%b8%c2%89%c3%a5%c2%8a%c2%a0%c3%a4%c2%b8%c2%80 '; Echo iconv (' Utf-8 ', ' latin1 ', UrlDecode ($s));
Three plus One

%c3%a4%c2%b8%c2%89%c3%a5%c2%8a%c2%a0%c3%a4%c2%b8%c2%80

What's the solution?

Header (' content-type:text/html;charset=utf-8 '); $a = "%c3%a4%c2%b8%c2%89%c3%a5%c2%8a%c2%a0%c3%a4%c2%b8%c2%80"; echo iconv (' Utf-8 ', ' latin1 ', UrlDecode ($a));

@ Moderator Hello

\xc3\xa5\xc2\xad\xc2\x9f\xc3\xa6\xc2\xb3\xc2\xa2321

-\xc3\xa5\xc2\x85\xc2\x94\xc3\xa5\xc2\xad\xc2\x90-

T\xc3\xa5\xc2\xbe\xc2\x85\xc3\xa9\xc2\xb8\xc2\xbf

Where these codes are mixed with normal digital letters and so on, then using Hex2bin processing will be an error

And will not get the result of processing

Third floor moderator V5 Ah, again urine sex. Study,

@ Moderator Hello

\xc3\xa5\xc2\xad\xc2\x9f\xc3\xa6\xc2\xb3\xc2\xa2321

-\xc3\xa5\xc2\x85\xc2\x94\xc3\xa5\xc2\xad\xc2\x90-

T\xc3\xa5\xc2\xbe\xc2\x85\xc3\xa9\xc2\xb8\xc2\xbf

Where these codes are mixed with normal digital letters and so on, then using Hex2bin processing will be an error

And will not get the result of processing

Header (' content-type:text/html;charset=utf-8 '); $s = "\xc3\xa5\xc2\xad\xc2\x9f\xc3\xa6\xc2\xb3\xc2\xa2321-\xc3\ XA5\XC2\X85\XC2\X94\XC3\XA5\XC2\XAD\XC2\X90-T\XC3\XA5\XC2\XBE\XC2\X85\XC3\XA9\XC2\XB8\XC2\XBF "; Echo iconv (' Utf-8 ', ' latin1 ', $s);
Yes, this is possible.





Header (' content-type:text/html;charset=utf-8 '); $s = "\xc3\xa6\xc2\x9d\xc2\x8e\xc3\xa5\xc2\x86\xc2\xac\xc3\xa5\ Xc2\x8f\xc2\x91 "; Echo iconv (' Utf-8 ', ' latin1 ', $s);//must be read from the database $s = ' \xc3\xa6\xc2\x9d\xc2\x8e\xc3\xa5\xc2\x86\xc2\ Xac\xc3\xa5\xc2\x8f\xc2\x91 '; $s = str_replace (' \x ', ' ", $s); Echo iconv (' Utf-8 ', ' latin1 ', hex2bin ($s));
Li Dong hair li Dong Hair

You see the first time the moderator mentioned that he did not use double quotes, you know the reason for it.

This writing is more general

$s = ' \xc3\xa5\xc2\xad\xc2\x9f\xc3\xa6\xc2\xb3\xc2\xa2321-\xc3\xa5\xc2\x85\xc2\x94\xc3\xa5\xc2\xad\xc2\x90-t\xc3 \XA5\XC2\XBE\XC2\X85\XC3\XA9\XC2\XB8\XC2\XBF '; $f = Create_function ("," return \ "$s \"; "); echo iconv (' Utf-8 ', ' latin1 ', $f ());
Cantonese 321

Rabbit

T stay Hung

It's possible to write this, but some people don't like Eval.

$s = ' \xc3\xa5\xc2\xad\xc2\x9f\xc3\xa6\xc2\xb3\xc2\xa2321-\xc3\xa5\xc2\x85\xc2\x94\xc3\xa5\xc2\xad\xc2\x90-t\xc3 \XA5\XC2\XBE\XC2\X85\XC3\XA9\XC2\XB8\XC2\XBF '; Echo iconv (' Utf-8 ', ' latin1 ', eval ("return \" $s \ ";"));

Thank the Almighty Master (moderator), Amen ~


Header (' content-type:text/html;charset=utf-8 '); $s = "\xc3\xa6\xc2\x9d\xc2\x8e\xc3\xa5\xc2\x86\xc2\xac\xc3\xa5\ Xc2\x8f\xc2\x91 "; Echo iconv (' Utf-8 ', ' latin1 ', $s);//must be read from the database $s = ' \xc3\xa6\xc2\x9d\xc2\x8e\xc3\xa5\xc2\x86\xc2\ Xac\xc3\xa5\xc2\x8f\xc2\x91 '; $s = str_replace (' \x ', ' ", $s); Echo iconv (' Utf-8 ', ' latin1 ', hex2bin ($s));
Li Dong hair li Dong Hair

You see the first time the moderator mentioned that he did not use double quotes, you know the reason for it.

No, it's just a single quotation mark instead of a double quote.

@microlab2009

You don't know the app, it's not what you say.

For example, the following log needs to extract the value of the UN parameter

36.32.251.206--[13/feb/2014:10:44:57 +0800] "get/s.gif?h=aa.aa.com&sid=139225950488782186&at=mozilla/5.0 %20 (compatible;%20msie%2010.0;%20windows%20nt%206.2;%20trident/6.0;%20.net4.0e;%20.net4.0c;%20infopath.2;%20. net%20clr%203.5.30729;%20.net%20clr%202.0.50727;%20.net%20clr%203.0.30729) &w=1422&h=800&re=http:// www.aa.com/s?wd=%25E5%258D%2595%25E7%2589%2587%25E6%259C%25BA%25E4%25B8%258D%25E7%2594%25A8%25E7%259A%2584IO% 25e9%2585%258d%25e7%25bd%25ae%25e8%25be%2593%25e5%2585%25a5%25e8%25bf%2598%25e6%2598%25af%25e8%25be%2593%25e5% 2587%25ba%25e5%25a5%25bd&rsv_bp=0&ch=&tn=**&bar=&rsv_spt=3&ie=utf-8&rsv_sug3=31 &rsv_sug4=1371&rsv_sug1=6&rsv_sug2=0&inputt=3&url=http://aa.aa.com/icview-328428-1-1.html &t=0&asr=&un=\xc3\xa5\xc2\x8d\xc2\x81\xc3\xa5\xc2\xb9\xc2\xb4\xc3\xa5\xc2\x90\xc2\x8e\xc3\xa5\xc2\ x85\xc2\xab\xc3\xa6\xc2\x9c\xc2\x88 http/1.1 "http://aa.aa.com/icview-328428-1-1.html" "mozilla/5.0 ( Compatible; MSIE 10.0; Windows NT 6.2; trident/6.0) ""-"

  • 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.