#NEWLINE# def serialize_as_length_prefixed_string( value , output_buffer ) : #NEWLINE# #INDENT# 'Serializes the str or unicode value using the length-prefixed format special to Scalyr.\n\n    This is a bit more efficient since the value does not need to be blackslash or quote escaped.\n\n    @param value: The string value to serialize.\n    @param output_buffer: The buffer to serialize the string to.\n\n    @type value: str or unicode\n    @type output_buffer: StringIO\n    ' #NEWLINE# output_buffer . write ( '`s' ) #NEWLINE# if ( type ( value ) is unicode ) : #NEWLINE# #INDENT# to_serialize = value . encode ( 'utf-8' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# to_serialize = value #NEWLINE# #UNINDENT# output_buffer . write ( struct . pack ( '>i' , len ( to_serialize ) ) ) #NEWLINE# output_buffer . write ( to_serialize )