mirror of
https://github.com/viq/NewsBlur.git
synced 2025-08-05 16:49:45 +00:00
Attempting to corral APNS push notification max sizes due to chinese unicode characters being 3 bytes.
This commit is contained in:
parent
3cd09d0f7b
commit
0a49e1b073
1 changed files with 5 additions and 3 deletions
|
@ -272,11 +272,13 @@ def linkify(*args, **kwargs):
|
||||||
return xhtml_unescape_tornado(linkify_tornado(*args, **kwargs))
|
return xhtml_unescape_tornado(linkify_tornado(*args, **kwargs))
|
||||||
|
|
||||||
def truncate_chars(value, max_length):
|
def truncate_chars(value, max_length):
|
||||||
if len(value) <= max_length:
|
if isinstance(value, unicode):
|
||||||
|
uvalue = value.encode('utf-8')
|
||||||
|
if len(uvalue) <= max_length:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
truncd_val = value[:max_length]
|
truncd_val = uvalue[:max_length]
|
||||||
if value[max_length] != " ":
|
if uvalue[max_length] != " ":
|
||||||
rightmost_space = truncd_val.rfind(" ")
|
rightmost_space = truncd_val.rfind(" ")
|
||||||
if rightmost_space != -1:
|
if rightmost_space != -1:
|
||||||
truncd_val = truncd_val[:rightmost_space]
|
truncd_val = truncd_val[:rightmost_space]
|
||||||
|
|
Loading…
Add table
Reference in a new issue