Re: String encoding question

2009-09-19 Thread Joshua Russo
On Sat, Sep 19, 2009 at 3:07 PM, Karen Tracey wrote: > On Sat, Sep 19, 2009 at 11:51 AM, Joshua Russo wrote: > >> Just one other thing. I was under the impression that x = u'' >> is equivalent to x = Unicode(''). Is that not correct? Seeing as you

Re: String encoding question

2009-09-19 Thread Karen Tracey
On Sat, Sep 19, 2009 at 11:51 AM, Joshua Russo wrote: > Just one other thing. I was under the impression that x = u'' is equivalent > to x = Unicode(''). Is that not correct? Seeing as you seem to be > indicating a difference between the unicode object and a literal. > >

Re: String encoding question

2009-09-19 Thread Joshua Russo
On Sat, Sep 19, 2009 at 2:40 PM, Karen Tracey wrote: > On Sat, Sep 19, 2009 at 11:19 AM, Joshua Russo wrote: > >> ... in fact using utf-8 string literals can cause problems in other places >>> with code that assumes another encoding (e.g. ascii) for

Re: String encoding question

2009-09-19 Thread Karen Tracey
On Sat, Sep 19, 2009 at 11:19 AM, Joshua Russo wrote: > ... in fact using utf-8 string literals can cause problems in other places >> with code that assumes another encoding (e.g. ascii) for byte strings. >> > > Could you expand on this? I know that the Unicode string

Re: String encoding question

2009-09-19 Thread Masklinn
On 19 Sep 2009, at 17:19 , Joshua Russo wrote: >> ... in fact using utf-8 string literals can cause problems in other >> places >> with code that assumes another encoding (e.g. ascii) for byte >> strings. >> > > Could you expand on this? I know that the Unicode string object has > different

Re: String encoding question

2009-09-19 Thread Joshua Russo
> > ... in fact using utf-8 string literals can cause problems in other places > with code that assumes another encoding (e.g. ascii) for byte strings. > Could you expand on this? I know that the Unicode string object has different methods than standard String, but are there other scenarios where

Re: String encoding question

2009-09-19 Thread Joshua Russo
On Sat, Sep 19, 2009 at 1:31 PM, Karen Tracey wrote: > On Sat, Sep 19, 2009 at 9:59 AM, Joshua Russo wrote: > >> I was working through some regression tests and saw a scenario I thought >> wasn't allowed/recommended. I was under the impression that if

Re: String encoding question

2009-09-19 Thread Masklinn
On 19 Sep 2009, at 16:31 , Karen Tracey wrote: > Without the encoding declaration, the interpreter would not know the > encoding of the source bytes, so would be unable (without making some > assumption) to correctly build unicode string objects from unicode > literals. It doesn't even bother

Re: String encoding question

2009-09-19 Thread Karen Tracey
On Sat, Sep 19, 2009 at 9:59 AM, Joshua Russo wrote: > I was working through some regression tests and saw a scenario I thought > wasn't allowed/recommended. I was under the impression that if you specified > UTF-8 encoding at the top of the file you where not suppose to

Re: String encoding question

2009-09-19 Thread Masklinn
On 19 Sep 2009, at 15:59 , Joshua Russo wrote: > I was working through some regression tests and saw a scenario I > thought > wasn't allowed/recommended. I was under the impression that if you > specified > UTF-8 encoding at the top of the file you where not suppose to use u > decorated

String encoding question

2009-09-19 Thread Joshua Russo
I was working through some regression tests and saw a scenario I thought wasn't allowed/recommended. I was under the impression that if you specified UTF-8 encoding at the top of the file you where not suppose to use u decorated unicode static string. So instead of u'prédio' I use 'prédio' in

Re: Encoding question

2009-09-09 Thread Oleg Oltar
Well, I prefer to find alt tag inside my image and check that it's correct instead of, checking that whole response contains some text. btw, have a problem: b = BeautifulSoap(client.get("/")) b.find('img')["alt"] again gives me those strange symbols I am updating my django now. (was using 1.0)

