Find it.

titles = "'"+titles.replace('|', "','")+"'"
with:
SCRIPT(" ... jQuery.prettyPhoto.open(**images=%(images)s,titles=[%(**
titles)s]);})" % dict(images=images, titles=titles), _language='javascript')

works! Tested on Firefox and Safari.

Though I've failed to find any references on this (there must be), the
problem seems to be Python string formatting. It seems that  when the value
of a dict is a list (haven't tested for other types such as dict and
tuple?), Python uses repr instead of str, so we end-up with a
representation! This does not happen if titles is a string. Note I'm using
Python 2.5.

Miguel



On Tue, Mar 27, 2012 at 6:46 PM, Derek <sp1d...@gmail.com> wrote:

> Check the meta tag - if it's UTF-8, that's most likely the issue.  You can
> try ISO-8859-1 and see if that works for you.
>
>
> On Tuesday, March 27, 2012 10:41:53 AM UTC-7, Derek wrote:
>>
>> What's the character set in your browser?
>>
>> On Tuesday, March 27, 2012 9:13:14 AM UTC-7, miguel wrote:
>>>
>>> This is not strictly a web2py issue. Though it is a problem that apps
>>> dealing with some character sets must deal with.
>>> I confess that the source of my problem is that I have been delaying
>>> reading-up on encoding and decoding far too long. But I'm pressed for time
>>> and I'm sure that this is a simple issue to many of you.
>>>
>>> Here's is it (slightly embarrassed):
>>>
>>> It works if I hardcode a string in a script helper:
>>>
>>> SCRIPT(" ... jQuery.prettyPhoto.open(**images=%(images)s,titles=['**olá',
>>> 'olé']);})" % dict(...images=images), _language='javascript')
>>>
>>> It also works if (getting titles from the db, where it is stored as
>>> "'olá','olé'" - note single quotes included):
>>>
>>> SCRIPT(" ... 
>>> jQuery.prettyPhoto.open(**images=%(images)s,titles=[%(**titles)]);})"
>>> % dict(images=images, titles=titles), _language='javascript')
>>>
>>> However, if I try to parse from the db (where titles is stored as
>>> "olá|olé", such as:
>>> titles = [title.strip() for title in titles.split('|')]
>>>
>>> The jQuery string is adequately adjusted to receive a list:
>>> SCRIPT(" ... jQuery.prettyPhoto.open(**images=%(images)s,titles=%(**
>>> titles));})" % dict(images=images, titles=titles),
>>> _language='javascript')
>>>
>>> All works but when rendered by the browser I do not get: Olá  instead I
>>> get: olá
>>> The same for Olé and olé
>>>
>>> My goal is to have a user supplied string, such as: olá|olé
>>>
>>> BTW this is a prettyPhoto widget I developed for plugin_wiki, which is
>>> awesome :-)
>>>
>>> Txs for the help,
>>> Miguel
>>>
>>

Reply via email to