21

I've just imported a chunk of text into a string element for a book app and I'm getting this error : An invalid XML character (Unicode:0x1f) was found in the element content of this document. I looked it up here http://lwp.interglacial.com/appf_01.htm and the description says US (removing underlining doesnt seem to work). What is this character so I can remove it if possible. I'm very new to android so simple answers please :)

Broo
  • 859
  • 4
  • 11
  • 21

3 Answers3

25

0x1f is a Unit Separator, an archaic way to separate fields in a text (Like , or Tab in CSV).

It is indeed not a valid text character in XML 1.0 (but allowed in XML 1.1). In a UTF-8 input string, you can also safely replace the byte 0x1f with 0x09(Tab) to work around the problem. Alternatively, declare the document as XML 1.1 and use an XML 1.1 parser.

phihag
  • 278,196
  • 72
  • 453
  • 469
  • Thanks Phihag, but my eclipse says otherwise. I'm using xml version 1.0, which seems to be standard for android projects on eclipse. Should I be updating it? – Broo Jul 14 '11 at 12:56
  • @Broo Unlikely that updating will help, but maybe file a bug if that problem persists. I misunderstood your question. Next time, if it is not programming-related (i.e. you want to *do* something instead of *writing code* that does something), please ask on http://superuser.com/ – phihag Jul 14 '11 at 13:05
  • WRONG: 0x1f is not a legal XML character in XML 1.0. See http://www.w3.org/TR/REC-xml/#charsets. It can be expressed as `#x1f;` in XML 1.1, but not in XML 1.0. Downvoting. – Michael Kay Jul 14 '11 at 13:46
15

US means "Unit separator". This is an invisible character, so you should open your text file with some text editor that can show the invisible characters and remove them. I think that probably Notepad++ will give you this functionality:

http://notepad-plus-plus.org/

valo
  • 1,712
  • 17
  • 12
  • 2
    Downloaded notepad++, opened file and it showed up straight away, brilliant! Thank you :) – Broo Jul 14 '11 at 12:53
0

Use Nodepad++ you will find the "Unit separator".

Like the picture:

enter image description here

Kevin Mayo
  • 1,089
  • 6
  • 19