Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Php utf8 / unicode encoding

I have a strings like

$string1 = 'love is all mine 🔥';
$string2 = '🔥Sarah is good girl⭐';
$string3 = 'हिन्दी ya ⭐';
$string4 = 'hái 还/還 ("still"), yǐjīng 已经 ';

i want to encode them in a harmless encoded strings like

Api Hatal\u0131d\u0131r. L\u00fctfen kontrol ederek tekrar deneyiniz

in which no special charactor and utf8 character so that i can use it in javascript. I have tried utf8_encode() and mb_convert_encoding( $string4 , 'UTF-8', 'UCS-2BE');. utf8_encode() is simply not working as it is giving error in javasciprt (because i want to create json response and to use it in my code). and mb_convert_encoding( $string4 , 'UTF-8', 'UCS-2BE'); is converting whole string into other Chinese characters.

Answer*

Draft saved
Draft discarded
Cancel
1
  • will it make utf8 charactors as \u0131d\u0131 ? Commented Dec 1, 2018 at 12:03

lang-php

AltStyle によって変換されたページ (->オリジナル) /