Skip to content

Web Developer Blog

Decode unicode escape sequences to proper UTF-8 encoded characters

$string = preg_replace_callback('/\\\\u([0-9a-fA-F]{4})/', function ($match) {
    return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
}, $string);

Reference:
http://stackoverflow.com/questions/2934563/how-to-decode-unicode-escape-sequences-like-u00ed-to-proper-utf-8-encoded-cha

Author adminPosted on February 7, 2015Categories PHP

Post navigation

Previous Previous post: Install ffmpeg and ffmpeg-php in Amazon AMI
Next Next post: Apache SNI

Categories

  • Amazon EC2
  • Apache
  • Apple
  • Bootstrap
  • Browser
  • Campaign Monitor
  • CDN
  • CentOS
  • Chrome
  • Composer
  • Concrete5
  • cPanel
  • CSS
  • Debian Linux
  • DNS
  • Drupal
  • eDM
  • Facebook
  • FirePHP
  • Flash
  • git
  • Gmail
  • Google Apps
  • Google Map
  • Horde
  • Hosting
  • HTML
  • HTML 5
  • Image Optimization
  • iPad
  • Java
  • Javascript
  • jQuery
  • Linux
  • Mac
  • Magento
  • Materials
  • MetaWeblog
  • MODx
  • MySQL
  • Nginx
  • Node.js
  • Payment Gateway
  • Paypal
  • Perl
  • Photoshop
  • PHP
  • Plesk
  • Programming
  • Push Message
  • Putty
  • React Native
  • Security
  • SEO
  • Shopify
  • SSH
  • SSL
  • Sublime Text
  • Tumblr
  • Uncategorized
  • WampServer
  • Web
  • Web Design
  • Windows
  • Wordpress
  • XenServer












Web Developer Blog Proudly powered by WordPress