Opened 18 years ago
Closed 18 years ago
#3631 closed (wontfix)
the built-in truncatewords filter can't deal with chinese
Reported by: | anonymous | Owned by: | Jacob |
---|---|---|---|
Component: | Uncategorized | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
i've tried to use the built-in the built-in truncatewords filter,
but it seems that it can not recognize Chinese characters.
As well as the wordcount filter has the same problem too.
No matter what the str is, the wordcount filter will return 1.
BTW, the str variable is utf-8 encoded, and i can use the len() method to get the correct length.
Thanks..
Note:
See TracTickets
for help on using tickets.
I have zero knowledge of Chinese, so I ask: does Chinese use normal spaces in between "words"? The filter uses
len(value.split())
to count the words, and if the.split()
isn't working then the problem is obvious.Since that is all the built-in filter does, I don't think there's anything we can do to make it work for special language cases. Better to write your own filter that works (and perhaps submit it as an enhancement)