를 사용하려면 :스핑크스'라틴어-1 '코덱은 UTF-8 내 체류 지수에 삽입하려고 다음과 같은 오류가
'latin-1' codec can't encode character u'\u2019' in position 126: ordinal not in range(256)
이 사용되어야한다 UTF-8 라틴 -1이 아닙니다. conf 파일에 다음과 같이 지정했습니다 :
index my_index
{
type = rt
path = /path/my_index
rt_field = content
charset_type = utf-8
}
utf-8 인 데이터베이스에서 삽입 할 값을 선택합니다. 원시 API (API 없음)를 사용하여 파이썬에서 삽입하고 있습니다.
cursor_sphinx.execute("replace into my_index (id, content) values (%s,%s)", (id, content))
어떻게 피할 수 있습니까?
스핑크스 포럼에서 언급했듯이 스핑크스는 아닙니다. https://www.google.com/search?q=codec+can't+encode+character+++in+position는 이것이 파이썬 문제라고 제안합니다. AFAIK 파이썬에는 사용해야하는 특정 유니 코드 문자열 유형 u "..."가 있습니다. – barryhunter
python 태그가 추가되었습니다. – barryhunter
'cursor_sphinx' 객체를 어떻게 만들었습니까? 연결시 데이터베이스 인코딩을 지정 했습니까? (데이터베이스에 설정된 올바른 인코딩을 사용하면 전혀 문제가되지 않을 수도 있습니다.) – geoffspear