Solved the problem

I posted on stackoverflow.com

http://stackoverflow.com/questions/34596573/javascript-string-encoding-on-client

vote up or correct if it is not ok


On Wednesday, January 20, 2016 at 3:41:13 PM UTC+1, Richard wrote:
>
> You need XML() web2py helper when you pass python string or generate js 
> code from python you need it... 
>
> In the view :
>
> {{=XML(python_var_containing_text_or_js_code}}
>
> Richard
>
> On Wed, Jan 20, 2016 at 4:52 AM, Yebach <vid....@gmail.com <javascript:>> 
> wrote:
>
>> In this case I get the list of string 
>>
>> users = [u'Ga\u0161peri\u010d', u'GovednikK', u'Jam\u0161ek', 
>> u'Jurejev\u010di\u010d', u'Kati\u0107', u'Kostelec', u'Ko\u0161ele', 
>> u'Male\u0161i\u010d', u'Muhi\u010d', u'Re\u017eek', u'Sitar', 
>> u'Toma\u017ei\u010d', u'Viktorovski', u'Vuk\u0161ini\u010dD', 
>> u'\u010cerni\u010d', u'\u017defran'];
>> And there is a JS error Uncaught SyntaxError: Unexpected string
>>
>>
>>
>>
>> On Monday, January 4, 2016 at 6:37:13 PM UTC+1, Richard wrote:
>>>
>>> From js directly? I not really good with js but I guess there is 
>>> encoding too... From web2py you can't since everything use byte (str('byte 
>>> string')) and not unicode (u'your properly encoded string')... So if you 
>>> pass data from web2py what I showed you is the way of doing it...
>>>
>>> Richard
>>>
>>> On Mon, Jan 4, 2016 at 11:59 AM, Yebach <vid....@gmail.com> wrote:
>>>
>>>> Ok, but I would like to already see the right endocing when I get data 
>>>> from server database?
>>>>
>>>> On Monday, January 4, 2016 at 5:39:32 PM UTC+1, Richard wrote:
>>>>>
>>>>> When passing data from python to javascript I guess you will need to 
>>>>> use unicode or decode 
>>>>>
>>>>> try 
>>>>>
>>>>> javascritp_string_var = s.decode('utf8')
>>>>>
>>>>> Or
>>>>>
>>>>> javascritp_string_var = unicode(s, 'utf8')
>>>>>
>>>>> Richard
>>>>>
>>>>>
>>>>> On Mon, Jan 4, 2016 at 11:34 AM, Yebach <vid....@gmail.com> wrote:
>>>>>
>>>>>> Hello
>>>>>>
>>>>>> I have the following scenario. 
>>>>>>
>>>>>> Database is PostgreSQL, encoding set to UTF-8
>>>>>>
>>>>>> When I read data from database with web2py I get a string reading in 
>>>>>> type of *Bolni\xc4\x8dar* where it was suppose to be *Bolničar*. 
>>>>>>
>>>>>> Now, when i use web2py to present data in my view is all fine (so I 
>>>>>> can see *Bolničar*), but when i use Java Script or anything else to 
>>>>>> present data I get weird behavior, where ščžć is not presented.
>>>>>> I would like that  my reading from db would be Bolničar from 
>>>>>> beginning so I have no more hassle later.
>>>>>>
>>>>>> also the data in my database is *Bolničar*.
>>>>>>
>>>>>> I do all the db inserts with web2py and they are all ok. Looks like 
>>>>>> only reading is kind of "wrong"
>>>>>>
>>>>>> Any suggestions?
>>>>>> Thank you
>>>>>>
>>>>>> -- 
>>>>>> 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+un...@googlegroups.com.
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>> -- 
>>>> 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+un...@googlegroups.com.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> -- 
>> 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+un...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to