Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support unicode objects #2

Closed
emosenkis opened this issue Aug 16, 2013 · 4 comments
Closed

Support unicode objects #2

emosenkis opened this issue Aug 16, 2013 · 4 comments

Comments

@emosenkis
Copy link

natsort silently fails to do anything useful with unicode strings:

>>> natsort.natsort_key('AAAS 5A')
('AAAS ', 5.0, 'A')
>>> natsort.natsort_key(u'AAAS 5A')
(u'AAAS 5A',)
# should be (u'AAAS ', 5.0, u'A')
@emosenkis
Copy link
Author

This seems to be caused by explicitly checking for str:
https://github.com/SethMMorton/natsort/blob/master/natsort/natsort.py#L212

The re module supports unicode, so it might just work if str is replaced with basestring. If it were me, I would probably raise an exception if natsort_key was called on a non-string instead of just returning a tuple containing it.

@SethMMorton
Copy link
Owner

I will take a look at this. I don't want to raise an exception for any non-string since it is designed to handle ints and floats as well. I'll make sure it supports unicode as well.

@SethMMorton
Copy link
Owner

OK. I added unicode support. I made it more explicit in the docs that natsort will accept ints and floats as well.

I will close this issue if you find that this is fixed. If you used pypi, this version is uploaded there.

@emosenkis
Copy link
Author

Works for me. Thanks! I've never gotten such a quick response before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants