More unicode conversions on the client

This commit is contained in:
Strahinja Val Markovic 2014-01-13 10:00:05 -08:00
parent b3a77e9464
commit e9b3916862
2 changed files with 9 additions and 6 deletions

View File

@ -39,10 +39,12 @@ def SanitizeQuery( query ):
return query.strip()
def ToUtf8IfNeeded( string_or_unicode ):
if isinstance( string_or_unicode, unicode ):
return string_or_unicode.encode( 'utf8' )
return string_or_unicode
def ToUtf8IfNeeded( value ):
if isinstance( value, unicode ):
return value.encode( 'utf8' )
if isinstance( value, str ):
return value
return str( value )
def PathToTempDir():

View File

@ -20,6 +20,7 @@
import vim
import os
import json
from ycm.utils import ToUtf8IfNeeded
def CurrentLineAndColumn():
"""Returns the 0-based current line and 0-based current column."""
@ -190,7 +191,7 @@ def ConvertDiagnosticsToQfList( diagnostics ):
'bufnr' : GetBufferNumberForFilename( location[ 'filepath' ] ),
'lnum' : location[ 'line_num' ] + 1,
'col' : location[ 'column_num' ] + 1,
'text' : diagnostic[ 'text' ],
'text' : ToUtf8IfNeeded( diagnostic[ 'text' ] ),
'type' : diagnostic[ 'kind' ],
'valid' : 1
}
@ -311,7 +312,7 @@ def EchoText( text, log_as_message = True ):
# Echos text but truncates it so that it all fits on one line
def EchoTextVimWidth( text ):
vim_width = GetIntValue( '&columns' )
truncated_text = text.encode('utf-8')[ : int( vim_width * 0.9 ) ]
truncated_text = ToUtf8IfNeeded( text )[ : int( vim_width * 0.9 ) ]
truncated_text.replace( '\n', ' ' )
old_ruler = GetIntValue( '&ruler' )