This is corrected question. The first time it was submitted on 2011.11.22 nd.
I am not able to save string with special characters, such as θæŋ after re.search(string). #saving to the model Textfield does not work. Instead of θæŋkfəli, i am getting shown "\xce\xb8\xc3\xa6\xc5\x8bkf\xc9\x99li" in Admin page. Is it error in re.search? Should i use special parameters during model field saving or in Admin entry displaying? [code] lines='title="Listen to audio" /></a><span class="pr">/<span class="unicode">ˈ</span>θæŋkfəli/</span> <span class="fl">adverb' #the string which i wan to save exactly as it is, Django saves it correctly liness=smart_str(lines, encoding='utf-8', strings_only=False, errors='replace') # saves correctly, i mean in Admin page in Textfield i can read "θæŋ" characters linesu=smart_unicode(lines, encoding='utf-8', strings_only=False, errors='replace') # saves correctly[/code] ## ***AFTER TRYING TO SEARCH part of unicode string linesu for θæŋkfəli Django does not save it in needed special characters. Instead of θæŋkfəli, i am getting "\xce\xb8\xc3\xa6\xc5\x8bkf \xc9\x99li" or "\u03b8\xe6\u014bkf\u0259li", Below there are shown 3 trials to get correct text and also described error in searching liness= bytes string*** [code] stryc=re.compile('<span\s*class=\"pr\">\s*/\s*<span \s*class="unicode\">(?P. <Pronun>.*)<span\s*class=\"fl\">', re.DOTALL) #\s+/\s+<span class=\"unicode\">\s+[\\a-zA-Z0-9\s] +/\s+</span> ' strys=re.search(stryc, linesu)[/code] 1) [code]Pronun=stryWordcs.groups('Pronun') a=Pronunciation(field=Pronun) a.save() # Pronun= "θæŋkfəli" [/code] #saving to the model Textfield does not work. Instead of θæŋkfəli, i am getting "\u03b8\xe6\u014bkf\u0259li" 2) [code]Pronun=stryWordcs.groups('Pronun') Pronun=smart_str(Pronun, encoding='utf-8', strings_only=False, errors='replace') a=Pronunciation(field=Pronun) a.save()[/code] #saving to the model Textfield does not work. Instead of θæŋkfəli, i am getting \xce\xb8\xc3\xa6\xc5\x8bkf\xc9\x99li" 3) [code]Pronun=stryWordcs.groups('Pronun') Pronun=Pronun.encode() a=Pronunciation(field=Pronun) a.save() [/code] #saving to the model Textfield does not work. Instead of θæŋkfəli, i am getting \xce\xb8\xc3\xa6\xc5\x8bkf\xc9\x99li" ## *** # 4) if i try to search in lines or liness i am not able to find θæŋkfəli due coding error about special character ˈ (small stick on top =\xcb\x88 = \u02c8) . Thus i make search on unicode string. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.