0

So I'm developing a laravel app in my localhost which is a windows laptop but my app server is in a linux server. When I'm developing and saving in a textarea some random text with special chars like "Ç ~ º" everything is well saved in db and showed in browser. The problem is in the server (linux), it creates specials chars like "pátio nº 64/2 " and shows bad in the browser.

I've tried to change collation in the config/database.php file to the same as the db (we use portuguese collation) 'collation' => 'Latin1_General_CI_AS' and charset =>'utf8' but nothing changed.

Any ideas? I'm using a sql server database If I change the charset to latin1 isntead of utf8 the server shows a error

PDOException in Connector.php line 55
SQLSTATE [] (null) (severity o)

I've also tried ot use html decode entities before save in the db but didn't work. I really need some help in this issue...

Cátia Matos
  • 820
  • 1
  • 8
  • 26

2 Answers2

0

You have to change collate and charset. If you're are able to set collate and charset via config/database.php then you may do this way (for mysql):

'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',

But if you don't want to change DB collation then you have an option to change collation and charset for a specific table only. To do that use the following query:

ALTER TABLE your_table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
unclexo
  • 3,691
  • 2
  • 18
  • 26
0

In my controller I've used this before save,

$var = iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $request->input ( 'input1' ));

Cátia Matos
  • 820
  • 1
  • 8
  • 26