XML problem with control characters (ascii 1-31)

Just starting out? Need help? Post your questions and find answers here.
Lebostein
Addict
Addict
Posts: 807
Joined: Fri Jun 11, 2004 7:07 am

XML problem with control characters (ascii 1-31)

Post by Lebostein »

XML 1.1 supports all ascii controls from $01 [SOH] to $1F [US]. But If you use that, then the correct characters are in the XML file after saving, but loading don't work:

Code: Select all

Structure Person
  Name$
  Age.l
  List Books.s()
EndStructure

Define P.Person

P\Name$ = "John Smith " + Chr(17) + Chr(1) + " xxx" ; means [DC1] + [SOH]
P\Age   = 42
AddElement(P\Books()): P\Books() = "Investing For Dummies"
AddElement(P\Books()): P\Books() = "A Little Bit of Everything For Dummies"

Debug P\Name$
Debug P\Age

If CreateXML(0)
  InsertXMLStructure(RootXMLNode(0), @P, Person)
  FormatXML(0, #PB_XML_ReFormat)
  SaveXML(0, "test.xml")
  FreeXML(0)
EndIf

If LoadXML(0, "test.xml")
  ExtractXMLStructure(MainXMLNode(0), @P, Person)
  FreeXML(0)
EndIf

Debug P\Name$
Debug P\Age
saved XML-file is correct:
https://www.dropbox.com/s/gq6qi2jfvh0afkx/ascii-xml.png
Lebostein
Addict
Addict
Posts: 807
Joined: Fri Jun 11, 2004 7:07 am

Re: XML problem with control characters (ascii 1-31)

Post by Lebostein »

Ah, OK, sorry, I see there is XML 1.0 supported only....
Lebostein
Addict
Addict
Posts: 807
Joined: Fri Jun 11, 2004 7:07 am

Re: XML problem with control characters (ascii 1-31)

Post by Lebostein »

No bug. Please move this to the coding questions.

Question: Is it possible to catch invalid string characters in XML files?
Post Reply