NetTalk Central

Author Topic: xml.Save() turns into gibberish  (Read 6336 times)

Wolfgang Orth

  • Sr. Member
  • ****
  • Posts: 251
    • View Profile
    • oData Wolfgang Orth
xml.Save() turns into gibberish
« on: March 15, 2019, 03:02:09 AM »
Hello Bruce and all,

when I compose an xml-structure in a webclient to post to the server, I have to struggle with german umlauts.

    xml.tagCase         = xf:CaseAny
    xml.ReplacementChar = '_'
    xml.RemovePrefix    = FALSE 
    xml.SOAPEnvelope    = 1
    xml._Indent         = 0 
    xml.SaveEncoding    = 'utf-8'

    xml.append             = 1
    xml.DontCloseTags      = 1   
    Shutdown_Headline  = GETINI(..)
    Shutdown_Message = GETINI(..) ! <--- these critters contain wierd german characters, like ? ? ? ? ? ? ?


    dbgView('Shutdown_Headline = ' & CLIP(Shutdown_Headline))
    dbgView('Shutdown_Message = ' & CLIP(Shutdown_Nachricht))  wierd german stuff gets displayed OKAY

    xml.Save(Shutdown_Notification_GROUP, '', '')

    dbgView(xml.xmldata) <=== here those special characters are all crap, like ? becomes to  ΓΌ and so on


I do not understand, why xml.Save disguises them.

Can someone please enlight me?

If that is inevitable, how can I translate them back after transmission?

Nettalk 9.30
Stringtheory 2.74
jFiles 1.44
xFiles 2.89




PS: I just see that I cannot write german umlauts in my posting. Just imagine a u and o with tiny dots ontop.

thanks in advance
Wolfgang
« Last Edit: March 15, 2019, 03:07:25 AM by Wolfgang Orth »

urayoan

  • Full Member
  • ***
  • Posts: 222
    • View Profile
    • AZ Rock Radio
Re: xml.Save() turns into gibberish
« Reply #1 on: March 15, 2019, 04:00:37 AM »
Wolfgang, a wild guess, but did you check the encoding in the XFiles Object? In Spanish, i usually use utf-8 or iso-8859-1.

The setting can be set globally or in the local procedure that includes the XFiles Object.

If the encoding is the case, check in the embed points that did not make override of the early settings.

xml.SaveEncoding = 'UTF-8'  where xml is the XFile object in the procedure.

Another stuff to check is this.
https://capesoft.com/docs/StringTheory3/StringTheory.htm#XMLDecode
https://capesoft.com/docs/StringTheory3/StringTheory.htm#XMLEncode

Hope the info can be helpful

@ Urayoan

Wolfgang Orth

  • Sr. Member
  • ****
  • Posts: 251
    • View Profile
    • oData Wolfgang Orth
Re: xml.Save() turns into gibberish
« Reply #2 on: March 17, 2019, 09:23:55 AM »
Hello Urayoan,

xml.SaveEncoding = 'UTF-8'  where xml is the XFile object in the procedure.

yes, thats why I set that in the first block.

But that was apparently not the reason. What I found out is, that the server gets the correct string, but when this server is set to send this string, it gets garbeled.

It happens in the BuildResult ROUTINE.

  packet.setvalue('<?xml version="1.0"  encoding="utf-8"?><13,10>')

Right after the StringTheory-object packet is completed, I do a packet.Replace(...) for all critical character. See attached screenshot.

At least as long, as I learned to understand, what happens here and how I can solve it in a better and cleaner way.

Thanks so far, and I will bother Bruce both on Wednesday and Thursday.

Bye
Wolfgang


Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: xml.Save() turns into gibberish
« Reply #3 on: March 17, 2019, 11:02:12 PM »
you are setting the XML to be utf-8,
but then populating it with strings that are ANSI, not utf-8.

I recommend converting Shutdown_Message to utf-8 before adding it to the XML.
UsingStringTheory.ToUnicode method, with the German code-page.

cheers
Bruce

Wolfgang Orth

  • Sr. Member
  • ****
  • Posts: 251
    • View Profile
    • oData Wolfgang Orth
Re: xml.Save() turns into gibberish
« Reply #4 on: March 18, 2019, 01:00:04 AM »
you are setting the XML to be utf-8,
but then populating it with strings that are ANSI, not utf-8.

I recommend converting Shutdown_Message to utf-8 before adding it to the XML.
UsingStringTheory.ToUnicode method, with the German code-page.

cheers
Bruce

HaHaHa, now I have screwed it up even more!

I am obviously on the complete wrong track!

I will bother you on this weeks ClarionLive Nettalk-Usergroup webinar.