John John - 1 year ago 71
HTML Question

Non-Latin characters in html input fields

I am having an issue with non-Latin characters. For example, if I go to the link below and type in "ü" and press submit, İ get %C3%BC instead of that letter. I have tried to use

content="text/html; charset=utf-8 "
, but it did not work. Do you guys have any idea how I can avoid the issue?

Thanks in advance

Answer Source

You can't really avoid the issue; decoding of such characters needs to happen server-side. In PHP the urldecode function is used for this, so urldecode('%C3%BC') returns 'ü'. This behaviour is part of the way that forms work - if you look at the code for the Stack Overflow form that I'm using to submit this answer:

<form id="post-form" action="/questions/37262431/answer/submit" method="post" class="post-form">

I'm able to use the letter ü, but the form doesn't contain any extra attributes, because the server is decoding the '%C3%BC' before returning 'ü' to the client.