ID:               34928
 User updated by:  clemens at gutweiler dot net
 Reported By:      clemens at gutweiler dot net
-Status:           Open
+Status:           Closed
 Bug Type:         WDDX related
 Operating System: Linux
 PHP Version:      4.4.0
 New Comment:

Solution:
setlocale( LC_ALL, 'de_DE.UTF-8' );

Background:
wddx use the c-function iscntrl() which use the locales system to
determinate if a character is okay or have to be encoded with <char
code='%02X'/>.
So if you have a non-UTF-8 locales default, the determination of the
char fails.


Previous Comments:
------------------------------------------------------------------------

[2005-10-24 17:02:17] clemens at gutweiler dot net

Hint: With PHP 4.3.11 the WDDX returns the correct Chars.

------------------------------------------------------------------------

[2005-10-24 16:44:00] clemens at gutweiler dot net

"Real" Unicode Chars does not work, too.
But utf8_encode() of chr() should return valid chars.

Test for "real" unicode chars:

<?php
        header( 'Content-Type: text/html; charset=UTF-8' );
?>
<html>
        <body>
                <form method="post">
                        <textarea name="text"><?php echo $_POST['text'] 
?></textarea>
                        <input type="submit"  />
                </form>
        </body>
</html>
<pre>
<?php
        
        $text = 'umlaute: '.chr( 220 ).chr( 228 ).chr( 246 ).chr( 223 );
        $text = utf8_encode( $text );
        
        if( isset( $_POST['text'] ) ) $text = $_POST['text'];
        
        var_dump( $text );
        
        $wddx = wddx_serialize_value( $text );
        var_dump( htmlentities( $wddx ) );
        
        $data = wddx_deserialize( $wddx );
        var_dump(  $data );
        
        $data = wddx_deserialize( '<?xml version="1.0" encoding="UTF-8"
?>'."\n".$wddx );
        var_dump(  $data );
        
        $data = wddx_deserialize( '<?xml version="1.0" encoding="ISO-8859-1"
?>'."\n".$wddx );
        var_dump(  $data );
        
        show_source( __FILE__ );
?>
</pre>

With PHP 4.4.0 and 5.0.5 i do not get valid UTF-8 chars back.

------------------------------------------------------------------------

[2005-10-21 19:23:42] [EMAIL PROTECTED]

Try to use real UTF8 chars instead of chr().

------------------------------------------------------------------------

[2005-10-20 12:01:24] clemens at gutweiler dot net

Why is this bug bogus?

It use utf8_encode to encode the data to UTF-8.

The manual says also: "Note: If you want to serialize non-ASCII
characters you have to convert your data to UTF-8 first (see
utf8_encode() and iconv()).".

So the code should be correct?

------------------------------------------------------------------------

[2005-10-20 11:20:53] [EMAIL PROTECTED]

Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

See bug #34913.


------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/34928

-- 
Edit this bug report at http://bugs.php.net/?id=34928&edit=1

Reply via email to