#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 Changed 11 years ago by andar
comment:2 follow-up: ↓ 3 Changed 11 years ago by 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') ...
comment:3 in reply to: ↑ 2 Changed 11 years ago by andar
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 Changed 11 years ago by Cas
- Resolution set to fixed
- Status changed from new to closed
git master: d5e340354e, 60f196ff93
comment:5 Changed 8 years ago by Cas
- Milestone changed from 2.0.x to 2.0
Why are lambdas being used in this function? Can't encodings just be a list of tuples?