how to detect encoding of uploaded csv file how to detect encoding of uploaded csv file linux linux

how to detect encoding of uploaded csv file


As someone noticed in the PHP docs here:

If you try to use mb_detect_encoding() to detect whether a string is valid UTF-8, use the strict mode, it is pretty worthless otherwise.

So you should try using the true param when detecting encoding:

mb_detect_encoding($str, mb_detect_order(), TRUE);

If you can predict some possible encodings, you can list them instead of using mb_detect_order().