PHP restore 16 Binary special characters

Source: Internet
Author: User

16-Step tab for special characters: https://websitebuilders.com/tools/html-codes/ascii/

Can be converted by the Hexdec () and chr () methods,

Example:

<? XML version=\x221.0\x22 encoding=\x22utf-8\x22 ?>\x0a<IDaffiliate event_id   refalias

Where \x22 is the double quote ", and \x0a is the change number \ n, through some methods after conversion:

    $str= "<?xml version=\x221.0\x22 encoding=\x22utf-8\x22?>\x0a<order id=\x22test\x22 affiliate=\x22main\x22 event_id=\x221\x22 ref=\x22tpcya\x22 alias=\x22\x22/> "; functionHexdec_string ($content) {        Preg_replace_callback(            "(\\\\x ([0-9a-f]{2})) I",function($matches) {return CHR(Hexdec($matches[1]);},//$string            $content        ); return $content; }    Echo Htmlspecialchars(Hexdec_string ($str), ent_quotes); Export the contents of XML as plain text

Results:

<? XML version= "1.0" encoding= "Utf-8" ?> <  ID= "Test"  affiliate= "main"  event_id= "1"  ref  = "Tpcya"  alias= ""/>

Reference: HTTPS://STACKOVERFLOW.COM/QUESTIONS/12238657/DECODING-JAVASCRIPT-ESCAPE-SEQUENCES-IN-PHP-X27-X22-ETC
http://php.net/manual/en/function.preg-replace-callback.php

PHP restore 16 Binary special characters

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.