Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome form POST shows "(unable to decode value)" and database stores it as a question mark

I have a test site and test DB both set to windows-1252. When I type Alt+234 into Chrome it puts this symbol in the field: Ω. And when I submit the form it posts and stores it as Ω I'm assuming this is the browser saying "hey, this isn't in the specified charset but I do know of an html equivalent, so I'll post that instead". Fine. The symbol appears properly after saving, I can save, save, save, and it always appears fine. But if I try the same thing with Alt+230 the browser does not submit it's html entity value of µ. Instead I see "(unable to decode value)" when viewing the POST in the Chrome DevTool window. And it ends up being stored in the database as a question mark.

Why does it treat Alt+234 (Ω) differently than Alt+230 (µ)?

I know I should switch to UTF8 but I still would like to know why it is functioning this way. Thanks!

like image 318
gfrobenius Avatar asked Aug 27 '14 20:08

gfrobenius


1 Answers

Using encodeURIComponent to wrap the value fixed the problem.

Broken:

`?value=${myValue}`

Working:

`?value=${encodeURIComponent(myValue)}`
like image 132
Lucio Avatar answered Sep 25 '22 15:09

Lucio