#NEWLINE# @ formatter_for ( 'str' ) #NEWLINE# def format_value_text( val , encoding , colormap , quote = False , **_ ) : #NEWLINE# #INDENT# escapedval = val . replace ( '\\' , '\\\\' ) #NEWLINE# if quote : #NEWLINE# #INDENT# escapedval = escapedval . replace ( "'" , "''" ) #NEWLINE# #UNINDENT# escapedval = unicode_controlchars_re . sub ( _show_control_chars , escapedval ) #NEWLINE# bval = escapedval . encode ( encoding , 'backslashreplace' ) #NEWLINE# if quote : #NEWLINE# #INDENT# bval = ( "'%s'" % bval ) #NEWLINE# #UNINDENT# displaywidth = wcwidth . wcswidth ( bval . decode ( encoding ) ) #NEWLINE# return color_text ( bval , colormap , encoding )