php displays unicode escaped characters

The problem is age old: php + mysql + utf-8 encoding

We have a two component model: a backend service, that provides access to some json data via web-access and some client, that displays the data. the backend reads data from a mysql source, which is of collation type 'utf8 - default collation', the php script is utf-8 encoded.

The problem is that the rendered json data contains escaped unicode characters like 'Rungestra\u00dfe 20'. what could be done to see the 'real' entity like 'ß' in this case?

Answers


The problem is that the rendered json data contains escaped unicode characters like 'Rungestra\u00dfe 20'

Why is that a problem? \u00DF is perfectly valid JSON syntax for the letter ß. Any JSON decoder will parse that string literal escape into the single character U+00DF Latin Small Letter Sharp S. For example if your client is a web browser then JSON.parse().

ß can be included in an HTML document as-is, you do not have to escape it to ß or ß.


Found this by google should help here. http://stackoverflow.com/a/2577882/2422553

Try mb_convert_encoding() with the "to" encoding as 'HTML-ENTITIES', and (if necessary) the "from" encoding set to 'UTF-8' or whichever Unicode encoding you're using.


Need Your Help

Create folder in client system

c# asp.net-3.5

My application is hosted on IIS 7.0. There is a scenario where end user save the image (from my application) into his/her machine. Now my question is can we make a default folder in end user machin...

Jquery Dialog box- hide Address

javascript jquery jquery-mobile

How do I redirect the user to another page withing the same website?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.