File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes URL, UTF-8 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "URL, UTF-8" Watch "URL, UTF-8" New topic


Dave Wingate
Ranch Hand

Joined: Mar 26, 2002
Posts: 262
Hi Ranchers,
I'm in a bit of a pickle and am hoping someone will set me in the right direction. The problem I'm trying to solve is in the context of a web application. The user types a character string in the browser, then we use AJAX to pass the user's string to the server, which persists the string to the DB. All pretty normal stuff. The problem arises when the user's string contains international symbols.

if the user types in "bénévoles" we call encodeURIComponent(..) to get "b%C3%A9n%C3%A9voles" ... the value that is stuffed into the AJAX request to the server. The problem is that sometimes the value received by the server is not "bénévoles" but "bénévoles" .... strange stuff! I say that the server sometimes gets that "bénévoles" value because I've only been able to reproduce the behavior on a deployed instance of our product, not on my local development machine. The most obvious delta I see between my development box (no problem) and our deployed product (user text garbled) is the the former isn't using SSL, but the latter does.

I'm thinking I'll try to introduce SSL to my development box in an effort to reproduce the problem ... but I'm wondering if I'm wasting my time. Has any one ever seen AJAX+SSL cause encoding problems (like the one I describe above)?

Any advice or suggestions are greatly welcomed.

Fun programming etcetera!
Dave Wingate
Ranch Hand

Joined: Mar 26, 2002
Posts: 262
I did eventually figure this out. And the problem had nothing to do with SSL. For anyone else who needs to solve a similar problem, the root cause for me was an uber-old application server that didn't properly decode UTF-8.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: URL, UTF-8
jQuery in Action, 3rd edition