Opened 15 years ago
Closed 14 years ago
#81 closed defect (fixed)
MapServer/php/LoadMap.php sends native php string instead of utf8-encoded string
|Reported by:||schneiderei||Owned by:||madair|
|Severity:||Major||Keywords:||encoding, php, ajax|
|External ID:||Operating System:||All|
Using MapServer 5.0.2 as rendering engine for my Fusion application, I have issues with character encoding: All my ä, ö, and ü became ? or other cryptic characters. I did some research, and I think that the problem comes from encoding heterogeneities: Ajax sends strings as utf8 by default, php uses 1byte strings by default.
MapServer/php/LoadMap.php is responsible for generating a json-string from what MapScript reads from the map file. It sends it back via Ajax with:
The function var2json generates a regular php string. I believe that this string needs to be converted to utf8 before it can be sent. I altered the above line to:
and my ä, ö, and ü are now displayed properly in the Fusion application.
Change History (3)
comment:1 by , 15 years ago
|Milestone:||1.1 → 2.0|
comment:2 by , 14 years ago
PHP's utf8_encode function is used to convert an ISO-8859-1 string into a utf-8 string. If the data is already in utf8 you would not need to do this.
I would have to assume if that was the fix for this issue then your data would have had to been in ISO-8859-1.
comment:3 by , 14 years ago
|Status:||new → closed|
Modified var2json to always return utf8 encoded strings.
I want to think about this one a little more and solicit feedback from some other developers, but I do believe that we need to do this. We should probably also look elsewhere in the PHP code in both MapServer and MapGuide and review the output methods to make sure we are always using the right encoding.