Opened 9 years ago

Closed 8 years ago

#3631 closed (wontfix)

the built-in truncatewords filter can't deal with chinese

Reported by: anonymous Owned by: jacob
Component: Uncategorized Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

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..

Change History (1)

comment:1 Changed 8 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

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)

Note: See TracTickets for help on using tickets.
Back to Top