Ajax / GroovyGrails Post data coming over with unexpected leading character. Who is encoding/decod

Posted by ????? on Stack Overflow See other posts from Stack Overflow or by ?????
Published on 2010-04-28T19:12:54Z Indexed on 2010/04/28 19:17 UTC
Read the original article Hit count: 242

Filed under:
|
|
|
|

I'm having an encoding issue, and I'm not sure where to look for the problem.

I have this Ajax.Request function (prototype library) sending data to a Groovy/Grails encoder

var myAjax = new Ajax.Request(url, {method:'post', encoding:'UTF-8', contentType:'application/x-www-form-urlencoded', parameters:{'content':new_content}, onSuccess:success, onFailure:failure});

The data is coming in with an unexpected %A0 at the beginning:

I have this simple controller that just echos the content back:

def titlechange = {
    def content = URLDecoder.decode(params['content'])
    printf("Content: %s; DecodedContent = %s\n", params['content'], content)
    response.characterEncoding='UTF-8'
render content
}

the debug print statement shows:

Content: %A0Hello%2C%20world%21; DecodedContent = †Hello, world!

Where is that %A0 coming from?

My grails configuration has this:

// The default codec used to encode data with ${}
grails.views.default.codec="none" // none, html, base64
grails.views.gsp.encoding="UTF-8"
grails.converters.encoding="UTF-8

Is the issue on the grails side or on the JavaScript side?

© Stack Overflow or respective owner

Related posts about grails

Related posts about groovy