ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Problem with foreign characters with YAJL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with foreign characters with YAJL

    Hello, I have a problem with Russian characters using http_get and parsing JSON with YAJL.
    Can you please assist me with this? What should be set in order to see correct Russian characters when parsing JSON?

    here's the code:

    tempFile = http_tempfile() + '.xml';
    HTTP_SetCCSIDs(1208:0);
    HTTP_SetfileCCSID(1208);

    //executing GET method
    rc = http_get(%trim(w_Url):tempFile:w_Timeout);
    if (rc <> 1 and rc <> 400);
    unlink(tempFile);
    w_errMsg = http_error();
    return;
    endif;

    //then when I parse JSON I have unknown characters instead of Russian ones:
    node = yajl_object_find( docNode : 'Name' );
    Name = yajl_get_string(node);


    Job run's with 285 codepage. I've also tried 1025 ccsid for Russia but it didn't help.
    I've checked JSON file and it is correct, so something must be changed in program. I don't have any clue for now.

    Thanks in advance.
    Last edited by michal2442; July 4, 2019, 06:59 AM.

  • #2
    Hello Michal,

    CCSID 285 is for UK and Ireland, and doesn't contain Cyrillic characters, so it makes perfect sense that this wouldn't show Cyrillic characters :-)

    Setting your job CCSID to 1025 should work, provided that your system/display supports Cyrillic characters. If its not working, post a JSON doc with Cyrillic characters that isn't working for us to try.

    You could also try using yajl_get_string_utf16() instead of yajl_get_string(). This returns the data in UTF-16, which could then be placed in an RPG unicode field.

    Comment

    Working...
    X