PluginProbe
Translation with DeepL API / trunk
Translation with DeepL API vtrunk
trunk 0.1.20180323 1.0 1.2.5.1 1.5.2.5 1.7.5 2.4.3.12 2.4.3.9 2.4.5
wpdeepl / includes / deepl-functions.php

deepl-functions.php in Translation with DeepL API trunk, at includes/deepl-functions.php

18 lines 742 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3 /**
4 * convert Unicode entities
5 * */
6 function deepl_unicode_decode( $string ) {
7 $string = preg_replace_callback( '#\\\\u([0-9a-fA-F]{4})#', function ( $match ) {
8 return mb_convert_encoding( pack( 'H*', $match[1] ), 'UTF-8', 'UCS-2BE' );
9 }, $string );
10 $string = str_replace( '\u0002', ' ', $string );
11 $string = preg_replace_callback('/&#x([0-9a-fA-F]{3,4});/', function ($match) {
12 return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
13 }, $string);
14 //$string = preg_replace_callback('/&#([0-9a-fA-F]{3,4});/', function ($match) { return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE'); }, $string);
15 return $string;
16 }
17
18