Note that if you are using mySQL that might be because mySQL, if not set to use utf-8 uses a latin encoding. You have to manually tell MySQL to use utf-8, and even then you will still have problems with it...mySQL sux
http://lobstertech.com/2009/jun/07/python_unicode_tutorial/ On Apr 12, 6:59 pm, mdipierro <[email protected]> wrote: > I have not looked into this yet. It should beutf8in both cases. > > On Apr 12, 8:39 pm, Tito Garrido <[email protected]> wrote: > > > > > Is it expected? > > > On Sun, Apr 11, 2010 at 11:54 AM, Tito Garrido <[email protected]>wrote: > > > > I could test it on Shell, not sure why it's happening: > > > > In[0]: > > > > p=db(db.paciente.id>0).select()[1].as_dict() > > > > Out[0]: > > > In[1]: > > > > p > > > > Out[1]: > > > > *{'bairro': 'Gra\xc3\xa7a',* 'telefone_residencial': '', 'numero': '492', > > > 'mae': '', 'celular': '', 'pai': '', 'data': '2009-10-20', 'id': 2, > > > 'telefone_comercial': '', 'nome': 'Tito \xc3\xa1 \xc3\xa9', 'emissor': > > > 'SSP-BA', 'cidade': 'Salvador', 'nascimento': '2009-10-20', 'rg': > > > '09376709', 'endereco': 'Rua 8', 'estado': 'Bahia', 'email': > > > '[email protected]'} > > > > In[2]: > > > > p=db(db.paciente.id>0).select().json() > > > > Out[2]: > > > In[3]: > > > > p > > > > Out[3]: > > > > '[{"telefone_comercial": null, "data": "2009-10-20", "bairro": "", > > > "nascimento": "2009-10-20", "emissor": "", "cidade": "", "nome": "Tito > > > Garrido Ogando", "telefone_residencial": null, "numero": "", "email": > > > null, "rg": "", "mae": "", "celular": null, "endereco": "", "pai": "", > > > "estado": "", "id": 1}, {"telefone_comercial": "", "data": "2009-10-20", > > > *"bairro": "Gra\\u00e7a"*, "nascimento": "2009-10-20", "emissor": "SS", > > > "cidade": "Salvador", "nome": "Tito \\u00e1 \\u00e9", > > > "telefone_residencial": "", "numero": "492", "email": "[email protected]", > > > "rg": "0709", "mae": "", "celular": "", "endereco": "Rua 8", "pai": "", > > > "estado": "Bahia", "id": 2}, {"telefone_comercial": null, "data": > > > "2009-10-20", "bairro": "", "nascimento": "2009-10-20", "emissor": "", > > > "cidade": "", "nome": "Garrido Tito", "telefone_residencial": null, > > > "numero": "", "email": null, "rg": "", "mae": "", "celular": null, > > > "endereco": "", "pai": "", "estado": "", "id": 3}, {"telefone_comercial": > > > null, "data": "2010-03-01", "bairro": "", "nascimento": null, "emissor": > > > "", "cidade": "", "nome": "", "telefone_residencial": null, "numero": "", > > > "email": null, "rg": "", "mae": "", "celular": null, "endereco": "", > > > "pai": "", "estado": "", "id": 4}, {"telefone_comercial": null, "data": > > > "2010-03-02", "bairro": "G", "nascimento": null, "emissor": "SSP-BA", > > > "cidade": "S", "nome": "Titoooo", "telefone_residencial": null, "numero": > > > "", "email": null, "rg": "09379", "mae": "", "celular": null, "endereco": > > > "R", "pai": "", "estado": "B", "id": 5}]' > > > > I've increased the font of aUTF-8entry (it's should be "Graça") > > > > On Sun, Apr 11, 2010 at 11:47 AM, Tito Garrido > > > <[email protected]>wrote: > > > >> In fact looks like it loses theUTF-8enconding when I print it or convert > > >> it to string... > > > >> Is there a way to re encode it? > > > >> Regards, > > > >> tito > > > >> On Sun, Apr 11, 2010 at 11:35 AM, mdipierro > > >> <[email protected]>wrote: > > > >>> Are you tell me that > > > >>> items=db(db.mytable.id>0).select(limitby=(0,1)) > > >>> print items[0].as_dict() > > >>> for item in items: print item.as_dict() > > > >>> produce two different outputs? It cannot be. > > > >>> Massimo > > > >>> On Apr 11, 9:00 am, Tito Garrido <[email protected]> wrote: > > >>> > I can get it asUTF-8if I execute: > > >>> > test=db(db.mytable.id>0).select()[0].as_dict() > > > >>> > return test > > > >>> > Not sure why it's not encoding on the former situation. > > > >>> > How could I convert it manually? > > > >>> > Thanks! > > > >>> > On Sun, Apr 11, 2010 at 2:15 AM, mdipierro <[email protected]> > > >>> wrote: > > >>> > > I am not sure the issue is web2py here. It may be 1) the encoding in > > >>> > > the db should beutf8and it is not, 2) the data has been stored > > >>> > > incorrecly. web2py does not convert data toUTF8when extracting from > > >>> > > DB but when inserting only. > > > >>> > > On Apr 10, 11:17 pm, Tito Garrido <[email protected]> wrote: > > >>> > > > Hi Folks, > > > >>> > > > I'm not sure why but when I'm using as_dict function in a row > > >>> element > > >>> > > it's > > >>> > > > not returningUTF-8characters an example: > > > >>> > > > db.define_table('evento', > > >>> > > > SQLField('dono','reference > > >>> auth_user',writable=False,readable=False), > > >>> > > > SQLField('paciente', 'reference paciente', label='Paciente*'), > > >>> > > > SQLField('titulo', 'string', length=255 > > >>> > > ,default='',label='Assunto*'), > > >>> > > > SQLField('data','date',default=request.now,readable=False), > > >>> > > > SQLField('horario','time',readable=False), > > >>> > > > SQLField('duracao','integer'), > > >>> > > > SQLField('status', 'string', length=255 ,default='Marcado'), > > >>> > > > SQLField('comentario', 'text',default=''), > > >>> > > > SQLField('criado_por','reference > > >>> > > > auth_user',writable=False,readable=False)) > > > >>> > > > eventos=db((db.evento.data.day()==data.day)& > > >>> > > > (db.evento.data.month()==data.month)& > > >>> > > > (db.evento.data.year()==data.year)& > > > >>> (db.evento.dono==dono_id)).select(orderby=db.evento.horario) > > > >>> > > > for evento in eventos: > > >>> > > > *eventos_as_list.append(evento.as_dict())* > > >>> > > > #some other operations > > > >>> > > > return eventos_as_list > > > >>> > > > Those elements inside this list "eventos_as_list" are not encoded > > >>> as > > >>> > >utf-8, > > >>> > > > it shows something like: > > >>> > > > *{'status': 'Marcado', 'paciente': 1, 'id': 11, 'horario': > > >>> '08:00:00', > > >>> > > > 'criado_por': 2, 'dono': 2, 'titulo': 'Criado pelo modal', 'data': > > >>> > > > '2010-03-20', 'comentario': 'Descri\xc3\xa7ao \xc3\xa1 > > >>> > > \xc3\xa9\r\n\r\ncom > > >>> > > > mais uma linha\r\n\r\natt'}* > > > >>> > > > Not sure if it's happening because I'm appending it to a list... > > >>> > > > is > > >>> there > > >>> > > a > > >>> > > > way to solve it? > > > >>> > > > Regards, > > > >>> > > > Tito > > > >>> > > > -- > > > >>> > > > Linux User #387870 > > >>> > > > .........____ > > >>> > > > .... _/_õ|__| > > >>> > > > ..º[ .-.___.-._| . . . . > > >>> > > > .__( o)__( o).:_______ > > > >>> > > -- > > >>> > > To unsubscribe, reply using "remove me" as the subject. > > > >>> > -- > > > >>> > Linux User #387870 > > >>> > .........____ > > >>> > .... _/_õ|__| > > >>> > ..º[ .-.___.-._| . . . . > > >>> > .__( o)__( o).:_______ > > > >> -- > > > >> Linux User #387870 > > >> .........____ > > >> .... _/_õ|__| > > >> ..º[ .-.___.-._| . . . . > > >> .__( o)__( o).:_______ > > > > -- > > > > Linux User #387870 > > > .........____ > > > .... _/_õ|__| > > > ..º[ .-.___.-._| . . . . > > > .__( o)__( o).:_______ > > > -- > > > Linux User #387870 > > .........____ > > .... _/_õ|__| > > ..º[ .-.___.-._| . . . . > > .__( o)__( o).:_______

