Processing PHP Files Using UTF-8 Special Characters

It seems that file processing in PHP does not work with certain characters (e.g.) encoded with UTF-8 if the path is hard-coded and the php file is saved as UTF-8.

Is it possible to make it work with all (or most western characters)? Is there a library that allows this to be possible? Because I could not find.

For example, a folder with the name äöü&()éèàâêûô@$+ç%&=! £ _; {[]} ~ '¢ ¬§ ° # @ | ... € `in windows will not work with is_dir ().

EDIT: SOLUTION

Ok, I found a solution. I haven't tested it completely yet, I'm not sure if it hasn't passed the test yet, and I don't know if this is the best practice, but encoding the string back to ANSI seems to do the trick (at least for the string I published).

$string = iconv(mb_detect_encoding($string, "auto"), 'Windows-1252', $string);

I think this should work with the default setting for most western Windows computers.

+5
source share
1 answer

I would also refuse to work with such a folder! :-)
Jokes, you can try to save the file as UTF-16, since this should be the encoding that Windows uses internally.

0
source

All Articles