Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 4 of 4 total |
German "Umlaute" in json |
Tue, Mar 19 2013 7:12 AM | Permanent Link |
Uli Becker | I need some data from a mysql database using a php script.
Everything works fine except the German "Umlaute". After using json_encode in php, the result is like that: D\u00fcsseldorf instead of Düsseldorf In my EWB application I use this code to populate the dataset: if SpieltageRequest.Statuscode = 200 then begin dsSpieltage.open; dsSpieltage.loadrows(SpieltageRequest.ResponseContent.Text); end; Any idea to solve this (I already tried different headers)? Here the (simplified) php code, the mysql database's collation is utf8_general_ci: <?php header('Content-Type: application/json; charset=UTF-8'); //header('Content-Type: application/json; charset=ISO-8859-1'); $response = array(); ... // get all rows from spieltage table $result = mysql_query("select * from spieltage where ...) or die(mysql_error()); // check for empty result if (mysql_num_rows($result) > 0) { // looping through all results $response["rows"] = array(); while ($row = mysql_fetch_array($result)) { $spieltag = array(); $spieltag["spieltageid"] = $row["spieltageid"]; ... // push single spieltag into final response array array_push($response["rows"], $spieltag); } echo json_encode($response); } else { } ?> |
Tue, Mar 19 2013 7:46 AM | Permanent Link |
Peter | Hello Uli,
i had the same problem and solved it with replacing the unicode escape sequences (found in a PHP-Forum): ---- zippp ---- function replace_unicode_escape_sequence($match) { return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE'); } [...] $json = json_encode($response); $json = preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $json); $json = str_replace('\/', '/', $json); echo $json: ---- zappp ---- Perhaps it is useful for you. Grüße aus Köln nach Düsseldorf P.S.: As a PHP-Noob it is hard for me to serve data from PHP-Code to an EWB-Application. I wish there would be an easier way (like a generator or something). --- Sorry for my weird english |
Tue, Mar 19 2013 7:57 AM | Permanent Link |
Uli Becker | Peter,
> Perhaps it is useful for you. Thanks a lot. That helps indeed. P.S.: As a PHP-Noob it is hard for me to serve data from PHP-Code to an EWB-Application. I wish there would be an easier way (like a generator or something). That would be great, off course. > Grüße aus Köln nach Düsseldorf Düsseldorf war nur ein Beispiel, ich bin in München , aber auch mit Umlaut. Uli |
Tue, Mar 19 2013 8:03 AM | Permanent Link |
Uli Becker | Works great! You saved my day.
Regards Uli |
This web page was last updated on Friday, November 1, 2024 at 07:01 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |