mercredi 22 février 2017

Convert to proper encoding when uploading file in php

I'm trying to get proper encoding for a file that is uploaded in Laravel.

I'm uploading the file using new FormData() which should be i utf-8 already. But it seems to have some issues.

I tried some encoding, and this is working, but of course I don't want to deal with things on a case by case basis. Haven't been able to figure out how to convert further back into proper utf-8 format.

$str = file_get_contents($file->getPathName());
$str = mb_convert_encoding($str, 'HTML-ENTITIES', "UTF-8");

$str = str_replace('�', '’', $str);
$str = str_replace('�', '“', $str);
$str = str_replace('�', '”', $str);



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lIcVt9
via IFTTT

Aucun commentaire:

Enregistrer un commentaire