Re: [web2py] Re: special chars in view, utf8 issue ?!

2020-02-13 Thread António Ramos
my solution   .decode('utf8').encode('latin1')
just did it without thinking... dont know what i´m doing but it works...

  {{temp=db(db.apps.id>0).select(db.apps.icon,db.apps.
url,db.apps.bg,db.apps.title,orderby=db.apps.id)}}
  {{for x in temp:}}
  {{=XML({"url":x["url"],"icon":x["icon"],"title":x[
'title'].decode('utf8').encode('latin1'),"bg":x["bg"]}) }},
  {{pass}}

Em qua., 12 de fev. de 2020 às 13:19, Clemens <
clemens.odend...@claret-clover.de> escreveu:

> Hello Ramos,
>
> since I can't see your screenshot, I have to guess. But in German we also
> our special characters and I encode these by the following procedure:
>
> import re
>> import sys
>>
>> def convert_special_chars(label):
>> if sys.version_info[0]==2: # python 2.x
>> label = label.decode('utf-8')
>> label = cgi.escape(label)
>> label = label.encode('ascii', 'xmlcharrefreplace')
>>
>> return label
>>
>
> Have a try! Hope it helps!
>
> Best regards
> Clemens
>
>
> On Wednesday, February 12, 2020 at 12:12:41 PM UTC+1, Ramos wrote:
>>
>> Hello i cant understand how to solve this issue.
>> I have a record with portuguese characters
>> "Ações de cada um" that passing it to  the view results in a different
>> value.
>> How do i understand it to solve it ?
>>
>> [image: image.png]
>> This is the result in my view
>> My layout has  
>> and my view is just
>>
>> {{=a}}
>>
>> [image: image.png]
>> and this is my controller
>> # -*- coding: utf-8 -*-
>> def execdal():
>>
>> ret=[]
>> a=db(db.apps.id==1).select(db.apps.icon,db.apps.url,db.apps.bg
>> ,db.apps.title,orderby=db.apps.id).as_list()
>> return dict(a=a)
>>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/b63a8e8e-717a-41e7-b2fd-476dae50ebed%40googlegroups.com
> 
> .
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/CAEM0BxNkSBUm92np%3DPGj_6AUQ36s01xbSrBdGN8P%3Ddyn-aTpJg%40mail.gmail.com.


[web2py] Re: special chars in view, utf8 issue ?!

2020-02-12 Thread Clemens
Hello Ramos,

since I can't see your screenshot, I have to guess. But in German we also 
our special characters and I encode these by the following procedure:

import re
> import sys
>
> def convert_special_chars(label):
> if sys.version_info[0]==2: # python 2.x
> label = label.decode('utf-8')
> label = cgi.escape(label)
> label = label.encode('ascii', 'xmlcharrefreplace')
>
> return label
>

Have a try! Hope it helps!

Best regards
Clemens


On Wednesday, February 12, 2020 at 12:12:41 PM UTC+1, Ramos wrote:
>
> Hello i cant understand how to solve this issue.
> I have a record with portuguese characters 
> "Ações de cada um" that passing it to  the view results in a different 
> value.
> How do i understand it to solve it ?
>
> [image: image.png]
> This is the result in my view 
> My layout has  
> and my view is just 
>
> {{=a}}
>
> [image: image.png]
> and this is my controller
> # -*- coding: utf-8 -*-
> def execdal():
>
> ret=[]
> a=db(db.apps.id==1).select(db.apps.icon,db.apps.url,db.apps.bg
> ,db.apps.title,orderby=db.apps.id).as_list()
> return dict(a=a)
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/b63a8e8e-717a-41e7-b2fd-476dae50ebed%40googlegroups.com.