#2225 closed patch (Fixed)
Change common.decode_string to actually decode (return unicode)
Reported by: | Bro | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 2.0.0 |
Component: | Unknown | Version: | master |
Keywords: | Cc: |
Description
This patch changes the decode_string so that it tries to decode the input string with different encodings, and returns the decoded output as unicode.
https://github.com/bendikro/deluge/tree/master-decode-string
Previous calls to decode_string are replaced with common.utf8_encoded
Change History (6)
comment:1 by , 12 years ago
follow-up: 3 comment:2 by , 12 years ago
In the first commit it was a list of tuples, but as gazpachoking commented here it's unnecessary to call chardet.detect when it's not needed.
An alternative would be a method that returns the encoding based on the input e.g:
def get_encoding(index): if index == 0: return ("utf8", 'strict') elif index == 1: return ("iso-8859-1", 'strict') ...
comment:3 by , 12 years ago
Replying to bro:
In the first commit it was a list of tuples, but as gazpachoking commented here it's unnecessary to call chardet.detect when it's not needed.
An alternative would be a method that returns the encoding based on the input e.g:
def get_encoding(index): if index == 0: return ("utf8", 'strict') elif index == 1: return ("iso-8859-1", 'strict') ...
Oh, I see.. The intention is to only run chardet when absolutely necessary.
Yea, there are alternatives, but using lambda works just fine in this circumstance.
comment:4 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
git master: d5e340354e, 60f196ff93
comment:5 by , 9 years ago
Milestone: | 2.0.x → 2.0 |
---|
Why are lambdas being used in this function? Can't encodings just be a list of tuples?