REST service and accented strings

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

REST service and accented strings

BrunoBB
Hi All,

I have some problems to handle accented string with Seasde REST.
The service is defined as follow:
testPut
        "This service is called by Orbeon when a user click on -Save- inside the Form Builder.
        A Form Definitions has been saved "
        | orbeonData |
        <put>
        <path: '/testPut'>

        orbeonData := Orbeon_Form_Data new.

        orbeonData xml: (self requestContext request rawBody "bodyDecodeUsing: 'ISO-8859-1'");
                document_id: '1';
                addToCache.

Using Postman from google is i do a "put" to the service with xml value:  <label>ó</label>. (accented o)

If i check Orbeon_Form_Data object at "xml" instance variable it answer: <label>ó</label>.

Does anyone has any idea what is happening ?

Now investigating this...

Regards,
Bruno
Reply | Threaded
Open this post in threaded view
|

Re: REST service and accented strings

BrunoBB
Hi,

I think is escaped character.

'ó' unescapePercents asString =  'ó' "answer true" so i will check more deeply in how to unescape the entire xml document.

Regards,
Bruno
Reply | Threaded
Open this post in threaded view
|

Re: REST service and accented strings

BrunoBB
Hi,

I think i will do in the service:

        orbeonData xml: (self requestContext request rawBody unescapePercents asString);
                document_id: '1';
                addToCache.

Does anyone has any other solution ?

Regards,
Bruno
Reply | Threaded
Open this post in threaded view
|

Re: REST service and accented strings

GLASS mailing list
In reply to this post by BrunoBB
Bruno ... just taking a look and I haven't wrapped my head around your
problem yet ... but it does jump out that you are using ISO-8859-1
encoding ...

I'm not complemently familiar with javascript conventions, but I think
that the default encoding for javascript is UTF8 ... it's also possible
that the encoding is done somewhere else (as part of transport mechanism
when the REST is put on the wire), so perhaps no special encoding needs
to be applied ...

Dale

On 08/06/2015 02:47 PM, BrunoBB via Glass wrote:

> Hi All,
>
> I have some problems to handle accented string with Seasde REST.
> The service is defined as follow:
> testPut
> "This service is called by Orbeon when a user click on -Save- inside the
> Form Builder.
> A Form Definitions has been saved "
> | orbeonData |
> <put>
> <path: '/testPut'>
>
> orbeonData := Orbeon_Form_Data new.
>
> orbeonData xml: (self requestContext request rawBody "bodyDecodeUsing:
> 'ISO-8859-1'");
> document_id: '1';
> addToCache.
>
> Using Postman from google is i do a "put" to the service with xml value:
> <label>ó</label>. (accented o)
>
> If i check Orbeon_Form_Data object at "xml" instance variable it answer:
> <label>ó</label>.
>
> Does anyone has any idea what is happening ?
>
> Now investigating this...
>
> Regards,
> Bruno
>
>
>
> --
> View this message in context: http://forum.world.st/REST-service-and-accented-strings-tp4841375.html
> Sent from the GLASS mailing list archive at Nabble.com.
> _______________________________________________
> Glass mailing list
> [hidden email]
> http://lists.gemtalksystems.com/mailman/listinfo/glass

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: REST service and accented strings

GLASS mailing list
I think the encoding is the problem.

ISO/IEC 8859-1:1998, Information technology — 8-bit single-byte coded graphic character sets — Part 1: Latin alphabet No. 1

But you are receiving what appears to be UTF-8. I'm no expert in this area, but I suspect that if you tell it the encoding is UTF-8, the web server will decode it for you. 8859-1 basically says (I think) to leave every 8-bit byte alone.


On Thu, Aug 6, 2015 at 3:10 PM, Dale Henrichs via Glass <[hidden email]> wrote:
Bruno ... just taking a look and I haven't wrapped my head around your problem yet ... but it does jump out that you are using ISO-8859-1 encoding ...

I'm not complemently familiar with javascript conventions, but I think that the default encoding for javascript is UTF8 ... it's also possible that the encoding is done somewhere else (as part of transport mechanism when the REST is put on the wire), so perhaps no special encoding needs to be applied ...

Dale


On 08/06/2015 02:47 PM, BrunoBB via Glass wrote:
Hi All,

I have some problems to handle accented string with Seasde REST.
The service is defined as follow:
testPut
        "This service is called by Orbeon when a user click on -Save- inside the
Form Builder.
        A Form Definitions has been saved "
        | orbeonData |
        <put>
        <path: '/testPut'>

        orbeonData := Orbeon_Form_Data new.

        orbeonData xml: (self requestContext request rawBody "bodyDecodeUsing:
'ISO-8859-1'");
                document_id: '1';
                addToCache.

Using Postman from google is i do a "put" to the service with xml value:
<label>ó</label>. (accented o)

If i check Orbeon_Form_Data object at "xml" instance variable it answer:
<label>ó</label>.

Does anyone has any idea what is happening ?

Now investigating this...

Regards,
Bruno



--
View this message in context: http://forum.world.st/REST-service-and-accented-strings-tp4841375.html
Sent from the GLASS mailing list archive at Nabble.com.
_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: REST service and accented strings

BrunoBB
Dale,

You are right is an encoding problem, this REST service is receiving a XML "put" from a Java application.
Now i'm using:
gsString := self requestContext request rawBody. "to get the XML from java"

And at some point the Java app do a "get" to receive the same XML.
Now i do:
((GRCodec forEncoding: 'utf-8') decode: gsString) asString

This has solved the problem. It seems that the REST service enconde the string at some point.

Thanks for your help.

Regards,
Bruno