#46370 [Bgs]: translation mixup
| From: | nikitin at freshframes dot com | Date: | Thu, 23 Oct 2008 15:08:59 +0000 |
| Subject: | #46370 [Bgs]: translation mixup | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-130011@lists.php.net to get a copy of this message | ||
ID: 46370
User updated by: nikitin at freshframes dot com
Reported By: nikitin at freshframes dot com
Status: Bogus
Bug Type: Filesystem function related
Operating System: debian 4.0
PHP Version: 5.2.6
New Comment:
ok, i just figured out the problem, seems i encode the files twice to
utf8..
now i removed all encodings and the file is uploaded in latin1.
once encoded it compares data like i need with mysql utf8 columns.
so, this here is fixed and may be closed.
sorry and thanks for your support.
Previous Comments:
------------------------------------------------------------------------
[2008-10-23 13:43:57] nikitin at freshframes dot com
i am pretty sure, that i use utf8 in the upload page.
my framework is joomla and it uses utf8
when i download the uploaded file the umlauts are corrupted -> utf8
encoded
so there is still the question why i need to encode it in php again.
------------------------------------------------------------------------
[2008-10-23 12:09:30] jani@php.net
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)
------------------------------------------------------------------------
[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