Re: Encoding question

2009-09-09 Thread Karen Tracey
On Wed, Sep 9, 2009 at 5:06 AM, Oleg Oltar wrote: > Hi! > > One of my tests returned following text () > > The test: > from django.test.client import Client > c = Client() > resp = c.get("/") > resp.content > > In [25]: resp.content > Out[25]: '\r\n\r\n\r\n Strict//EN"

Re: [Tutor] Encoding question

2009-09-09 Thread Kent Johnson
On Wed, Sep 9, 2009 at 5:06 AM, Oleg Oltar wrote: > Hi! > > One of my tests returned following text () > > The test: > from django.test.client import Client >  c = Client() > resp = c.get("/") > resp.content > > In [25]: resp.content > Out[25]: '\r\n\r\n\r\n Strict//EN" >

Re: Encoding question

2009-09-09 Thread Oleg Oltar
It's more then great! Thanks! 2009/9/9 ray > > Hi Oleg > > You can use BeautifulSoup > > from BeautifulSoup import BeautifulSoup > >>> html = '\r\n\r\n\r\n Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;>\r\n\r\n xmlns="http://www.w3.org/1999/xhtml;>\r\n

Re: Encoding question

2009-09-09 Thread ray
Hi Oleg You can use BeautifulSoup from BeautifulSoup import BeautifulSoup >>> html = '\r\n\r\n\r\n>> Strict//EN" >>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;>\r\n\r\n>> xmlns="http://www.w3.org/1999/xhtml;>\r\n \r\n>> http-equiv="content-type" content="text/html; charset=utf-8"

Encoding question

2009-09-09 Thread Oleg Oltar
Hi! One of my tests returned following text () The test: from django.test.client import Client c = Client() resp = c.get("/") resp.content In [25]: resp.content Out[25]: '\r\n\r\n\r\nhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;>\r\n\r\nhttp://www.w3.org/1999/xhtml;>\r\n \r\n\r\n

Re: encoding question

2009-07-29 Thread Jarek Zgoda
Wiadomość napisana w dniu 2009-07-29, o godz. 10:04, przez alecs: > filename = smart_unicode(file.name, encoding='cp1251', > strings_only=False, errors='strict') > > destination = open('%s/%s' % (dir_path, filename), 'wb+') > > UnicodeEncodeError ('ascii', u'1.3.1.\u0421\u043b.\u041f >

encoding question

2009-07-29 Thread alecs
filename = smart_unicode(file.name, encoding='cp1251', strings_only=False, errors='strict') destination = open('%s/%s' % (dir_path, filename), 'wb+') UnicodeEncodeError ('ascii', u'1.3.1.\u0421\u043b.\u041f \u0435\u0440\u0435\u043d\u043e\u0441 \u043e\u0442\u043f

Re: encoding question

2009-06-25 Thread alexarsh
Hi, Thanks for the reply. I tried both but still got the same result. Maybe you have other ideas? Thanks, Alex A. On Jun 24, 7:51 pm, Gustavo Henrique wrote: > try: > > from unicodedata import normalize > mytext = '%u05D9%u05D2' > newtext = normalize('NFKD',

Re: encoding question

2009-06-24 Thread Gustavo Henrique
try: from unicodedata import normalize mytext = '%u05D9%u05D2' newtext = normalize('NFKD', mytext).encode('ASCII','ignore') or: import sys reload(sys) sys.setdefaultencoding('latin-1') --~--~-~--~~~---~--~~ You received this message because you are subscribed

encoding question

2009-06-24 Thread knight
Hi, I have html page with inline editing. (I have text, that when I click on it, it changes to edit box, and I can change the text) I do it with some java scripts. (http://www.yvoschaap.com/index.php/ weblog/ajax_inline_instant_update_text_20/) The problem is that I should save the text that I