views:

35

answers:

2

I have this function inside a php file:

mysql_query("SET NAMES 'utf8'") or die(mysql_error()); 
mysql_query("SET CHARACTER SET 'utf8'") or die(mysql_error());

    some stuff happening here,

rename($src, $dest.$cat);

Thats on the server, and is the setup I have today which works (atleast on my browsers).

Now, on my local machine (my own laptop with wampserver) this wont work unless I do this:

mysql_query("SET NAMES 'utf8'") or die(mysql_error()); 
mysql_query("SET CHARACTER SET 'utf8'") or die(mysql_error());

      some stuff happening here

$cat=utf8_decode($category);
rename($src, $dest.$cat);

And I also have meta=utf-8 in this php file.

$cat gets its content from a mysql_query...

I would like to know the difference (why it isn't working the same way on the server and on my local machine)?

And I would like to know if this will cause problems on different users browsers, by having it the way it is

A: 

both meta HTML tags and SQL queries do not affect filesystem operations.

it is probably a filesystem issue. Windows may recode your filenames.

Col. Shrapnel
A: 

Filesystem operations in Windows require that you specify the paths/filenames in the codepage Windows is using.

SO I'd guess your codepage is probably something like cp1252, hence you must use utf8_decode. Note that, unfortunately, you cannot set Windows' codepage to UTF-8 (65001).

On Linux,on the other hand, you can use whatever encoding you wish. However, you must be consistent -- if you save a file using a UTF-8 filename, you must read it using the same byte sequence.

Artefacto