0

I'm having trouble with encodings when calling the Quickbase API using Python. I call the API to get a record, and specify the encoding parameter in the request as "UTF-8". The XML response I get back from Quickbase says it's UTF-8, because the XML starts with:

<?xml version="1.0" encoding="utf-8" ?>

However, the XML bytes are actually in encoded as CP1252. I've confirmed this because a right single quotation mark (Unicode char U+2019) is being encoded as the byte 0x92 (CP1252) rather than the UTF-8 byte sequence 0xE2 0x80 0x99. Any idea why Quickbase is saying the XML response is one encoding (UTF-8) but actually using another (CP1252)?

Note that I'm also passing a "Accept-Charset: utf-8" header in the request, but that has no effect.

Ben Hoyt
  • 10,694
  • 5
  • 60
  • 84
  • 3
    Have you considered yelling at Intuit? – Ignacio Vazquez-Abrams Apr 02 '12 at 16:42
  • Yeah, good idea, thanks. Couldn't find their support form at first, but emailed them now. – Ben Hoyt Apr 02 '12 at 18:57
  • Their CS rep got back to me and said, "I've looked into this further for you and found out that the best thing to do at this time would be to search through our User Voice feature to see if anyone else has requested enhanced support for UTF8 encoding. If so, I'd suggest that you vote on it." So please vote on https://quickbase.uservoice.com/forums/111823-quickbase-product-feedback/suggestions/2245671-unicode-support -- in the meantime I'll use dan04's solution to work around it. – Ben Hoyt Apr 03 '12 at 21:30
  • "Enhanced"? Another name for the unrecommend list. – Ignacio Vazquez-Abrams Apr 04 '12 at 01:04

1 Answers1

2

Any idea why Quickbase is saying the XML response is one encoding (UTF-8) but actually using another (CP1252)?

Probably because a Quickbase developer copied-and-pasted the XML declaration without actually understanding what encoding means.

The easiest workaround is to use xml_response = xml_response.decode('windows-1252').encode('UTF-8') to get a real UTF-8 string to pass to the XML parser.

dan04
  • 87,747
  • 23
  • 163
  • 198