File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -131,11 +131,12 @@ def viml_keys(obj):
131131 return obj .keys ()
132132
133133def viml_len (obj ):
134- try :
135- if type (obj ) is str :
136- return len (obj .encode ('utf-8' , 'ignore' ))
137- except UnicodeDecodeError :
138- pass
134+ if type (obj ) is str :
135+ if sys .version_info < (3 , 0 ):
136+ b = bytes (obj )
137+ else :
138+ b = bytes (obj , 'utf8' )
139+ return len (b )
139140 return len (obj )
140141
141142def viml_printf (* args ):
Original file line number Diff line number Diff line change @@ -131,11 +131,12 @@ def viml_keys(obj):
131131 return obj .keys ()
132132
133133def viml_len (obj ):
134- try :
135- if type (obj ) is str :
136- return len (obj .encode ('utf-8' , 'ignore' ))
137- except UnicodeDecodeError :
138- pass
134+ if type (obj ) is str :
135+ if sys .version_info < (3 , 0 ):
136+ b = bytes (obj )
137+ else :
138+ b = bytes (obj , 'utf8' )
139+ return len (b )
139140 return len (obj )
140141
141142def viml_printf (* args ):
You can’t perform that action at this time.
0 commit comments