tua Posted August 3, 2016 Share Posted August 3, 2016 <?php $data = ["name" => utf8_encode("Lutz Übelgönner"), "street" => utf8_encode("Änderärger Straße 18")]; //$data = ["name" => "Bob Smith", "street" => "19 Main Street"]; $jdata = json_encode($data, JSON_ERROR_UTF8); print $jdata; ?> I do (see code above) in order to be able to json_encode, which gives me: {"name":"Lutz \u00dcbelg\u00f6nner","street":"\u00c4nder\u00e4rger Stra\u00dfe 18"} How do I turn this into something that will make Germans happy? Thanks for any suggestions! Quote Link to comment https://forums.phpfreaks.com/topic/301747-encodingdecoding-issues/ Share on other sites More sharing options...
Jacques1 Posted August 3, 2016 Share Posted August 3, 2016 (edited) So what do you not like? The \u escape sequences? JSON_UNESCAPED_UNICODE However, this is an entirely unnecessary step, because JSON is just an intermediary data format. As soon as you parse it, you'll get human-readable text. Edited August 3, 2016 by Jacques1 Quote Link to comment https://forums.phpfreaks.com/topic/301747-encodingdecoding-issues/#findComment-1535542 Share on other sites More sharing options...
requinix Posted August 3, 2016 Share Posted August 3, 2016 By learning what those \us mean and thereby understanding that they're supposed/allowed to be there? And by saving your file in UTF-8 format and getting rid of those calls to utf8_encode. And by dropping the JSON_ERROR_UTF8. If you look at the documentation you'll see it's not one of the allowed options. And really, it has "error" right there in the name: does that sound right? Quote Link to comment https://forums.phpfreaks.com/topic/301747-encodingdecoding-issues/#findComment-1535543 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.