Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #13159 > unrolled thread

How do I automate the removal of all non-ascii characters from my code?

Started byAlec Taylor <alec.taylor6@gmail.com>
First post2011-09-12 17:49 +1000
Last post2011-09-12 06:23 -0700
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  How do I automate the removal of all non-ascii characters from my code? Alec Taylor <alec.taylor6@gmail.com> - 2011-09-12 17:49 +1000
    Re: How do I automate the removal of all non-ascii characters from my code? Miki Tebeka <miki.tebeka@gmail.com> - 2011-09-12 06:23 -0700
    Re: How do I automate the removal of all non-ascii characters from my code? Miki Tebeka <miki.tebeka@gmail.com> - 2011-09-12 06:23 -0700

#13159 — How do I automate the removal of all non-ascii characters from my code?

FromAlec Taylor <alec.taylor6@gmail.com>
Date2011-09-12 17:49 +1000
SubjectHow do I automate the removal of all non-ascii characters from my code?
Message-ID<mailman.1016.1315813775.27778.python-list@python.org>
Good evening,

I have converted ODT to HTML using LibreOffice Writer, because I want
to convert from HTML to Creole using python-creole. Unfortunately I
get this error: "File "Convert to Creole.py", line 17
SyntaxError: Non-ASCII character '\xe2' in file Convert to Creole.py
on line 18, but no encoding declared; see
http://www.python.org/peps/pep-0263.html for details".

Unfortunately I can't post my document yet (it's a research paper I'm
working on), but I'm sure you'll get the same result if you write up a
document in LibreOffice Writer and add some End Notes.

How do I automate the removal of all non-ascii characters from my code?

Thanks for all suggestions,

Alec Taylor

[toc] | [next] | [standalone]


#13177

FromMiki Tebeka <miki.tebeka@gmail.com>
Date2011-09-12 06:23 -0700
Message-ID<mailman.1032.1315833791.27778.python-list@python.org>
In reply to#13159
You can add "# coding=UTF8" to the top of your file (see http://www.python.org/dev/peps/pep-0263/).

Of you want to remove unicode, there are several options, one of them is passing the file through "iconv --to ascii".

[toc] | [prev] | [next] | [standalone]


#13178

FromMiki Tebeka <miki.tebeka@gmail.com>
Date2011-09-12 06:23 -0700
Message-ID<b773fdcd-3878-44c6-8f2c-2dd61cd6a704@glegroupsg2000goo.googlegroups.com>
In reply to#13159
You can add "# coding=UTF8" to the top of your file (see http://www.python.org/dev/peps/pep-0263/).

Of you want to remove unicode, there are several options, one of them is passing the file through "iconv --to ascii".

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web