<commit_before>module Riddle
  class Client
    # This class takes care of the translation of ints, strings and arrays to
    # the format required by the Sphinx service.
    class Message
      def initialize
        @message = ""
        @size_method = @message.respond_to?(:bytesize) ? :bytesize : :length
      end
      
      # Append raw data (only use if you know what you're doing)
      def append(*args)
        return if args.length == 0
        
        args.each { |arg| @message << arg }
      end
      
      # Append a string's length, then the string itself
      def append_string(str)
        @message << [str.send(@size_method)].pack('N') + str
      end
      
      # Append an integer
      def append_int(int)
        @message << [int].pack('N')
      end
      
      def append_64bit_int(int)
        @message << [int >> 32, int & 0xFFFFFFFF].pack('NN')
      end
      
      # Append a float
      def append_float(float)
        @message << [float].pack('f').unpack('L*').pack("N")<commit_msg>Another Ruby 1.9 fix, for searches with unicode characters<commit_after>module Riddle
  class Client
    # This class takes care of the translation of ints, strings and arrays to
    # the format required by the Sphinx service.
    class Message
      def initialize
        @message = ""
        @size_method = @message.respond_to?(:bytesize) ? :bytesize : :length
      end
      
      # Append raw data (only use if you know what you're doing)
      def append(*args)
        args.each { |arg| @message << arg }
      end
      
      # Append a string's length, then the string itself
      def append_string(str)
        string = string.respond_to?(:force_encoding) ?
          str.force_encoding('ASCII-8BIT') : str
        
        @message << [string.send(@size_method)].pack('N') + string
      end
      
      # Append an integer
      def append_int(int)
        @message << [int].pack('N')
      end
      
      def append_64bit_int(int)
        @message << [int >> 32, int & 0xFFFFFFFF].pack('NN')
      end
      
      # Append a float
      def append_float(float)
        @message << [float].pack('f').unpack('L*').pack("N")
{'fraction_non_alphanumeric': 0.11116236162361623, 'fraction_numerical': 0.006457564575645757, 'mean_word_length': 2.1074498567335245, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1526651', 'n_tokens_mistral': 650, 'n_tokens_neox': 636, 'n_words': 193}