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

gfrobenius picture gfrobenius · Aug 27, 2014 · Viewed 16.4k times · Source

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!

Answer

Lucio picture Lucio · Mar 22, 2019

Using encodeURIComponent to wrap the value fixed the problem.

Broken:

`?value=${myValue}`

Working:

`?value=${encodeURIComponent(myValue)}`