Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-22 Thread Lawrence D’Oliveiro
On Thursday, June 23, 2016 at 2:02:18 PM UTC+12, Rustom Mody wrote: > So remembered that there is one method -- yes clunky -- that I use most -- > forgot to mention -- C-x 8 RET > ie insert-char¹ > > Which takes the name (or hex) of the unicode char. A handy tool for looking up names and codes

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-22 Thread Rustom Mody
On Tuesday, June 21, 2016 at 7:27:00 PM UTC+5:30, Rustom Mody wrote: > >https://wiki.archlinux.org/index.php/Keyboard_configuration_i > >n_Xorg> -- no good You probably want this: https://wiki.archlinux.org/index.php/X_KeyBoard_extension#Editing_the_layout > > So Rustom, how do *you* prod

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-22 Thread Tim Chase
On 2016-06-22 00:55, Lawrence D’Oliveiro wrote: > On Wednesday, June 22, 2016 at 7:50:50 AM UTC+12, Tim Chase wrote: >> I have a ~/.XCompose file that contains something like > > You may find your custom XCompose is ignored by certain GUI apps. > This is because the GUI toolkits they are using nee

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-22 Thread Lawrence D’Oliveiro
On Wednesday, June 22, 2016 at 7:50:50 AM UTC+12, Tim Chase wrote: > > I have a ~/.XCompose file that contains something like > > include "%L" >: "😖" U1F616 # CONFOUNDED FACE >: "😛" U1F61B # FACE WITH > STUCK-OUT TONGUE: "😛" U1F61B # > FACE WIT

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-21 Thread Marko Rauhamaa
Tim Chase : > I have a ~/.XCompose file that contains something like My Fedora 23 setup has === BEGIN /etc/X11/xinit/xinitrc-common= [...] userxkbmap=$HOME/.Xkbmap [...] if [ -r "$userxkbmap" ]; then setxkbmap $(cat "$userxkbmap") XKB_IN_USE=yes fi [...] =

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-21 Thread Tim Chase
On 2016-06-21 21:56, Marko Rauhamaa wrote: > Rustom Mody : > > > Regarding xkb: > > > > Some good advice given to me by Yuri Khan on emacs list > > https://lists.gnu.org/archive/html/help-gnu-emacs/2015-01/msg00332.html > > Well, not quite: > >* Find the XKB data directory. [Normally, this >

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-21 Thread Marko Rauhamaa
Rustom Mody : > Regarding xkb: > > Some good advice given to me by Yuri Khan on emacs list > https://lists.gnu.org/archive/html/help-gnu-emacs/2015-01/msg00332.html Well, not quite: * Find the XKB data directory. [Normally, this is /usr/share/X11/xkb.] * In its “keycodes” subdirectory, cre

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-21 Thread Tim Chase
On 2016-06-21 11:35, Marko Rauhamaa wrote: > > These are all pretty easy to remember. > > German umlauts a" o" u" give ä ö ü (or use uppercase) > > Spanish eña (spelling?) and punctuations: n~ ?? !! --> ñ ¿ ¡ > > French accents: e' e` e^ c, --> é è ê ç > > Money: c= l- y- c/ --> € £ ¥ ¢ >

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-21 Thread Rustom Mody
On Tuesday, June 21, 2016 at 6:38:19 PM UTC+5:30, Marko Rauhamaa wrote: > A coworker of mine went through the trouble of doing the xmodmap > equivalent with setxkbmap. Thought of interviewing him about it one day. > > How-to's are really hard to come by: > >https://wiki.archlinux.org/index.ph

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-21 Thread Rustom Mody
On Tuesday, June 21, 2016 at 7:27:00 PM UTC+5:30, Rustom Mody wrote: > Emacs: : > Math: So far Ive used tex input method -- Not satisfactory After "Random832" pointed me to RFC1345 I checked that emacs has an RFC1345 input method. It may be nicer than tex input method -- need to check However like

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-21 Thread Rustom Mody
On Tuesday, June 21, 2016 at 6:38:19 PM UTC+5:30, Marko Rauhamaa wrote: > Rustom Mody : > > > On Tuesday, June 21, 2016 at 2:05:55 PM UTC+5:30, Marko Rauhamaa wrote: > >> (On the other hand, I have always specified my preferred keyboard > >> layout with .Xmodmap.) > > > > If this is being given as

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-21 Thread Marko Rauhamaa
Rustom Mody : > On Tuesday, June 21, 2016 at 2:05:55 PM UTC+5:30, Marko Rauhamaa wrote: >> (On the other hand, I have always specified my preferred keyboard >> layout with .Xmodmap.) > > If this is being given as advice I never gave it as advice. > its bad advice xmodmap is obsolete use xkb A c

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-21 Thread Rustom Mody
On Tuesday, June 21, 2016 at 2:05:55 PM UTC+5:30, Marko Rauhamaa wrote: > Larry Hudson : > > It sounds like you are almost, but not quite, describing the Linux > > Compose key. > > I have used Linux since the 1990's but don't know anything about "the > Linux Compose key." It used to be a real (a

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-21 Thread Marko Rauhamaa
Larry Hudson : > It sounds like you are almost, but not quite, describing the Linux > Compose key. I have used Linux since the 1990's but don't know anything about "the Linux Compose key." (On the other hand, I have always specified my preferred keyboard layout with .Xmodmap.) > These are all pre

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-21 Thread Larry Hudson via Python-list
On 06/19/2016 08:29 PM, Steven D'Aprano wrote: On Mon, 20 Jun 2016 12:07 pm, Rustom Mody wrote: [snip] In theory most Linux apps support an X mechanism for inserting characters that don't appear on the keyboard. Unfortunately, this gives no feedback when you get it wrong, and discoverablity is

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-20 Thread Rustom Mody
On Monday, June 20, 2016 at 8:30:25 PM UTC+5:30, Steven D'Aprano wrote: > On Tue, 21 Jun 2016 12:23 am, Grant Edwards wrote: > > > On 2016-06-20, Phil Boutros wrote: > [...] > >> Ctrl-K, =, ! (last two steps interchangeable). Done. Result: ≠ > > > > On any non-broken X11 system it's: = / >

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-20 Thread Steven D'Aprano
On Tue, 21 Jun 2016 12:23 am, Grant Edwards wrote: > On 2016-06-20, Phil Boutros wrote: [...] >> Ctrl-K, =, ! (last two steps interchangeable). Done. Result: ≠ > > On any non-broken X11 system it's: = / Nope, doesn't work for me. I guess I've got a "broken" X11 system. Oh, I did learn one

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-20 Thread Grant Edwards
On 2016-06-20, Phil Boutros wrote: > Steven D'Aprano wrote: >> >> Quote: >> >> "Why do we have to write x!=y then argue about the status of x<>y when we >> can simply write x≠y?" >> >> "Simply"? >> >> This is how I write x≠y from scratch: > > > To wrap this back full circle, here's how it's d

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-20 Thread Rustom Mody
On Monday, June 20, 2016 at 11:34:36 AM UTC+5:30, Random832 wrote: > On Mon, Jun 20, 2016, at 01:03, Rustom Mody wrote: > > > Ctrl-K, =, ! (last two steps interchangeable). Done. Result: ≠ > > > > Are these 'shortcuts' parameterizable? > > They originate from RFC 1345, with the extension that

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-20 Thread Steven D'Aprano
On Monday 20 June 2016 17:57, Lawrence D’Oliveiro wrote: > On Monday, June 20, 2016 at 4:31:00 PM UTC+12, Phil Boutros wrote: >> >> Steven D'Aprano wrote: >>> >>> This is how I write x≠y from scratch: >> >> >> To wrap this back full circle, here's how it's done on vim: >> >> Ctrl-K, =, ! (l

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-20 Thread Lawrence D’Oliveiro
On Monday, June 20, 2016 at 4:31:00 PM UTC+12, Phil Boutros wrote: > > Steven D'Aprano wrote: >> >> This is how I write x≠y from scratch: > > > To wrap this back full circle, here's how it's done on vim: > > Ctrl-K, =, ! (last two steps interchangeable). Done. Result: ≠ Standard Linux

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-19 Thread Random832
On Mon, Jun 20, 2016, at 01:03, Rustom Mody wrote: > > Ctrl-K, =, ! (last two steps interchangeable). Done. Result: ≠ > > Are these 'shortcuts' parameterizable? They originate from RFC 1345, with the extension that they can be reversed if the reverse doesn't itself exist as a RFC 1345 combinat

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-19 Thread Rustom Mody
On Monday, June 20, 2016 at 10:01:00 AM UTC+5:30, Phil Boutros wrote: > Steven D'Aprano wrote: > > > > Quote: > > > > "Why do we have to write x!=y then argue about the status of x<>y when we > > can simply write x≠y?" > > > > "Simply"? > > > > This is how I write x≠y from scratch: > > > To

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-19 Thread Rustom Mody
On Monday, June 20, 2016 at 10:06:41 AM UTC+5:30, Rustom Mody wrote: > I have greater horror-stories to describe if you like > On my recent ubuntu upgrade my keyboard broke -- totally ie cant type > anything. > Here's a detailed rundown... > > Upgrade complete; reboot -- NO KEYBOARD -- Yikes > H

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-19 Thread Rustom Mody
On Monday, June 20, 2016 at 8:59:44 AM UTC+5:30, Steven D'Aprano wrote: > Without better tooling and more discoverability, non-ASCII characters as > syntax are an anti-feature. You need to decide which hat you have on - idealist - pragmatist From a pragmatic pov nothing you are saying below is a

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-19 Thread Phil Boutros
Steven D'Aprano wrote: > > Quote: > > "Why do we have to write x!=y then argue about the status of x<>y when we > can simply write x≠y?" > > "Simply"? > > This is how I write x≠y from scratch: To wrap this back full circle, here's how it's done on vim: Ctrl-K, =, ! (last two steps interch

Re: ASCII or Unicode? (was best text editor for programming Python on a Mac)

2016-06-19 Thread Steven D'Aprano
On Mon, 20 Jun 2016 12:07 pm, Rustom Mody wrote: > If python were to do more than lip service to REALLY being a unicode age > language why are things like this out of bounds even for discussion? > > http://blog.languager.org/2014/04/unicoded-python.html Quote: "Why do we have to write x!=y the

Re: ASCII and Unicode

2013-12-08 Thread rusi
On Monday, December 9, 2013 1:41:41 AM UTC+5:30, giacomo boffi wrote: > the wrong one... i.e, the one JUST BEFORE your change of > subject --- if i look at the "ellipsis" post, i see the same encoding > that you have mentioned > sorry for the confusion And thank you for pointing the way to the c

Re: ASCII and Unicode

2013-12-08 Thread giacomo boffi
Steven D'Aprano writes: > On Sat, 07 Dec 2013 17:05:34 +0100, giacomo boffi wrote: > >> Steven D'Aprano writes: >> >>> Ironically, your post was not Unicode. [...] Your post was sent using >>> a legacy encoding, Windows-1252, also known as CP-1252 >> >> i access rusi's post using a NNTP serve

Re: ASCII and Unicode

2013-12-08 Thread rusi
e he used the ellipsis characters: > Subject: Re: Managing Google Groups headaches > Date: Thu, 5 Dec 2013 23:13:54 -0800 (PST) > Content-Type: text/plain; charset=windows-1252 > Then his reply to me: > Subject: Re: ASCII and Unicode [was Re: Managing Google Groups headaches] &

Re: ASCII and Unicode

2013-12-08 Thread Steven D'Aprano
013 23:13:54 -0800 (PST) Content-Type: text/plain; charset=windows-1252 Then his reply to me: Subject: Re: ASCII and Unicode [was Re: Managing Google Groups headaches] Date: Fri, 6 Dec 2013 18:33:39 -0800 (PST) Content-Type: text/plain; charset=UTF-8 And finally, his reply to you: Subj

Re: ASCII and Unicode

2013-12-08 Thread rusi
On Saturday, December 7, 2013 9:35:34 PM UTC+5:30, giacomo boffi wrote: > Steven D'Aprano writes: > > Ironically, your post was not Unicode. [...] Your post was sent > > using a legacy encoding, Windows-1252, also known as CP-1252 > i access rusi's post using a NNTP server, > and in his post i

Re: ASCII and Unicode

2013-12-07 Thread giacomo boffi
Steven D'Aprano writes: > Ironically, your post was not Unicode. [...] Your post was sent > using a legacy encoding, Windows-1252, also known as CP-1252 i access rusi's post using a NNTP server, and in his post i see Content-Type: text/plain; charset=UTF-8 is it possible that what you see is

Re: ASCII and Unicode [was Re: Managing Google Groups headaches]

2013-12-06 Thread Chris Angelico
On Sat, Dec 7, 2013 at 2:16 PM, rusi wrote: > On Saturday, December 7, 2013 8:11:45 AM UTC+5:30, Chris Angelico wrote: >> On Sat, Dec 7, 2013 at 1:33 PM, rusi wrote: >> > That seems to suggest that something is not right with the python >> > mailing list config. No?? > >> If in doubt, blame someo

Re: ASCII and Unicode [was Re: Managing Google Groups headaches]

2013-12-06 Thread rusi
On Saturday, December 7, 2013 8:11:45 AM UTC+5:30, Chris Angelico wrote: > On Sat, Dec 7, 2013 at 1:33 PM, rusi wrote: > > That seems to suggest that something is not right with the python > > mailing list config. No?? > If in doubt, blame someone else, eh? > I'd first check what your browser's

Re: ASCII and Unicode [was Re: Managing Google Groups headaches]

2013-12-06 Thread MRAB
On 07/12/2013 02:41, Chris Angelico wrote: On Sat, Dec 7, 2013 at 1:33 PM, rusi wrote: That seems to suggest that something is not right with the python mailing list config. No?? If in doubt, blame someone else, eh? I'd first check what your browser's actually sending. Firebug will help ther

Re: ASCII and Unicode [was Re: Managing Google Groups headaches]

2013-12-06 Thread Chris Angelico
On Sat, Dec 7, 2013 at 1:33 PM, rusi wrote: > That seems to suggest that something is not right with the python > mailing list config. No?? If in doubt, blame someone else, eh? I'd first check what your browser's actually sending. Firebug will help there. See if your form fill-out is encoded as

Re: ASCII and Unicode [was Re: Managing Google Groups headaches]

2013-12-06 Thread rusi
On Saturday, December 7, 2013 12:30:18 AM UTC+5:30, Steven D'Aprano wrote: > On Fri, 06 Dec 2013 05:03:57 -0800, rusi wrote: > > Evidently (and completely inadvertently) this exchange has just > > illustrated one of the inadmissable assumptions: > > "unicode as a medium is universal in the same wa

Re: ASCII and Unicode [was Re: Managing Google Groups headaches]

2013-12-06 Thread Chris Angelico
On Sat, Dec 7, 2013 at 6:00 AM, Steven D'Aprano wrote: > - character 33 was permitted to be either the exclamation > mark ! or the logical OR symbol | > > - consequently character 124 (vertical bar) was always > displayed as a broken bar ¦, which explains why even today >

Re: ASCII and Unicode [was Re: Managing Google Groups headaches]

2013-12-06 Thread Roy Smith
Steven D'Aprano pearwood.info> writes: > Yes, it appears that MT-NewsWatcher is *deeply, deeply* confused about > encodings and character sets. It doesn't just assume things are ASCII, > but makes a half-hearted attempt to be charset-aware, but badly. I can > only imagine that it was written b

Re: ASCII and Unicode [was Re: Managing Google Groups headaches]

2013-12-06 Thread Gene Heskett
On Friday 06 December 2013 14:30:06 Steven D'Aprano did opine: > On Fri, 06 Dec 2013 05:03:57 -0800, rusi wrote: > > Evidently (and completely inadvertently) this exchange has just > > illustrated one of the inadmissable assumptions: > > > > "unicode as a medium is universal in the same way that

Re: Ascii to Unicode.

2010-07-30 Thread John Machin
On Jul 30, 4:18 am, Carey Tilden wrote: > In this case, you've been able to determine the > correct encoding (latin-1) for those errant bytes, so the file itself > is thus known to be in that encoding. The most probably "correct" encoding is, as already stated, and agreed by the OP to be, cp1252.

RE: Ascii to Unicode.

2010-07-30 Thread Lawrence D'Oliveiro
In message , Joe Goldthwaite wrote: > Next I tried to write the unicodestring object to a file thusly; > > output.write(unicodestring) > > I would have expected the write function to request the byte string from > the unicodestring object and simply write that byte string to a file. Encoded ac

Re: Ascii to Unicode.

2010-07-30 Thread Lawrence D'Oliveiro
In message <4c51d3b6$0$1638$742ec...@news.sonic.net>, John Nagle wrote: > UTF-8 is a stream format for Unicode. It's slightly compressed ... “Variable-length” is not the same as “compressed”. Particularly if you’re mainly using non-Roman scripts... -- http://mail.python.org/mailman/listin

RE: Ascii to Unicode.

2010-07-30 Thread Lawrence D'Oliveiro
In message , Joe Goldthwaite wrote: > Ascii.csv isn't really a latin-1 encoded file. It's an ascii file with a > few characters above the 128 range that are causing Postgresql Unicode > errors. Those characters work fine in the Windows world but they're not > the correct byte representation for

Re: Ascii to Unicode.

2010-07-29 Thread Nobody
On Thu, 29 Jul 2010 23:49:40 +, Steven D'Aprano wrote: > It looks to me like Python uses a 16-bit implementation internally, It typically uses the platform's wchar_t, which is 16-bit on Windows and (typically) 32-bit on Unix. IIRC, it's possible to build Python with 32-bit Unicode on Windows

Re: Ascii to Unicode.

2010-07-29 Thread Mark Tolonen
"Joe Goldthwaite" wrote in message news:5a04846ed83745a8a99a944793792...@newmbp... Hi Steven, I read through the article you referenced. I understand Unicode better now. I wasn't completely ignorant of the subject. My confusion is more about how Python is handling Unicode than Unicode its

Re: Ascii to Unicode.

2010-07-29 Thread Steven D'Aprano
On Thu, 29 Jul 2010 11:14:24 -0700, Ethan Furman wrote: > Don't think of unicode as a byte stream. It's a bunch of numbers that > map to a bunch of symbols. Not only are Unicode strings a bunch of numbers ("code points", in Unicode terminology), but the numbers are not necessarily all the same

Re: Ascii to Unicode.

2010-07-29 Thread MRAB
John Nagle wrote: On 7/28/2010 3:58 PM, Joe Goldthwaite wrote: This still seems odd to me. I would have thought that the unicode function would return a properly encoded byte stream that could then simply be written to disk. Instead it seems like you have to re-encode the byte stream to some

Re: Ascii to Unicode.

2010-07-29 Thread John Nagle
On 7/28/2010 3:58 PM, Joe Goldthwaite wrote: This still seems odd to me. I would have thought that the unicode function would return a properly encoded byte stream that could then simply be written to disk. Instead it seems like you have to re-encode the byte stream to some kind of escaped Ascii

Re: Ascii to Unicode.

2010-07-29 Thread Ethan Furman
Joe Goldthwaite wrote: Hi Ulrich, Ascii.csv isn't really a latin-1 encoded file. It's an ascii file with a few characters above the 128 range . . . It took me a while to get this point too (if you already have "gotten it", I apologize, but the above comment leads me to believe you haven't).

Re: Ascii to Unicode.

2010-07-29 Thread Carey Tilden
On Thu, Jul 29, 2010 at 10:59 AM, Joe Goldthwaite wrote: > Hi Ulrich, > > Ascii.csv isn't really a latin-1 encoded file.  It's an ascii file with a > few characters above the 128 range that are causing Postgresql Unicode > errors.  Those characters work fine in the Windows world but they're not th

Re: Ascii to Unicode.

2010-07-29 Thread Ethan Furman
Joe Goldthwaite wrote: Hi Steven, I read through the article you referenced. I understand Unicode better now. I wasn't completely ignorant of the subject. My confusion is more about how Python is handling Unicode than Unicode itself. I guess I'm fighting my own misconceptions. I do that a lot

RE: Ascii to Unicode.

2010-07-29 Thread Joe Goldthwaite
Hi Ulrich, Ascii.csv isn't really a latin-1 encoded file. It's an ascii file with a few characters above the 128 range that are causing Postgresql Unicode errors. Those characters work fine in the Windows world but they're not the correct byte representation for Unicode. What I'm attempting to d

RE: Ascii to Unicode.

2010-07-29 Thread Joe Goldthwaite
Hi Steven, I read through the article you referenced. I understand Unicode better now. I wasn't completely ignorant of the subject. My confusion is more about how Python is handling Unicode than Unicode itself. I guess I'm fighting my own misconceptions. I do that a lot. It's hard for me to un

Re: Ascii to Unicode.

2010-07-29 Thread Ulrich Eckhardt
Joe Goldthwaite wrote: > import unicodedata > > input = file('ascii.csv', 'rb') > output = file('unicode.csv','wb') > > for line in input.xreadlines(): > unicodestring = unicode(line, 'latin1') > output.write(unicodestring.encode('utf-8')) # This second encode >

Re: Ascii to Unicode.

2010-07-28 Thread Steven D'Aprano
On Wed, 28 Jul 2010 15:58:01 -0700, Joe Goldthwaite wrote: > This still seems odd to me. I would have thought that the unicode > function would return a properly encoded byte stream that could then > simply be written to disk. Instead it seems like you have to re-encode > the byte stream to some

RE: Ascii to Unicode.

2010-07-28 Thread Joe Goldthwaite
> Hello hello ... you are running on Windows; the likelihood that you > actually have data encoded in latin1 is very very small. Follow MRAB's > answer but replace "latin1" by "cp1252". I think you're right. The database I'm working with is a US zip code database. It gets updated monthly. The p

Re: Ascii to Unicode.

2010-07-28 Thread John Machin
On Jul 29, 4:32 am, "Joe Goldthwaite" wrote: > Hi, > > I've got an Ascii file with some latin characters. Specifically \xe1 and > \xfc.  I'm trying to import it into a Postgresql database that's running in > Unicode mode. The Unicode converter chokes on those two characters. > > I could just manua

Re: Ascii to Unicode.

2010-07-28 Thread Thomas Jollans
On 07/28/2010 09:29 PM, John Nagle wrote: > for rawline in input : > unicodeline = unicode(line,'latin1')# Latin-1 to Unicode > output.write(unicodeline.encode('utf-8')) # Unicode to as UTF-8 you got your blocks wrong. -- http://mail.python.org/mailman/listinfo/python-list

Re: Ascii to Unicode.

2010-07-28 Thread John Nagle
On 7/28/2010 11:32 AM, Joe Goldthwaite wrote: Hi, I've got an Ascii file with some latin characters. Specifically \xe1 and \xfc. I'm trying to import it into a Postgresql database that's running in Unicode mode. The Unicode converter chokes on those two characters. I could just manually replac

Re: Ascii to Unicode.

2010-07-28 Thread Thomas Jollans
On 07/28/2010 08:32 PM, Joe Goldthwaite wrote: > Hi, > > I've got an Ascii file with some latin characters. Specifically \xe1 and > \xfc. I'm trying to import it into a Postgresql database that's running in > Unicode mode. The Unicode converter chokes on those two characters. > > I could just ma

Re: Ascii to Unicode.

2010-07-28 Thread MRAB
Joe Goldthwaite wrote: Hi, I've got an Ascii file with some latin characters. Specifically \xe1 and \xfc. I'm trying to import it into a Postgresql database that's running in Unicode mode. The Unicode converter chokes on those two characters. I could just manually replace those to character

Re: 'ascii' codec can't encode character u'\xe4' in position 4: ordinal not in range(128)

2009-11-08 Thread Ben Finney
balavignesh writes: > Whats the wrong in my code? Without seeing your code, all we could do is guess, poorly. Far better would be if you can construct a very small example, one that you post here so any reader here could run it, that demonstrates the behaviour you want explained. Don't forget t

Re: Ascii codec can't encode

2008-10-30 Thread Ulrich Eckhardt
luca72 wrote: > UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in > position 8: ordinal not in range(128) > > I have solve in this way: > > file_ricerca = codecs.open('ri', 'wb', 'ISO-8859-15', 'repalce') That should be 'replace' instead of 'repalce', I assume you just mistyped

Re: Ascii codec can't encode

2008-10-30 Thread luca72
the arror are: >>> Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/eric4/DebugClients/Python/ DebugClientBase.py", line 1006, in __unhandled_exception self.mainThread.user_exception(None, (exctype,excval,exctb), 1) File "/usr/lib/python2.5

Re: Ascii codec can't encode

2008-10-30 Thread Marc 'BlackJack' Rintsch
On Thu, 30 Oct 2008 03:01:07 -0700, luca72 wrote: > the code is this > # -*- coding: ISO-8859-1 -*- > from BeautifulSoup import BeautifulSoup import urllib > sito = urllib.urlopen('http://text.net/') esamino = BeautifulSoup(sito) > luca = esamino.findAll('tr', align='center') lunghezza = len(luca)

Re: Ascii codec can't encode

2008-10-30 Thread luca72
Hello Again the code is this # -*- coding: ISO-8859-1 -*- from BeautifulSoup import BeautifulSoup import urllib sito = urllib.urlopen('http://text.net/') esamino = BeautifulSoup(sito) luca = esamino.findAll('tr', align='center') lunghezza = len(luca) messaggio_per_scar = open('me', 'wb') file_rice

Re: Ascii codec can't encode

2008-10-30 Thread Ulrich Eckhardt
luca72 wrote: > Hy the code is this: > > Pok\xe9mon That's not what I meant, I meant a piece of Python source code. This piece has to be large enough to demonstrate the problem but with everything else removed. The point is that guessing what is wrong in your program is just futile; In order to h

Re: Ascii codec can't encode

2008-10-30 Thread luca72
On 30 Ott, 10:27, luca72 <[EMAIL PROTECTED]> wrote: > Hy the code is this: > > Pok\xe9mon > > Luca Sorry is the é -- http://mail.python.org/mailman/listinfo/python-list

Re: Ascii codec can't encode

2008-10-30 Thread luca72
Hy the code is this: Pok\xe9mon Luca -- http://mail.python.org/mailman/listinfo/python-list

Re: Ascii codec can't encode

2008-10-30 Thread Ulrich Eckhardt
luca72 wrote: > hello i have this problem: > UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in > position 8: ordinal not in range(128) This is the result of transcoding a Unicode string to ASCII, where the Unicode string contains a character that is not representable in ASCII. Th

Re: Ascii Menu I/O redirection

2008-09-20 Thread Hendrik van Rooyen
Steven D'Aprano <[EMAIL PROTECTED]> wrote: >I'm not sure that closing stdin and stout are a good idea. This could >have side-effects for other parts of your program, and will almost >certainly end badly if you're running in the interactive interpreter. > Its a very simple thingy - there will o

Re: Ascii Menu I/O redirection

2008-09-20 Thread Steven D'Aprano
On Sat, 20 Sep 2008 23:14:26 +0200, Hendrik van Rooyen wrote: > class console(object): > """ > This spoofs a single file like object, using stdout & - in > (Minimalistic proof of concept implementation) """ > > def __init__(self): > self.read = sys.stdin.read > sel

Re: Ascii to binary conversion

2008-08-09 Thread Terry Reedy
azrael wrote: Any idea how to easily write a function that recieves a character or string and returns a binary number like: ascii("1") is converted to bin("00110001") Other alternatives in 2.6 (I believe) and 3.0: >>> 0b00111010101 469 >>> b='111010101' >>> eval('0b'+b) 469 >>> '{0:b}'.forma

Re: Ascii to binary conversion

2008-08-09 Thread John Machin
On Aug 10, 12:37 am, azrael <[EMAIL PROTECTED]> wrote: [top-posting corrected] > > On 9 kol, 15:39, John Machin <[EMAIL PROTECTED]> wrote: > > > On Aug 9, 11:18 pm, azrael <[EMAIL PROTECTED]> wrote: > > > > Hy folks, > > > > I googled, and searched, and can not bealive that I have not found a > > >

Re: Ascii to binary conversion

2008-08-09 Thread azrael
You see, I don't like reading some tutorials. I pick myself a problem and look for ways to slove it. I am using Python for about 2 years, but mostly for image processing. As you say, ord is oposite to chr. I learn by example. thnx guys, this looks great On 9 kol, 16:47, Larry Bates <[EMAIL PROTE

Re: Ascii to binary conversion

2008-08-09 Thread Mensanator
On Aug 9, 8:18�am, azrael <[EMAIL PROTECTED]> wrote: > Hy folks, > > I googled, and searched, and can not bealive that I have not found a > built in way to convert the easy and elegant python way a function to > easily convert simple ascii data to binary and back. > > I've written some my own but t

Re: Ascii to binary conversion

2008-08-09 Thread Larry Bates
azrael wrote: looks nice. is there an oposite function of ord() so I could also bring a binary number also back to ascii. the speed matters if you plan to exchange about 10 M ascii chars and don't wont to wait a year for the results. :) On 9 kol, 15:39, John Machin <[EMAIL PROTECTED]> wrote:

Re: Ascii to binary conversion

2008-08-09 Thread azrael
looks nice. is there an oposite function of ord() so I could also bring a binary number also back to ascii. the speed matters if you plan to exchange about 10 M ascii chars and don't wont to wait a year for the results. :) On 9 kol, 15:39, John Machin <[EMAIL PROTECTED]> wrote: > On Aug 9, 11:1

Re: Ascii to binary conversion

2008-08-09 Thread John Machin
On Aug 9, 11:18 pm, azrael <[EMAIL PROTECTED]> wrote: > Hy folks, > > I googled, and searched, and can not bealive that I have not found a > built in way to convert the easy and elegant python way a function to > easily convert simple ascii data to binary and back. > > I've written some my own but

Re: ascii to unicode line endings

2007-05-03 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, fidtz wrote: import codecs testASCII = file("c:\\temp\\test1.txt",'w') testASCII.write("\n") testASCII.close() testASCII = file("c:\\temp\\test1.txt",'r') testASCII.read() > '\n' > Bit pattern on disk : \0x0D\0x0A testASCII.seek(0) te

Re: ascii to unicode line endings

2007-05-03 Thread fidtz
On 3 May, 13:39, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > On 2 May 2007 09:19:25 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > The code: > > > import codecs > > > udlASCII = file("c:\\temp\\CSVDB.udl",'r') > > udlUNI = codecs.open("c:\\temp\\CSVDB2.udl",'w',"utf_16") > > udlUNI.write(u

Re: ascii to unicode line endings

2007-05-03 Thread fidtz
On 3 May, 13:00, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > On 3 May 2007 04:30:37 -0700, [EMAIL PROTECTED] wrote: > > > > >On 2 May, 17:29, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > >> On 2 May 2007 09:19:25 -0700, [EMAIL PROTECTED] wrote: > > >> >The code: > > >> >import codecs > > >

Re: ascii to unicode line endings

2007-05-03 Thread Jerry Hill
On 2 May 2007 09:19:25 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > The code: > > import codecs > > udlASCII = file("c:\\temp\\CSVDB.udl",'r') > udlUNI = codecs.open("c:\\temp\\CSVDB2.udl",'w',"utf_16") > udlUNI.write(udlASCII.read()) > udlUNI.close() > udlASCII.close() > > This doesn't se

Re: ascii to unicode line endings

2007-05-03 Thread Jean-Paul Calderone
On 3 May 2007 04:30:37 -0700, [EMAIL PROTECTED] wrote: >On 2 May, 17:29, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >> On 2 May 2007 09:19:25 -0700, [EMAIL PROTECTED] wrote: >> >> >> >> >The code: >> >> >import codecs >> >> >udlASCII = file("c:\\temp\\CSVDB.udl",'r') >> >udlUNI = codecs.open("c

Re: ascii to unicode line endings

2007-05-03 Thread fidtz
On 2 May, 17:29, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > On 2 May 2007 09:19:25 -0700, [EMAIL PROTECTED] wrote: > > > > >The code: > > >import codecs > > >udlASCII = file("c:\\temp\\CSVDB.udl",'r') > >udlUNI = codecs.open("c:\\temp\\CSVDB2.udl",'w',"utf_16") > > >udlUNI.write(udlASCII.read

Re: ascii to unicode line endings

2007-05-02 Thread Jean-Paul Calderone
On 2 May 2007 09:19:25 -0700, [EMAIL PROTECTED] wrote: >The code: > >import codecs > >udlASCII = file("c:\\temp\\CSVDB.udl",'r') >udlUNI = codecs.open("c:\\temp\\CSVDB2.udl",'w',"utf_16") > >udlUNI.write(udlASCII.read()) > >udlUNI.close() >udlASCII.close() > >This doesn't seem to generate the corre

Re: ascii-unicode replacement

2007-04-05 Thread Andrea Valle
Many thanks Gabriel Convert to unicode right there, using read_text.decode("ascii"). You have unicode now. That's exactly what I was searching for. This new line: text = text.decode("ascii") solved my problem. Best -a- -- Andrea Valle -

Re: ascii-unicode replacement

2007-04-05 Thread Gabriel Genellina
En Thu, 05 Apr 2007 14:28:20 -0300, Andrea Valle <[EMAIL PROTECTED]> escribió: > I scripted some text files with another language which cannot handle > unicode. > As I need special character in the resulting text files (IPA > extension), my idea was to define some special ascii sequences in the

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
rom: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Steven D'Aprano Sent: Tuesday, July 04, 2006 9:35 AM To: python-list@python.org Subject: RE: ascii character - removing chars from string On Tue, 04 Jul 2006 09:01:15 -0700, bruce wrote: > update... > > the error i'm g

RE: ascii character - removing chars from string

2006-07-04 Thread Steven D'Aprano
On Tue, 04 Jul 2006 09:01:15 -0700, bruce wrote: > update... > > the error i'm getting... > UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in > position 62: ordinal not in range(128) Okay, now we're making progress -- we know what exception you're getting. Now, how about t

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
-list@python.org Subject: Re: ascii character - removing chars from string bruce wrote: > i've done the s.replace('\xa0','') with no luck. let me guess: you wrote s.replace("\xa0", "") instead of s = s.replace("\xa0", ""

Re: ascii character - removing chars from string

2006-07-04 Thread Fredrik Lundh
bruce wrote: > i've done the s.replace('\xa0','') with no luck. let me guess: you wrote s.replace("\xa0", "") instead of s = s.replace("\xa0", "") ? -- http://mail.python.org/mailman/listinfo/python-list

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Steven D'Aprano Sent: Tuesday, July 04, 2006 8:45 AM To: python-list@python.org Subject: RE: ascii character - removing chars from string On Tue, 04 Jul 2006 08:09:53 -0700, bruce wrote: > simon...

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
i've done the s.replace('\xa0','') with no luck. -bruce -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Steven D'Aprano Sent: Tuesday, July 04, 2006 8:45 AM To: python-list@python.org Subject: RE: ascii character - removing cha

RE: ascii character - removing chars from string

2006-07-04 Thread Steven D'Aprano
On Tue, 04 Jul 2006 08:09:53 -0700, bruce wrote: > simon... > > the issue that i'm seeing is not a result of simply using the > 'string.replace' function. it appears that there's something else going on > in the text > > although i can see the nbsp in the file, the file is manipulated by a n

RE: ascii character - removing chars from string

2006-07-04 Thread bruce
andle non-ascii chars. i'm still looking for a way to search/replace non-ascii chars... this would/should resolve my issue.. -bruce -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Simon Forman Sent: Monday, July 03, 2006 11:28 PM To: python-list@python.org

RE: ascii character - removing chars from string update

2006-07-03 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, bruce wrote: > here is a sample of the text i'm looking to do hte search/replace for... > > bgcolor="#ff" > ACCT 209 - SURVEY OF ACCT PRIN   > > i'm trying to figure out how to replace the " " with a ''. in html, the > ' ' char is not a valid

Re: ascii character - removing chars from string

2006-07-03 Thread Simon Forman
i'm looking to remove or replace the insances with a ' ' (space) Simplicity: s.replace(' ', ' ') ~Simon "You keep using that word. I do not think it means what you think it means." -Inigo Montoya, "The Princess Bride" > > -bru

  1   2   >