PluginProbe
Translation with DeepL API / 2.4.5
Translation with DeepL API v2.4.5
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
← All changes | includes/deepl-functions.php +17 -3 1.7.52.4.5 View file →
@@ -1,3 +1,17 @@
1 -<?php
2 -
3 -
1 +<?php
2 +
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 +