After upgrading to Laravel Valet I now have strange encoding issues on my application. This didn't happen when running homestead.
Example:

We have just installed it on a new El Capitan, and the encoding issues persists. What is going on? Hmmm
I am also having this issue.
I'm getting
"Malformed UTF-8 characters, possibly incorrectly encoded"
in
/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php
when trying to encode json in my laravel application.
Any suggestions?
Can you show me the text that's causing the problem so I can try and reproduce locally? Is it a problem if you include the text in a view by hand, or only if coming from the database?
For what it's worth, this is working for me directly in a view as well as coming from the database:


If it's coming from the database, did you choose the correct table encoding and collation when creating the database? Here's what I have:

Hi @adamwathan
This is indeed very strange. It only happens from the database. I think this has something to do with MariaDB since we just switched to that with Laravel Valet.
exit('W酶lk'); // ouputs "W酶lk" (awesome name)
exit(User::find(2)->lastname // outputs "W锟斤拷lk" (not-so-nice name)
In my database:

Create table syntax:
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`firstname` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`lastname` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL
)
FYI: We use doctrine/dbal don't know if this could interfere in anyway.
This is from database.php:
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
And output of SHOW VARIABLES LIKE 'char%';

What does the data look like in the database? Can you try switching to SQLite just to try and isolate the MariaDB issue? It's a real pain in the ass to install MySQL and MariaDB on the same machine, haha... I will try at some point today though.
Working for me with MariaDB the same as it did with MySQL 馃
Is there any way you can create a sample project that demonstrates the issue, including maybe a seeder or something that when run is causing this problem?
Interesting. Inside my table it looks perfect as well.
I'm afraid something else in my application could be causing this. it has been upgraded from laravel 4.2 all the way to l 5.1
Here's a demo project that works for me, just clone, create a database, migrate and seed, then hit / and /json to check output:
Downloading your project works. Using the same database on my old application does not.
Current ideas for why this could be happening:
1) Your project is 5.3.*, mine is 5.2.*. Could there be any issue in this?
2) My project initially started being 4.2, and has since then been upgraded to Laravel 5.2. Could this have anything to do with the issue?
I have narrowed this down to something in my application. If you have any suggestions where I could start debugging I'd be grateful. I am lost at the moment. I LOVE MY JOB! <3
UPDATES:
dd(DB::select('select * from users where id = ?', [2]));User it works. Must be something in my User model. Hmm.Here's the mother f*cker:
/**
* Get the user's last name.
*
* @param string $value
* @return string
*/
public function getLastnameAttribute($value) {
return UCWORDS(STRTOLOWER($value));
}
STRTOLOWER has the wrong charset.
Solution:
Using mb_strtolower
Glad you found the issue!
Most helpful comment
Here's the mother f*cker:
STRTOLOWERhas the wrong charset.Solution:
Using
mb_strtolower