Thank you very much. Worked like a charm! Regards, -Megha
On Thu, Jun 23, 2011 at 10:07 PM, Anand Chitipothu <[email protected]>wrote: > 2011/6/23 megha <[email protected]>: > > Hi, > > > > I'm gathering someone may have solved this problem before. > > Unfortunately, I didn't find anything that worked for me via searches. > > > > Here's what I'm trying to do: > > I have a html form - uses tinyMCE for text areas, that I type into in > > Kannada. Once I submit the form, I do not save any of this text to a > > db/file but just put it back in the response with a dictionary object > > (one for each text area) and expect that html with charset = utf-8 > > will just understand things right. However, I seem to have over > > simplified this in my head. > > > > What's happening: > > I notice that the string that comes through in for eg: these > > characters : ಹೇ is u'\\u0cb9\\u0cc7' into my req = web.input(). If I > > try to keep this as it is and send it back in a dictionary in the > > response, Javascript considers the dictionary corrupted and throws me > > an error. I see this set to the dictionary key in the equivalent JS > > dict - u'\u0cb9\u0cc7'. > > > > I assumed that this could be a problem python should solve for me and > > I tried u'\\u0cb9\\u0cc7'.decode('utf-8').encode('utf-8') , unicode > > (resp_str,'utf-8') and such. All the encoding is yielding ascii > > characters and junk on the web page, with no JS errors, however. > > > > I'm however, no more sure which part of this req-resp is really > > causing a problem. > > > > Anyone done something like this before? Will be grateful to have any > > tips/ pointers as well. > > Unicode strings are represented differently in Python and Javascript. > So passing Python dict to javascript won't work correctly. You need to > convert it to JSON and put in the html page. > > You can convert a python dict to JSON using: > > import simplejson > > d = {"name": u"\u0C05"} > json = simplejson.dumps(d) > > Anand > > -- > You received this message because you are subscribed to the Google Groups > "web.py" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/webpy?hl=en. > > -- You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/webpy?hl=en.
