Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] invalid byte 2 of 3 byte UTF-8 error received

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Sandy Mustard <smustard AT cinci.rr.com>
  • To: XOM API for Processing XML with Java <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] invalid byte 2 of 3 byte UTF-8 error received
  • Date: Mon, 23 Sep 2013 20:58:02 -0400

Well, perhaps I figured it out.

I added the following after my character conversions:

byte[] chrs = textString.getBytes("UTF-8"); // <<<<<<<<<<<<<<<<<<<<<<
textString= new String(chrs); // <<<<<<<<<<<<<<<<<<<<<<<
Attribute attr = new Attribute("Text", textString);

I'm hoping this is correct.

SandyMustard


On 9/23/2013 8:15 PM, Sandy Mustard wrote:
I have some text that I need to convert to xml. The text is:
"Ing. Libor Vos\xe1hlo\nSenior project manager\nforteq Czech\nKopisty 1-
areal MUS,a.s.\nCZ - 43401, Most - Kopisty\nTel: +420 476 203 826\nFax:
+420 476 203 835\nMobil: +420 602 109 446\n"

I am converting the "\n" sequences to new lines (x0a).
Note the character sequence that is \xe1. I convert this sequence with

a character with a value of 225 (xe1).
I am using XOM to create the XML
Attribute attr = new Attribute("Text", textString);
xmlClass.addAttribute(attr);
and here is the output:

<MyElem Text="Ing. Libor Vosáhlo&#x0A;Senior project manager&#x0A;forteq
Czech&#x0A;Kopisty 1- areal MUS,a.s.&#x0A;CZ - 43401, Most -
Kopisty&#x0A;Tel: +420 476 203 826&#x0A;Fax: +420 476 203
835&#x0A;Mobil: +420 602 109 446&#x0A;" />

Note the correct last name in the data (with the á)

However, when reading this in various XML parsers, I get a
"java.io.UTFDataFormatException: Invalid byte 2 of 3-byte UTF-8
sequence" error.

How do I pass this string to XOM to get the correct UTF-8 encoding?

Thank you.

Sandy Mustard
_______________________________________________
XOM-interest mailing list
XOM-interest AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/xom-interest


-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2014.0.4117 / Virus Database: 3604/6692 - Release Date: 09/23/13








Archive powered by MHonArc 2.6.24.

Top of Page