On Friday, March 6, 2020 at 6:26:06 AM UTC-8, Velu Narasimman wrote:
>
> I am getting some input from user and that input has some non ASCII 
> characters. The user is using some Spanish characters like 'ó', 'é' etc., 
> when I save his input to database I face UnicodeEncodeError.
>
> Traceback (most recent call last):
>   File 
> "/usr/local/lib/python2.7/dist-packages/Trac-1.0.15-py2.7.egg/trac/web/main.py"
> , line 624, in _dispatch_request
>     dispatcher.dispatch(req)
>   File 
> "/usr/local/lib/python2.7/dist-packages/Trac-1.0.15-py2.7.egg/trac/web/main.py"
> , line 302, in dispatch
>     resp = chosen_handler.process_request(req)
>   File 
> "/usr/local/lib/python2.7/dist-packages/timesheet-1.0-py2.7.egg/timesheet/form_ui.py"
> , line 1173, in process_request
>     timeEntry.create_weekly(project_env,timesheet_result,project)
>   File 
> "/usr/local/lib/python2.7/dist-packages/timesheet-1.0-py2.7.egg/timesheet/model.py"
> , line 289, in create_weekly
>     str(detail['comments']).replace('"', '').replace("'", '').replace('\n'
> , ' ').replace('\r', ' '),\
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in 
> position 37: ordinal not in range(128)
>
> If there is any support page for unicode usage in Trac it would be better. 
> Please help me how I can get some randome language characters input like 
> this and store it to db without issues.
>

Try:

str(detail['comments']) -> detail['comments'] 

Or 

str(detail['comments']) -> unicode(detail['comments'])

- Ryan

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/trac-users/3d41cf41-ce2a-45ab-b06b-8f543e4a0719%40googlegroups.com.

Reply via email to