jmcclell / django-bootstrap-pagination

Django template tag for rendering Page objects as Bootstrap pagination HTML
MIT License
212 stars 83 forks source link

Unicode strings support #6

Closed manenko closed 11 years ago

manenko commented 12 years ago

Hello,

I tried to use i18n and non-ASCII symbols for _previouslabel, _nextlabel, etc. and got UnicodeEncodeError:

'ascii' codec can't encode characters in position 0-4: ordinal not in range(128) Exception Location: /skipped/bootstrap-pagination/templatetags/bootstrap_pagination.py in render, line 137

The problem is in code like this: previous_label = str(kwargs.get("previous_label", "←"))

I replace str with unicode and everything works fine.

jmcclell commented 12 years ago

What happens if you get rid of str() all together? I'm not sure any of those str() calls are necessary. I'm used to languages where the mindset is to enforce type safety before continuing on, but the Python way appears to be just to let it go and if it fails it fails. Removing the str() calls all together might make more sense.

manenko commented 12 years ago

They are not necessary and removing 'str' should fix unicode support.

jmcclell commented 12 years ago

Can you provide me with your template test case that is failing so I can make sure my fix solves your issue?

MarkDoggen commented 8 years ago

Could you push this fix to support unicode strings?