<br><br><div class="gmail_quote">On Mon, Sep 12, 2011 at 8:17 AM, Gary Herron <span dir="ltr"><<a href="mailto:gherron@islandtraining.com">gherron@islandtraining.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">On 09/12/2011 12:49 AM, Alec Taylor wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Good evening,<br>
<br>
I have converted ODT to HTML using LibreOffice Writer, because I want<br>
to convert from HTML to Creole using python-creole. Unfortunately I<br>
get this error: "File "Convert to Creole.py", line 17<br>
SyntaxError: Non-ASCII character '\xe2' in file Convert to Creole.py<br>
on line 18, but no encoding declared; see<br>
<a href="http://www.python.org/peps/pep-0263.html" target="_blank">http://www.python.org/peps/<u></u>pep-0263.html</a> for details".<br>
<br>
Unfortunately I can't post my document yet (it's a research paper I'm<br>
working on), but I'm sure you'll get the same result if you write up a<br>
document in LibreOffice Writer and add some End Notes.<br>
<br>
How do I automate the removal of all non-ascii characters from my code?<br>
<br>
Thanks for all suggestions,<br>
<br>
Alec Taylor<br>
</blockquote>
<br>
<br>
<br></div></div>
This question does not quite make sense.  The error message is complaining about a python file.  What does that file have to do with ODT to HTML conversion and LibreOffice?<br>
<br>
The error message means the python file (wherever it came from) has a non-ascii character (as you noted), and so it needs something to tell it what such a character means.  (That what the encoding is.)<br>
<br>
A comment like this in line 1 or 2 will specify an encoding:<br>
  # -*- coding: <encoding name> -*-<br>
but, we'll have to know more about the file "Convert to Creole.py" to guess what encoding name should be specified there.<br>
<br>
You might try utf-8 or latin-1.<div><div></div><div class="h5"><br>
<br>
<br>
-- <br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br>If you are having trouble figuring out which encoding your file has, the "file" util is often a quick and dirty solution.<br><br>#> echo "åäö" > test.txt<br>#> file test.txt<br>
test.txt: UTF-8 Unicode text<br>#> iconv test.txt -f utf-8 -t latin1 > test.l1.txt<br>#> file test.l1.txt<br>test.l1.txt: ISO-8859 text<br><br>Note: I use latin1 (iso-8859-1) because it can describe the characters 'å', 'ä', 'ö'. Your encoding might be different depending on what system you are using.<br>
<br>The gist is that if you specify the correct encoding as mentioned above with the "coding"-comment, your program will probably (ish) run as intended.<br><br>-- John-John Tedro<br>