Document Labelled Utf-16 But Has Utf-8 Content Follow

0
Avatar
Legacy Poster

Hi.  Now that I've figured out how to get the XML Response, I see another problem.  I can't parse it.

 

My parser says:  Entity: line 1: parser error : Document labelled UTF-16 but has UTF-8 content

 

True enough, the response begins with "<?xml version="1.0" encoding="utf-16"?>".

4 comments

0
Avatar
Domingo Rodriguez
Moderator
Comment actions Permalink

Are you saying that although you define "UTF-16" as the encoding for the BarTender XML Script command response, the format we use seems to be in "UTF-8" encoding?

 

When you say "my parser", is that from your ERP system? Are you using SAP? Please give as much details on your ERP system as you can please.

0
Avatar
Legacy Poster
Comment actions Permalink

I had the same issue.  The response certainly does not LOOK like utf-16 either.

 

My application is in python and the python XML parser (etree) was complaining about this.

Since python offers a simple conversion between encodings, I tried converting it.

 

response = response.encode('utf16')

 

Now the xml tag coming back from BarTender/Commander matches the actual encoding, so the parser accepts it.

 

It's definitely a bit of a shady solution, I don't love doing this.  But it works :)

 

-Ben Mehlman

0
Avatar
Legacy Poster
Comment actions Permalink

Are you saying that although you define "UTF-16" as the encoding for the BarTender XML Script command response, the format we use seems to be in "UTF-8" encoding?

 

When you say "my parser", is that from your ERP system? Are you using SAP? Please give as much details on your ERP system as you can please.

 

Hi Domingo, I'm currently working with your phone support on this issue.. as it has popped up again.

 

It is the opposite of what you said.  When the Commander BTXML response encoding is set to UTF-8, it sends the response as UTF-8, but with an encoding=utf-16 in the header.  The encoding is right, but the header is wrong.  It's definitely a Commander or Bartender problem.

 

By setting the response encoding dropdown to UTF-16, it works.. the response is encoded as UTF-16, and the header says utf-16.. it matches therefore everything works.  However we need to use utf-8.

0
Avatar
Domingo Rodriguez
Moderator
Comment actions Permalink

Do you have the CAS number for the ticket you opened?

 

Can you include here the exact BTXML-Script you're using for setting the XML Response in UTF-8 format?

 

Will you continue with this issue over the phone with our tech-support department, or over the forum?

Please sign in to leave a comment.