Re: right adjusted strings containing umlauts

2013-08-28 Thread kurt . alfred . mueller
On Wednesday, August 28, 2013 12:23:12 PM UTC+2, Dave Angel wrote: > On 28/8/2013 04:01, Kurt Mueller wrote: > > Because I cannot switch to Python 3 for now my life is not so easy:-) > > For some text manipulation tasks I need a template to split lines > > from stdin into a list of strings the way

Re: right adjusted strings containing umlauts

2013-08-28 Thread Dave Angel
On 28/8/2013 04:01, Kurt Mueller wrote: > Because I cannot switch to Python 3 for now my life is not so easy:-) > > For some text manipulation tasks I need a template to split lines > from stdin into a list of strings the way shlex.split() does it. > The encoding of the input can vary. > For furt

Re: right adjusted strings containing umlauts

2013-08-28 Thread Kurt Mueller
Am 08.08.2013 18:37, schrieb Chris Angelico: > On Thu, Aug 8, 2013 at 5:16 PM, Kurt Mueller > wrote: >> Am 08.08.2013 17:44, schrieb Peter Otten: >>> Kurt Mueller wrote: What do I do, when input_strings/output_list has other codings like iso-8859-1? >>> You have to know the actual encodi

Re: right adjusted strings containing umlauts

2013-08-23 Thread Kurt Mueller
Am 08.08.2013 18:37, schrieb Chris Angelico: > On Thu, Aug 8, 2013 at 5:16 PM, Kurt Mueller > wrote: >> Am 08.08.2013 17:44, schrieb Peter Otten: >>> Kurt Mueller wrote: What do I do, when input_strings/output_list has other codings like iso-8859-1? >>> You have to know the actual encodi

Re: right adjusted strings containing umlauts

2013-08-09 Thread Steven D'Aprano
On Thu, 08 Aug 2013 17:24:49 +0200, Kurt Mueller wrote: > What do I do, when input_strings/output_list has other codings like > iso-8859-1? When reading from a text file, honour some sort of encoding cookie at the top (or bottom) of the file, like Emacs and Vim use, or a BOM. If there is no enc

Re: right adjusted strings containing umlauts

2013-08-09 Thread wxjmfauth
Le jeudi 8 août 2013 18:27:06 UTC+2, Kurt Mueller a écrit : > Now I have this small example: > > -- > > #!/usr/bin/env python > > # vim: set fileencoding=utf-8 : > > > > from __future__ import print_function > > import sys, shlex > >

Re: right adjusted strings containing umlauts

