Hello. Trying to implement a function in PL / Python (PostgreSQL 9.5, Python 2.7). So I just can not work together with Cyrillic functions. Below is the actual code:
create or replace function pytest() returns varchar as $$ import os, pymorphy2 morph = pymorphy2.MorphAnalyzer() word = morph.parse(u'смартфоны')[0]; #return word.word # Возвращает ñð¼ð°ñññð¾ð½ñ #return u'смартфоны' # Возвращает ÑмаÑÑÑÐ¾Ð½Ñ return 'смартфоны' # Возвращает смартфоны $$ language plpython2u; At the same time, in repr (). Decode ('unicode_escape') was wrapped, and manually encoded / decoded. Anyway, kryakozyabry, the truth is different. Moreover, if you drive a word in Cyrillic into a variable, then all the rules are displayed. Can anyone come across? The database I have is in UTF8 (en_US.UTF-8). What could be the problem, I'll never know. Help me please.
sys.setdefaultencoding('utf-8')? - jfsreturn u'смартфоны'? If it works, fix pymorphy2 (outside pl / python). If it doesn’t work, remove pymorphy2 from the example. 2- naturally remove setdefaultencoding. This design can hide problems. 3- do not userepr().decode('unicode_escape'). The crawlers indicate that the text has been recoded using incompatible encoding. - jfssetdefaultencodingcall should be removed regardless of your current problem. Although its absence can help in debugging both this and other problems with the text (and vice versa: its presence can hide other possible problems - do you not think that you have only one bug in the program?). - jfs