EDIT: I only realized that when I do not try to print to the console of this variable, it works. Why?
I ran into a problem with displaying a string label with utf characters. I installed locale env in the uwsgi ini file as follows:
env =LC_ALL=en_US.UTF-8
env =LANG=en_US.UTF-8
and in wsgi.py:
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
When I ran the application code:
print (locale.getlocale(), locale.getpreferredencoding())
print locale.getdefaultlocale()
print "option_value", option_value
label = force_text(option_label)
print 'label', label
conclusion:
(('en_US', 'UTF-8'), 'UTF-8')
('en_US', 'UTF-8')
option_value d
ERROR <stack trace>
print 'label', label
UnicodeEncodeError: 'ascii' codec can't encode character u'\u015b' in position 5: ordinal not in range(128)
The problem does not occur when I run the application through servers in a production environment. Django 1.6.5 Python 2.7.6 Ubuntu 14.04 uWSGI 2.0.5.1
source
share