-3

I've sent a query string like this by JS to a PHP 7.1 app

?com=item&title=Hello%uD83D%uDE99

and should get

Hello

but it is

Hello??????

Please F1...:)

I use JSHttpRequest class to do so

Thanks

sam
  • 31
  • 3
  • 2
    What do you mean, it is "Hello??????"? How do you observe this? – Sergio Tulentsev Feb 11 '18 at 22:00
  • I used every thing, **json_decode($_GET['title']) ** , **print_r($_GET)** , **preg_replace_callback('/\\\\u([0-9a-fA-F]+)/', function ($match) { return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UTF-16BE'); }, $str); return $str;** and so on... – sam Feb 11 '18 at 22:11
  • 2
    Possible duplicate of [How to show emojis in PHP](https://stackoverflow.com/questions/37410967/how-to-show-emojis-in-php) –  Feb 11 '18 at 22:14
  • @rtfm now it is **Helloí ½íº** – sam Feb 11 '18 at 22:17
  • `Hello%uD83D%uDE99` turned in to `Salamí ½íºa` well thats odd, how about posting the code you used –  Feb 11 '18 at 22:18
  • @rtfm function decodeEmoticons($src) { $replaced = preg_replace("/\\\\u([0-9A-F]{1,4})/i", "$1;", $src); $result = mb_convert_encoding($replaced, "UTF-16", "HTML-ENTITIES"); $result = mb_convert_encoding($result, 'utf-8', 'utf-16'); return $result; } – sam Feb 11 '18 at 22:20
  • 1
    look at the input, one simple change will make this work –  Feb 11 '18 at 22:24
  • thanks @rtfm, i collect data with json and then serialize it and send via AJAX. so i have some restrictions. OK i'll try to change the input – sam Feb 11 '18 at 22:34
  • % to \ will make the above function work –  Feb 11 '18 at 22:43

1 Answers1

0

Added this line:

this.queryText = this.queryText.replace(/\%(u[0-9a-f]{4})/ig, '\\$1');

before

xr.send(this.queryText);
this.span = null;

in JsHttpRequest.js:422 to fix query string

ThanX to all

sam
  • 31
  • 3