2013-08-08 Thread Terry Reedy
On 8/8/2013 11:24 AM, Kurt Mueller wrote: print( u'{0:>3} {1:>3} {2:>3} {3:>3} {4:>3}'.format( *output_list ) ) Using autonumbering feature, same as print( u'{:>3} {:>3} {:>3} {:>3} {:>3}'.format( *output_list ) ) print( (u' '.join([u'{:>3}']*5)).format(*output_list) ) print( (u' '.join([u'{:

Re: right adjusted strings containing umlauts

2013-08-08 Thread Dave Angel
Kurt Mueller wrote: > Now I have this small example: > -- > #!/usr/bin/env python > # vim: set fileencoding=utf-8 : > > from __future__ import print_function > import sys, shlex > > print( repr( sys.stdin.encoding ) ) > > strg_form = u'{0:>3}

Re: right adjusted strings containing umlauts

2013-08-08 Thread Chris Angelico
On Thu, Aug 8, 2013 at 5:16 PM, Kurt Mueller wrote: > Am 08.08.2013 17:44, schrieb Peter Otten: >> Kurt Mueller wrote: >>> What do I do, when input_strings/output_list has other codings like >>> iso-8859-1? >> >> You have to know the actual encoding. With that information it's easy: > output_l

Re: right adjusted strings containing umlauts

2013-08-08 Thread Peter Otten
Kurt Mueller wrote: > Am 08.08.2013 17:44, schrieb Peter Otten: >> Kurt Mueller wrote: >>> What do I do, when input_strings/output_list has other codings like >>> iso-8859-1? >> >> You have to know the actual encoding. With that information it's easy: > output_list >> ['\xc3\xb6', '\xc3\xbc',

Re: right adjusted strings containing umlauts

2013-08-08 Thread Kurt Mueller
Now I have this small example: -- #!/usr/bin/env python # vim: set fileencoding=utf-8 : from __future__ import print_function import sys, shlex print( repr( sys.stdin.encoding ) ) strg_form = u'{0:>3} {1:>3} {2:>3} {3:>3} {4:>3}' for inpt_l

Re: right adjusted strings containing umlauts

2013-08-08 Thread Kurt Mueller
Am 08.08.2013 17:44, schrieb Peter Otten: > Kurt Mueller wrote: >> What do I do, when input_strings/output_list has other codings like >> iso-8859-1? > > You have to know the actual encoding. With that information it's easy: output_list > ['\xc3\xb6', '\xc3\xbc', 'i', 's', 'f'] encoding

Re: right adjusted strings containing umlauts

2013-08-08 Thread Dave Angel
Kurt Mueller wrote: > Am 08.08.2013 16:43, schrieb jfhar...@gmail.com: >> On Thursday, 8 August 2013 15:23:46 UTC+1, Kurt Mueller wrote: >>> I'd like to print strings right adjusted. >>> print( '>{0:>3}<'.format( 'ä' ) ) >> >> Make both strings unicode >> print( u'>{0:>3}<'.format( u'ä' ) ) >> W

Re: right adjusted strings containing umlauts

2013-08-08 Thread Peter Otten
Kurt Mueller wrote: > Am 08.08.2013 16:43, schrieb jfhar...@gmail.com: >> On Thursday, 8 August 2013 15:23:46 UTC+1, Kurt Mueller wrote: >>> I'd like to print strings right adjusted. >>> print( '>{0:>3}<'.format( 'ä' ) ) >> >> Make both strings unicode >> print( u'>{0:>3}<'.format( u'ä' ) ) >> W

Re: right adjusted strings containing umlauts

2013-08-08 Thread Kurt Mueller
Am 08.08.2013 16:43, schrieb jfhar...@gmail.com: > On Thursday, 8 August 2013 15:23:46 UTC+1, Kurt Mueller wrote: >> I'd like to print strings right adjusted. >> print( '>{0:>3}<'.format( 'ä' ) ) > > Make both strings unicode > print( u'>{0:>3}<'.format( u'ä' ) ) > Why not use rjust for it though

Re: right adjusted strings containing umlauts

2013-08-08 Thread MRAB
On 08/08/2013 15:40, Neil Cerutti wrote: On 2013-08-08, Kurt Mueller wrote: I'd like to print strings right adjusted. ( Python 2.7.3, Linux 3.4.47-2.38-desktop ) from __future__ import print_function print( '>{0:>3}<'.format( 'a' ) ) a< But if the string contains an Umlaut: print( '>{0:>3}

Re: right adjusted strings containing umlauts

2013-08-08 Thread jfharden
On Thursday, 8 August 2013 15:23:46 UTC+1, Kurt Mueller wrote: > I'd like to print strings right adjusted. > > print( '>{0:>3}<'.format( 'ä' ) ) > Make both strings unicode print( u'>{0:>3}<'.format( u'ä' ) ) Why not use rjust for it though? u'ä'.rjust(3) -- Jonathan -- http://mail.python

Re: right adjusted strings containing umlauts

2013-08-08 Thread Neil Cerutti
On 2013-08-08, Kurt Mueller wrote: > I'd like to print strings right adjusted. > ( Python 2.7.3, Linux 3.4.47-2.38-desktop ) > > from __future__ import print_function > print( '>{0:>3}<'.format( 'a' ) ) >> a< > > But if the string contains an Umlaut: > print( '>{0:>3}<'.format( '??' ) ) >> ??< >

right adjusted strings containing umlauts

2013-08-08 Thread Kurt Mueller
I'd like to print strings right adjusted. ( Python 2.7.3, Linux 3.4.47-2.38-desktop ) from __future__ import print_function print( '>{0:>3}<'.format( 'a' ) ) > a< But if the string contains an Umlaut: print( '>{0:>3}<'.format( 'ä' ) ) > ä< Same with % notation: print( '>%3s<' % ( 'a' ) ) > a<

Re: Regular Expression for words (with umlauts, without numbers)

2011-05-13 Thread Vlastimil Brom
2011/5/13 MRAB : > The latest release is here: > >    http://pypi.python.org/pypi/regex > -- Wow, set operators were added recently ... https://code.google.com/p/mrab-regex-hg/wiki/GeneralDetails ok, it might be not necassary to sove this exact problem with respect to the solutions already mentione

Re: Regular Expression for words (with umlauts, without numbers)

2011-05-13 Thread MRAB
will grab your desired umlauts. I'd actually recommend, however, that if you have an extra 20 minutes, to use Regexp 2.7: http://bugs.python.org/issue2636 Its a much needed improvement over F.Lundh's re implementation (from 1999!) and its 40% faster. Moreover, you can do exactly wh

Re: Regular Expression for words (with umlauts, without numbers)

2011-05-13 Thread Jens Lechtenboerger
On 2011-05-13, Peter Otten wrote: > Jens Lechtenboerger wrote: > >> I'm looking for a regular expression to recognize natural language >> words with umlauts but without numbers. While \w with re.U does >> recognize words with umlauts, it also matches numbers, whic

Re: Regular Expression for words (with umlauts, without numbers)

2011-05-13 Thread Peter Otten
Jens Lechtenboerger wrote: > I'm looking for a regular expression to recognize natural language > words with umlauts but without numbers. While \w with re.U does > recognize words with umlauts, it also matches numbers, which I do > not want. > > Is there a better

Re: Regular Expression for words (with umlauts, without numbers)

2011-05-13 Thread Tim Chon
Hallo Jens, In current python re module, you have to do something like: ((?!\d|_\w)+ which uses the negative look ahead to grab all words except integers and underscore. Of course, if you turn on the unicode flag re.U or use it inline like, (?u) then this will grab your desired umlauts. I&#

Regular Expression for words (with umlauts, without numbers)

2011-05-13 Thread Jens Lechtenboerger
Dear experts, I'm looking for a regular expression to recognize natural language words with umlauts but without numbers. While \w with re.U does recognize words with umlauts, it also matches numbers, which I do not want. Is there a better way than an exhaustive enumeration such as [-a-zàá

Re: umlauts

2009-10-17 Thread Diez B. Roggisch
equence for ö in utf-8. If this shows something else, you need to adjust your terminal settings. for me it also prints the correct o-umlaut (ö), so that was not the problem. All of the below result in xml that shows all umlauts correctly when printed: xml.decode("cp1252") xml.

Re: umlauts

2009-10-17 Thread Diez B. Roggisch
this shows something else, you need to adjust your terminal settings. for me it also prints the correct o-umlaut (ö), so that was not the problem. All of the below result in xml that shows all umlauts correctly when printed: xml.decode("cp1252") xml.decode("cp1252"

Re: umlauts

2009-10-17 Thread Neil Hodgson
The server is sniffing the User-Agent header to decide whether to send UTF-8 or ISO-8859-1. Try this code: import urllib2 r = urllib2.Request("http://www.google.de/ig/api?weather=Muenchen";, None, {"User-Agent":"Mozilla/5.0"}) f = urllib2.urlopen(r) i = f.info() print(i) xml = f.read()

Re: umlauts

2009-10-17 Thread Arian Kuschki
This is wierd. I looked at the site in FireFox - and it was > >displayed correctly, including umlauts. Bringing up the > >info-dialog claims the page is UTF-8, the XML itself says so as > >well (implicit, through the missing declaration of an encoding) - > >but it clearly is *n

Re: umlauts

2009-10-17 Thread Mark Tolonen
"Diez B. Roggisch" wrote in message news:7jub5rf37div...@mid.uni-berlin.de... [snip] This is wierd. I looked at the site in FireFox - and it was displayed correctly, including umlauts. Bringing up the info-dialog claims the page is UTF-8, the XML itself says so as well (implici

Re: umlauts

2009-10-17 Thread I V
On Sat, 17 Oct 2009 21:24:59 +0330, Arian Kuschki wrote: > I just checked and I see the following in the headers: Content-Type > text/xml; charset=UTF-8 > > Where does it say ISO-8859-1? In the headers returned via urllib (and via wget). But checking in Firefox, it does indeed specify UTF-8 in t

Re: umlauts

2009-10-17 Thread Arian Kuschki
as displayed > > correctly, including umlauts. Bringing up the info-dialog claims the > > page is UTF-8, the XML itself says so as well (implicit, through the > > missing declaration of an encoding) - but it clearly is *not* utf-8. > > The headers correctly identify i

Re: umlauts

2009-10-17 Thread Arian Kuschki
n utf-8. > >If this shows something else, you need to adjust your terminal settings. for me it also prints the correct o-umlaut (ö), so that was not the problem. All of the below result in xml that shows all umlauts correctly when printed: xml.decode("cp1252") xml.decode("c

Re: umlauts

2009-10-17 Thread I V
On Sat, 17 Oct 2009 18:54:10 +0200, Diez B. Roggisch wrote: > This is wierd. I looked at the site in FireFox - and it was displayed > correctly, including umlauts. Bringing up the info-dialog claims the > page is UTF-8, the XML itself says so as well (implicit, through the > missing

Re: umlauts

2009-10-17 Thread Diez B. Roggisch
t contains umlauts. Consider the following: In [1]: import urllib In [2]: f = urllib.urlopen("http://www.google.de/ig/api?weather=Muenchen";) In [3]: xml = f.read() In [4]: f.close() In [5]: print xml --> print(xml) As you can see the umlauts in the XML are not displayed properly.

Re: umlauts

2009-10-17 Thread StarWing
what to do. I always have problems when dealing input text that > >> contains umlauts. Consider the following: > > >> In [1]: import urllib > > >> In [2]: f = urllib.urlopen("http://www.google.de/ig/api?weather=Muenchen";) > > >> In [3]: xml

Re: umlauts

2009-10-17 Thread StarWing
On 10月18日, 上午12时14分, MRAB wrote: > Arian Kuschki wrote: > > Hi all > > > this has been bugging me for a long time and I do not seem to be able to > > understand what to do. I always have problems when dealing input text that > > contains umlauts. Consider the f

Re: umlauts

2009-10-17 Thread Diez B. Roggisch
MRAB schrieb: Arian Kuschki wrote: Hi all this has been bugging me for a long time and I do not seem to be able to understand what to do. I always have problems when dealing input text that contains umlauts. Consider the following: In [1]: import urllib In [2]: f = urllib.urlopen("

Re: umlauts

2009-10-17 Thread Diez B. Roggisch
MRAB schrieb: Arian Kuschki wrote: Hi all this has been bugging me for a long time and I do not seem to be able to understand what to do. I always have problems when dealing input text that contains umlauts. Consider the following: In [1]: import urllib In [2]: f = urllib.urlopen("

Re: umlauts

2009-10-17 Thread Diez B. Roggisch
StarWing schrieb: On 10月17日, 下午9时54分, Arian Kuschki wrote: Hi all this has been bugging me for a long time and I do not seem to be able to understand what to do. I always have problems when dealing input text that contains umlauts. Consider the following: In [1]: import urllib In [2]: f

Re: umlauts

2009-10-17 Thread Diez B. Roggisch
StarWing schrieb: On 10月17日, 下午9时54分, Arian Kuschki wrote: Hi all this has been bugging me for a long time and I do not seem to be able to understand what to do. I always have problems when dealing input text that contains umlauts. Consider the following: In [1]: import urllib In [2]: f

Re: umlauts

2009-10-17 Thread StarWing
On 10月17日, 下午9时54分, Arian Kuschki wrote: > Hi all > > this has been bugging me for a long time and I do not seem to be able to > understand what to do. I always have problems when dealing input text that > contains umlauts. Consider the following: > > In [1]: import

Re: umlauts

2009-10-17 Thread MRAB
Arian Kuschki wrote: Hi all this has been bugging me for a long time and I do not seem to be able to understand what to do. I always have problems when dealing input text that contains umlauts. Consider the following: In [1]: import urllib In [2]: f = urllib.urlopen("http://www.goog

Re: umlauts

2009-10-17 Thread Diez B. Roggisch
Arian Kuschki schrieb: Hi all this has been bugging me for a long time and I do not seem to be able to understand what to do. I always have problems when dealing input text that contains umlauts. Consider the following: In [1]: import urllib In [2]: f = urllib.urlopen("http://www.goog

umlauts

2009-10-17 Thread Arian Kuschki
Hi all this has been bugging me for a long time and I do not seem to be able to understand what to do. I always have problems when dealing input text that contains umlauts. Consider the following: In [1]: import urllib In [2]: f = urllib.urlopen("http://www.google.de/ig/api?weather=Mue

Re: Problem reading file with umlauts

2009-07-09 Thread Claus Hausberger
gt; or encode the text before writing: > > text = text.encode("latin1") > > (I'm assuming you want the output file to be in Latin1.) > > > > >> Claus Hausberger wrote: > >> > >>> I have a text file with is encoding in

Re: Problem reading file with umlauts

2009-07-07 Thread MRAB
s encoding in Latin1 (ISO-8859-1). I can't change that as I do not create those files myself. I have to read those files and convert the umlauts like ö to stuff like &oumol; as the text files should become html files. umlaut-in.txt: This file is contains data in the unicode character

Re: Problem reading file with umlauts

2009-07-07 Thread Claus Hausberger
ate those files myself. I have to read > > those files and convert the umlauts like ö to stuff like &oumol; as > > the text files should become html files. > > umlaut-in.txt: > > This file is contains data in the unicode > character set and is encoded with utf-8. >

Re: Problem reading file with umlauts

2009-07-07 Thread Stefan Behnel
Michiel Overtoom schrob: > Viele Röhre. Macht spaß! Tsüsch! LOL! :) Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem reading file with umlauts

2009-07-07 Thread Michiel Overtoom
Claus Hausberger wrote: I have a text file with is encoding in Latin1 (ISO-8859-1). I can't change that as I do not create those files myself. I have to read those files and convert the umlauts like ö to stuff like &oumol; as the text files should become html files. umlaut-in.txt:

Re: Problem reading file with umlauts

2009-07-07 Thread Stefan Behnel
Claus Hausberger wrote: > Hello > > I have a text file with is encoding in Latin1 (ISO-8859-1). I can't change > that as I do not create those files myself. > > I have to read those files and convert the umlauts like ö to stuff like > &oumol; as the text files sh

Problem reading file with umlauts

2009-07-07 Thread Claus Hausberger
Hello I have a text file with is encoding in Latin1 (ISO-8859-1). I can't change that as I do not create those files myself. I have to read those files and convert the umlauts like ö to stuff like &oumol; as the text files should become html files. I have this code: #!/usr/b

Re: Umlauts in idle

2008-12-13 Thread Marc 'BlackJack' Rintsch
On Sat, 13 Dec 2008 02:58:48 -0800, a_olme wrote: > On 13 Dec, 10:38, "Martin v. Löwis" wrote: >> > When I try to use umlauts in idle it will only print out as Unicode >> > escape characters. Is it possible to configure idle to print them as >> > ordinary

Re: Umlauts in idle

2008-12-13 Thread a_olme
On 13 Dec, 10:38, "Martin v. Löwis" wrote: > > When I try to use umlauts in idle it will only print out as Unicode > > escape characters. Is it possible to configure idle to print them as > > ordinary characters? > > Did you really use the print statement? They

Re: Umlauts in idle

2008-12-13 Thread Martin v. Löwis
> When I try to use umlauts in idle it will only print out as Unicode > escape characters. Is it possible to configure idle to print them as > ordinary characters? Did you really use the print statement? They print out fine for me. Regards, Martin -- http://mail.python.org/mailman

Re: Umlauts in idle

2008-12-12 Thread Benjamin Kaplan
On Fri, Dec 12, 2008 at 3:51 PM, a_olme wrote: > Hello all, > > When I try to use umlauts in idle it will only print out as Unicode > escape characters. Is it possible to configure idle to print them as > ordinary characters? > Best Regards Anders Olme Make sure you

Umlauts in idle

2008-12-12 Thread a_olme
Hello all, When I try to use umlauts in idle it will only print out as Unicode escape characters. Is it possible to configure idle to print them as ordinary characters? Best Regards Anders Olme -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's email module - problem with umlauts in some email clients

2006-12-08 Thread Fredrik Lundh
Nico Grubert wrote: > + On a solaris machine running thunderbird 1.5.0.8 and on a macintosh > machine running eudora umlauts are *not* displayed properly. > The email header does not contain any "Content-type". If I manually > switch the email client's character

Python's email module - problem with umlauts in some email clients

2006-12-08 Thread Nico Grubert
Hi there, I wrote a short python script that sends an email using python's email module and I am using Python 2.3.5. The problem is, that umlauts are not displayed properly in some email clients: + On a windows machine running thunderbird 1.0.2 umlauts are displayed properly. The