473,385 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 980

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Richard Lewis | last post by:
Hi there, I'm having a problem with unicode files and ftplib (using Python 2.3.5). I've got this code: xml_source = codecs.open("foo.xml", 'w+b', "utf8") #xml_source = file("foo.xml",...
4
by: chris_fieldhouse | last post by:
Hi, I'm almost done with a php driven email filter and automated forwarder, I've tested it out with various emails and ironed out plain text and html. But this final item has me stumped. ...
10
by: Simon Willison | last post by:
I'm having a horrible time trying to get xml.dom.pulldom to consume a UTF8 encoded XML file. Here's what I've tried so far: <msg>Simon\xe2\x80\x99s XML nightmare</msg> """ ('START_DOCUMENT',...
4
by: Samuel | last post by:
Hi I am trying to write to a string text encoded to utf8 as oppose to utf16 Since the data comes from an XML object (and I serialize it) I need to pass either StreamWriter or a StringWriter...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.