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


Groups > comp.lang.python > #38779

Re: UnicodeEncodeError when not running script from IDE

References (2 earlier) <0d6d513d-fa12-4d51-a33d-7bb38f1ee6b2@googlegroups.com> <mailman.1700.1360680572.2939.python-list@python.org> <780d353a-de5c-4d04-8f51-11d81802351b@googlegroups.com> <mailman.1711.1360684727.2939.python-list@python.org> <a80a49be-b3c4-4549-bf94-523605dbbeec@googlegroups.com>
From Fabio Zadrozny <fabiofz@gmail.com>
Date 2013-02-12 18:04 -0200
Subject Re: UnicodeEncodeError when not running script from IDE
Newsgroups comp.lang.python
Message-ID <mailman.1722.1360699522.2939.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Just to note, PyDev does something behind the scenes (it sets the encoding
for the console).

You may specify which encoding you want at your launch configuration (in
the 'common' tab you can set the encoding you want for the shell).

Cheers,

Fabio


On Tue, Feb 12, 2013 at 3:12 PM, Magnus Pettersson
<magpettersson@gmail.com>wrote:

> > What encoding is this file?  Since you're appending to it, you really
> >
> > need to match the pre-existing encoding, or the next program to deal
> >
> > with it is in big trouble.  So using the io.open() without the encoding=
> >
> > keyword is probably a mistake.
>
> The .txt file is in UTF-8
>
> I have got it to work now in the terminal, but i dont understand what im
> doing and why i didnt need to do all the unicode strings and encode mumbo
> jumbo in eclipse
>
> #Here kanji = u"私"
> baseurl = u"http://www.romajidesu.com/kanji/"
> url = baseurl+kanji
> savefile([url]) #this test works now. uses: io.open(filepath,
> "a",encoding="UTF-8") as f:
> # This made the fetching of the website work. Why did i have to write
> url.encode("UTF-8") when url already is unicode? I feel i dont have a good
> understanding of this.
> page = urllib2.urlopen(url.encode("UTF-8"))
>
>
> ....
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

UnicodeEncodeError when not running script from IDE Magnus Pettersson <magpettersson@gmail.com> - 2013-02-12 02:43 -0800
  Re: UnicodeEncodeError when not running script from IDE Andrew Berg <bahamutzero8825@gmail.com> - 2013-02-12 05:01 -0600
    Re: UnicodeEncodeError when not running script from IDE Magnus Pettersson <magpettersson@gmail.com> - 2013-02-12 06:24 -0800
      Re: UnicodeEncodeError when not running script from IDE Peter Otten <__peter__@web.de> - 2013-02-12 15:49 +0100
        Re: UnicodeEncodeError when not running script from IDE Magnus Pettersson <magpettersson@gmail.com> - 2013-02-12 07:29 -0800
          Re: UnicodeEncodeError when not running script from IDE Peter Otten <__peter__@web.de> - 2013-02-12 16:48 +0100
          Re: UnicodeEncodeError when not running script from IDE Dave Angel <davea@davea.name> - 2013-02-12 10:58 -0500
            Re: UnicodeEncodeError when not running script from IDE Magnus Pettersson <magpettersson@gmail.com> - 2013-02-12 09:12 -0800
              Re: UnicodeEncodeError when not running script from IDE Fabio Zadrozny <fabiofz@gmail.com> - 2013-02-12 18:04 -0200
              Re: UnicodeEncodeError when not running script from IDE Dave Angel <davea@davea.name> - 2013-02-12 15:51 -0500
                Re: UnicodeEncodeError when not running script from IDE Magnus Pettersson <magpettersson@gmail.com> - 2013-02-12 16:20 -0800
                Re: UnicodeEncodeError when not running script from IDE Dave Angel <davea@davea.name> - 2013-02-12 22:51 -0500
              Re: UnicodeEncodeError when not running script from IDE Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-13 11:21 +1100
                Re: UnicodeEncodeError when not running script from IDE Magnus Pettersson <magpettersson@gmail.com> - 2013-02-12 16:40 -0800
        Re: UnicodeEncodeError when not running script from IDE Magnus Pettersson <magpettersson@gmail.com> - 2013-02-12 07:29 -0800
      Re: UnicodeEncodeError when not running script from IDE MRAB <python@mrabarnett.plus.com> - 2013-02-12 21:03 +0000
    Re: UnicodeEncodeError when not running script from IDE Magnus Pettersson <magpettersson@gmail.com> - 2013-02-12 06:24 -0800
  Re: UnicodeEncodeError when not running script from IDE Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-12 22:43 +1100
    Re: UnicodeEncodeError when not running script from IDE Magnus Pettersson <magpettersson@gmail.com> - 2013-02-12 04:34 -0800
      Re: UnicodeEncodeError when not running script from IDE Terry Reedy <tjreedy@udel.edu> - 2013-02-12 11:07 -0500

csiph-web