#46370 [Opn->Bgs]: translation mixup
| From: | jani@php.net | Date: | Thu, 23 Oct 2008 12:09:30 +0000 |
| Subject: | #46370 [Opn->Bgs]: translation mixup | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-129999@lists.php.net to get a copy of this message | ||
ID: 46370
Updated by: jani@php.net
Reported By: nikitin at freshframes dot com
-Status: Open
+Status: Bogus
Bug Type: Filesystem function related
Operating System: debian 4.0
PHP Version: 5.2.6
New Comment:
If you upload as latin1 it's stored as latin1, set your charsets
properly in the upload page and it works as expected. (fyi:
file_get_contents doesn't convert anything to anything, it's binary
safe)
Previous Comments:
------------------------------------------------------------------------
[2008-10-23 11:17:55] nikitin at freshframes dot com
Description:
------------
i upload a latin1 file to the debian server (move_uploaded_file)
this file is stored in utf8 (using utf8 translation in putty shows me
correct chars, using latin1 translation shows me the multibyte
chars...)
then i read the file into a var via file_get_contents and wonder why
mb_check_encoding( var, "UTF-8" ) returns false.
sending the var via browser to client with utf8 charset produces wrong
data, so i probably have latin1 data in my var.
now i use utf8_encode( var ) and everything works fine.
what do i need to set to get utf8 data from file reads, or why do i
need to encode it again?
Reproduce code:
---------------
move_uploaded_file( $_FILES['file']['tmp_name'][0], $file );
$data = file_get_contents( $file );
var_dump( array(
mb_check_encoding( $data, "UTF-8" ),
mb_check_encoding( utf8_encode( $data ), "UTF-8" ) );
Expected result:
----------------
[ true, true ]
Actual result:
--------------
[ false, true ]
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46370&edit=1