It turns out this is a well known glitch in web development especially when done in Java. The main reasons for the mess are
- Web browsers do not specify the encoding of posted data
- Java Servlet specification says that default request encoding should be ISO-8859-1 in contrast to UTF-8 which is universally used nowadays
Tomcat FAQ recommends creating a filter to set the request encoding.
But when using Wicket there is no such issue as they fix the request encoding to UTF-8 as described in How to change the character encoding.
Unfortunately Sling guys did it in another way (SLING-508) which requires me to put a hidden input named _charset_ with the value UTF-8 in all my forms. So they have adopted the ugly IE hack. :(
This is also described in Sling documentation.
I wish Sling had a way to set this to UTF-8 in one place and get rid of it.
Sometimes web development is so frustrating.
Update: Mar 2nd
After picking up this discussion on Sling mailing list the guys there decided after all to make this configurable, see SLING-1998.
Great! My forms now work without the _charset_ hack.
Hi, Great information.
ReplyDeleteA great first impression and a positive user experience are the keys to running a successful website.
Thanks for sharing a nice post.