469,917 Members | 1,644 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

Re: Not able to get utf8 encoded string into a document

Lawrence, Anna K (US SSA) wrote:
I am working on a web application using Pylons .0.9.6, SQLAlchemy 0.4.4,
MySQLdb 1.2.2 and Python 2.4.4.

We want to use utf8 encoding throughout and as far as I can see
everything is set properly between components and Iíve got a
sitecustomize.py in my site-packages directory of python set to utf8 as
well. Everything is stored properly in the database and displays nicely
in the app. However, when I try to take a string that is coming out of
the database and export it to a Word document, no amount of
encoding/decoding will make the Word doc display properly.

Since Iím on a Windows machine, my default locale is cp437. Is this the
reason?
From where I'm sitting, I can't see enough to help. The crucial
thing seems to be in this phrase: "When I try to take a string that
is coming out of the database and export it to a Word document,
no amount of encoding/decoding will make the Word doc display properly".
It presumably doesn't matter what web framework etc. you're using:
you either get a unicode object or an encoded string from the database
and you're putting that in a Word doc. Is that correct?

Can you provide a sample of code which shows what you're doing, and
explain what does / doesn't happen? By way of trying to get closer,
there's a Noddy example below:

<code>
import win32com.client

word = win32com.client.gencache.EnsureDispatch ("Word.Application")
word.Visible = 1
doc = word.Documents.Add ()
doc.Range ().Text = u"poup\u00e9e"

</code>

Now, on my Win2K machine this displays perfectly well in word with
the French word poupee with the penultimate e having an acute
accent. So, translating this minimalist example into your situation,
what happens when you try doing this?

TJG
Jun 27 '08 #1
0 852

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.