Character encoding bug
mllr - February 15, 2009 - 13:49
| Project: | AMFPHP |
| Version: | 6.x-1.0-beta1 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | snelson |
| Status: | needs review |
Description
The module destroys characters like ä, ö, ü... even though I changed the setCharsetHandler settings in gateway.php
I could fix it using the trick described in the following link:
http://blog.richardolsson.se/blog/2008/12/character-encoding-bug-in-amfp...
Thanks for upgrading anyway

#1
Have you tried the new charset settings at admin/build/services/settings/amfphp.
I wonder then, should we just remove this line altogether as well as the configuration page? You tell me, I've never dealt with other encodings.
#2
…hmmm, I can’t find any charset settings under admin/build/services/settings/amfphp. Just the security options (use keys, use sessid). So my answer is no, I didn’t try those settings. But I think I don’t know what you mean, sorry.
I tried to solve the enconding with the setCharsetHandler-settings in amfphp’s gateway.php, but without success.
Right now I use "$gateway->setCharsetHandler( "utf8_decode", "ISO-8859-1", "ISO-8859-1" );" but it only works if I uncomment the same line in amfphp.module.
:-) Don’t ask me what to do, I’m not a PHP-Coder, not even an advanced Drupal-User, sorry. :-)
viele Grüße
Frank
#3
I had to change line 50 in the amfphp.module to
<?php$gateway->setCharsetHandler("iconv", "UTF-8", "UTF-8");
?>
To get Japanese to work before.
#4
thanks
#5
I had the same problem and just deleted that line 50 to solve it. It seems that the module can receive data in utf8 and stores it correctly in drupal, but if it serves data, it converts the utf8 data from drupal into ISO-8859-1 (in line 50), which should not be done, because flex handles it as utf8.
#6
Just wanted to add that we had to do the same thing because line 50 was overriding anything being set in gateway.php
-Loc
#7
Hi,
Just chiming in.
I had the same problem with Japanese too and you have to take out line 50.
Once it's out everything runs peachy.
The explanation I read is that Drupal turns everything internally to UTF-8 already there is no need to decode it again as it is already UTF-8 out of Drupal and by AMF messing with it, it screws it up when it enters Flash.
So when I update the AMFPHP module I have to take out line 50.
I had to do this recently and the problem was I had forgotten that this was necessary as I had done it a long time ago.
After a lot of panicking I re-found the article on Drupal where some kind gent explains the problem.
#8
Hi,
I had the same problem with the german special-characters (Ö,Ä,Ü,ö,ä,ü)
I deleted that line 50 to solve it.
#9
i make a patch that add admin screen to the amfphp module, where you can control the charset handler, and change the problematic line 50 to :
$gateway->setCharsetHandler(variable_get('amfphp_charset_mode', 'iconv'), variable_get('amfphp_charset_phpCharset', 'UTF-8'), variable_get('amfphp_charset_sqlCharset', 'UTF-8'));
and make the default charset handler utf-8.
#10
@perelman yuval: The patch contains your .project file (eclipse?). You should remove it.
Apart from that - it does the work, and allows flexibility where it's needed.
#11
@z.stolar thanks for the comment , i removed the project file and upload the file again.
#12
I had to make the same (remove the line from the amfphp.module file).
I suggest do not force the charset, but let the user choose it in the file amfphp/gateway.php
#13
I suggest use a copy of /modules/amfphp/amfphp/gateway.php (named for example, modules/amfphp/amfphp/drupal-gateway.php) and require it in the file amfphp.module (maybe the file could be placed in drupal/sites/default/ for example)
#14
@JuniorZ: The patch in #11 saves the need of editing files, and makes it easy for people to test different encodings, until the desired result is achieved.
#15
GREAT, that worked for me with Danish Character to. Thanks