Forum Stats

  • 3,784,351 Users
  • 2,254,928 Discussions
  • 7,880,790 Comments

Discussions

ORDS - request charset

Vanja Keglević
Vanja Keglević Member Posts: 30 Green Ribbon

Hello,

I'm having problems when issuing http requests to ORDS using charsets other than utf-8(which works fine). I tried windows-1250, iso-8859-2 and utf-16. Neither of them gets parsed correctly in ORDS, for non ascii charaters I get "?" charaters.

Does ORDS handle properly charsets other than utf-8?

Thanks

«1

Answers

  • thatJeffSmith-Oracle
    thatJeffSmith-Oracle Distinguished Product Manager Posts: 8,272 Employee
    edited Mar 20, 2019 9:34AM

    ORDS is Java which by definition is pure Unicode

    Do you have an example? Those always help. And I assume you are looking at the raw data returned and not how your client/viewer/browser is choosing to render said responses?

  • Vanja Keglević
    Vanja Keglević Member Posts: 30 Green Ribbon
    edited Mar 20, 2019 9:55AM

    Jeff,

    I'm a Java developer so I know that charset should and can be handled correctly. But it's certainly not handled "by default" in Java.

    My issue is only with the charset of the request, not with the ORDS response.

    I don't have an example, but could try to make one on apex.oracle site.

  • thatJeffSmith-Oracle
    thatJeffSmith-Oracle Distinguished Product Manager Posts: 8,272 Employee
    edited Mar 20, 2019 12:49PM

    no need for that, just share your request, and describe what the handler code is doing

    for example i already have an ECHO service, i could test that to see if i could send a 'funny character' and get it back correctly, but I'd rather not guess what you're doing/seeing

  • user11981878
    user11981878 Member Posts: 1
    edited Mar 21, 2019 8:52AM

    Gentlemen,

    I'm also struggling with encoding in ORDS.

    My database is in MSWIN1252 and exposes data through ORDS.

    As far as my knowledge goes, ORDS is like a java wrapper around my pl/sql.

    If my pl/sql function returns a resultset with eg french characters inside (éëè...) the response of my request shows me other characters eg:

    value: FÖRSTERÖË

    becomes:FÖRSTERÖÃ

    (request property "Encoding" in soapui not specified)

    I'm using SOAPUI to test my request

    if I explicitly set my request property "Encoding" in soapui to UTF-8 I get the correct value.

    I also wonder which language setting is used when connecting from java layer to database (NLS_LANG?)

    Thnx

    Grts

    Stijn

  • Vanja Keglević
    Vanja Keglević Member Posts: 30 Green Ribbon
    edited Mar 21, 2019 11:00AM

    Jeff,

    here is an example:

    ORDS plsql handler("request" variable is an out response string):

    declare

        v_request   clob;

    begin

        v_request := :body_text;

        :request := v_request;

    end;

    ### First I try posting string abcčšćđž in utf-8, and it works as expected:

    $ echo -e '\x61\x62\x63\xc4\x8d\xc5\xa1\xc4\x87\xc4\x91\xc5\xbe' | curl http://lldevapex:8080/ords/lldev/opp/test/encoding --user "tomcat_ords:tomcat_ords" -H 'Content-Type: text/plain; charset=utf-8' --data-binary @-

    {"request":"abcčšćđž\n"}

    ### Then I try the same request and just change the charset to iso-8859-2 in the request - string gets parsed again as utf-8?

    $ echo -e '\x61\x62\x63\xc4\x8d\xc5\xa1\xc4\x87\xc4\x91\xc5\xbe' | curl http://lldevapex:8080/ords/lldev/opp/test/encoding --user "tomcat_ords:tomcat_ords" -H 'Content-Type: text/plain; charset=iso-8859-2' --data-binary @-

    {"request":"abcčšćđž\n"}

    ### Then I try to send a string in iso-8859-2 encoding - but it doesn't get parsed right:

    $ echo -e '\x61\x62\x63\xe8\xb9\xe6\xf0\xbe' | curl http://lldevapex:8080/ords/lldev/opp/test/encoding --user "tomcat_ords:tomcat_ords" -H 'Content-Type: text/plain; charset=iso-8859-2' --data-binary @-

    {"request":"abc???\n"}

  • thatJeffSmith-Oracle
    thatJeffSmith-Oracle Distinguished Product Manager Posts: 8,272 Employee
    edited Mar 21, 2019 11:56AM

    Java should be translating that to utf-8 for us, automagically. Before I start a test case/bug report, what version of Java you running?

  • Vanja Keglević
    Vanja Keglević Member Posts: 30 Green Ribbon
    edited Mar 22, 2019 7:56AM

    Java version is:

    java version "1.8.0_191"

    Java(TM) SE Runtime Environment (build 1.8.0_191-b12)

    Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

    tomcat-9.0.13

    Oracle Database 11.2.0.4.0

    > select ords.installed_version from dual;

    INSTALLED_VERSION

    --------------------------------------------------------------------------------

    18.4.0.r3541002

  • user8825413
    user8825413 Member Posts: 5 Blue Ribbon
    I have the same problem. Has anyone found the solution?
    

    Thanks.

  • User_H3J7U
    User_H3J7U Member Posts: 837 Gold Trophy

    My database charset is AL32UTF8. ORDS 21.2.4.r2431032 standalone.

    When non-utf8 encoding are specified in the request

    echo -e '\x61\x62\x63\xe8\xb9\xe6\xf0\xbe' | curl http://iam:8080/ords/test/echo -H 'Content-Type: text/plain; charset=iso-8859-2' --data-binary @-
    

    the :body_text receives a replacement characters ef,bf,bd: 61,62,63,ef,bf,bd,ef,bf,bd,ef,bf,bd,a. The value of :content_type is plain/text without charset. owa_util.print_cgi_env returns the header Content-Type with charset:

    Content-Type = text/plain; charset=ISO-8859-2;<br />
    REQUEST_CHARSET = AL32UTF8<br />
    REQUEST_IANA_CHARSET = UTF-8<br />
    REQUEST_METHOD = POST<br />
    

    The workaround is to use the binary parameter :body and convert it using the charset from owa_util.get_cgi_env('Content-Type').

  • user8825413
    user8825413 Member Posts: 5 Blue Ribbon

    My database charset is ISO8859P15. When I access to application mod_plsql in ORDS

    curl -I  http://host.domain.com:8080/ords/dadplsql/PROCEDURE I receive :

    HTTP/1.1 200

    Content-Type: text/html;charset=UTF-8

    Transfer-Encoding: chunked

    Date: Mon, 29 Nov 2021 09:07:21 GMT

    Can you explain me where change de characterset but Content-Type: text/html;charset= is ISO-8859-1

    Is inside PROCEDURE? Or inside configuration DAD?

    Thanks.