· Jan 26, 2017

Issue with encoding (special character) - Business service

Hello devs,

I'm facing an issue with one of my business services, which basically grabs a XML from a webservice (which in turn reads the data from the caché database) and does some processing afterwards. The XML content (which is formed of some of the table fields values) contains a special character: (left single quote)

Here is the code in charge of reading/processing the XML and its contents (essentialy the line $$$TRACE("Status Error "_$$$StatusDisplayString(sc))  is throwing an exception: Status Error ERROR #6301: SAX XML Parser Error: invalid character 0x18 while processing Anonymous Stream at line 1 offset 4798):

    Set xread = ##class(%XML.Reader).%New()
    Set xread.IgnoreNull=1

    sc= xread.OpenStream(pInput)
    set save=""
    if sc {       
      for i=1:1:$l(..TargetClass,",") {
      s class=$p(..TargetClass,",",i)
      s node=$p(..ClassNode,",",i)
      Do xread.Correlate(node,class)
    while xread.Next(.obj, .sc) {     
    if $$$ISERR(sc) quit         
    set sc=..SendObject(obj)
    if $$$ISERR(sc) quit
    // store latest timestamp
    if $l(..SaveProperty)>0,$zobjproperty(obj,..SaveProperty)>save set save=$zobjproperty(obj,..SaveProperty)
    // Save the timestamp up to the point of completion (or failure)
    if $l(save)>0 ##class(RMHCommon.Setting).Set(..SaveSetting,save)

    // error code during next or send request
    if $$$ISERR(sc) {
    $$$TRACE("Status Error "_$$$StatusDisplayString(sc))
    quit sc

I am afraid this is something with caché/Healthshare character encoding, but thing is, my HS uses Unicode as the default encoding. By looking at this character definition within Unicode, it leads me to something weird:

Cancel character?

I'm a bit confused to be honest.

Can someone give me a helping hand?

Thanks in advance!

Discussion (3)0
Log in or sign up to continue

Hey John, thanks for you response!

I wrote some debug piece of code to write into a xml file the pInput content and that's what I get:

<?xml version="1.0" encoding="UTF-8" ?> ... <Value><![CDATA[ ... <P>SORRY TO SAY THAT THIS CHARACTER WILL MESS THIS UP  ?</P> ... ]]></Value>

Where you see the question mark, it is indeed the place the weird character is supposed to be.

By opening the file with Notepad++ and checking the 'Encoding' menu, it shows 'Encode with UTF-8 without BOM'.

Any clues?