python - Sphinx 'latin-1' codec can't encode character' - want to use utf-8 -


i following error trying insert rt index:

'latin-1' codec can't encode character u'\u2019' in position 126: ordinal not in range(256) 

it should using utf-8, not latin-1. in conf file have specified:

index my_index {         type = rt         path = /path/my_index         rt_field = content          charset_type = utf-8 } 

i selecting values insertion database utf-8. inserting python, using raw sql (no api):

cursor_sphinx.execute("replace my_index (id, content ) values (%s,%s)", (id, content)) 

how can avoid this?

well, inserting content.encode("utf-8") did trick, although don't see why necessary when first database utf-8 , .py file specifies # coding=utf-8


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -