>>> message = "SOS"
    >>> _encode_to_binary_string(message, on='1', off='0')
    '101010001110111011100010101'

    >>> message = " SOS"
    >>> _encode_to_binary_string(message, on='1', off='0')
    '0000000101010001110111011100010101'
11871
def _encode_to_binary_string(message, on, off):
    
    def to_string(i, s):
        if i == 0 and s == off:
            return off * 4
        return s
    return ''.join(to_string(i, s) for i, s in enumerate(_encode_binary(message, on=on, off=off)))
1058634
public static String encode(String message, int offset, boolean isEnocdeNumber) {
		final int len = message.length();
		final char[] chars = new char[len];

		for (int i = 0; i < len; i++) {
			chars[i] = encodeChar(message.charAt(i), offset, isEnocdeNumber);
		}
		return new String(chars);
	}
616897
private void logBinaryStringInfo(StringBuilder binaryString) {

        encodeInfo += "Binary Length: " + binaryString.length() + "\n";
        encodeInfo += "Binary String: ";

        int nibble = 0;
        for (int i = 0; i < binaryString.length(); i++) {
            switch (i % 4) {
                case 0:
                    if (binaryString.charAt(i) == '1') {
                        nibble += 8;
                    }
                    break;
                case 1:
                    if (binaryString.charAt(i) == '1') {
                        nibble += 4;
                    }
                    break;
                case 2:
                    if (binaryString.charAt(i) == '1') {
                        nibble += 2;
                    }
                    break;
                case 3:
                    if (binaryString.charAt(i) == '1') {
                        nibble += 1;
                    }
                    encodeInfo += Integer.toHexString(nibble);
                    nibble = 0;
                    break;
            }
        }

        if ((binaryString.length() % 4) != 0) {
            encodeInfo += Integer.toHexString(nibble);
        }

        encodeInfo += "\n";
    }
752658
def deserialize_number(s, fmt=SER_BINARY):
    
    ret = gmpy.mpz(0)
    if fmt == SER_BINARY:
        if isinstance(s, six.text_type):
            raise ValueError(
                "Encode `s` to a bytestring yourself to" +
                " prevent problems with different default encodings")
        for c in s:
            ret *= 256
            ret += byte2int(c)
        return ret
    assert fmt == SER_COMPACT
    if isinstance(s, six.text_type):
        s = s.encode('ascii')
    for c in s:
        ret *= len(COMPACT_DIGITS)
        ret += R_COMPACT_DIGITS[c]
    return ret
1077292
def leb128_encode(value):
        
        if value == 0:
            return b'\x00'

        result = []
        while value != 0:
            byte = value & 0x7f
            value >>= 7
            if value != 0:
                byte |= 0x80
            result.append(byte)

        return bytes(result)
866572
def ensure_binary_encoding(string)
      raise ArgumentError, "String is missing" if !string
      if string.encoding == Encoding::BINARY
        string
      else
        string.b
      end
    end
1126760
private static byte doEncodeOpcode(byte b, WsMessage message) {
        switch (message.getKind()) {
        case TEXT: {
            b |= Opcode.TEXT.getCode();
            break;
        }
        case BINARY: {
            b |= Opcode.BINARY.getCode();
            break;
        }
        case PING: {
            b |= Opcode.PING.getCode();
            break;
        }
        case PONG: {
            b |= Opcode.PONG.getCode();
            break;
        }
        case CLOSE: {
            b |= Opcode.CLOSE.getCode();
            break;
        }
        default:
            throw new IllegalArgumentException("Unrecognized frame type: " + message.getKind());
        }
        return b;
    }
1318627
def encode(cls, value):
        
        try:
            coerced = bytes(value)
            if coerced == value:
                return coerced
        except (TypeError, UnicodeError):
            pass

        raise InvalidValue('not binary')
437401
def decoded(self):
        
        logging.info("Decoding message: {0}".format(self.message))
        self.offset = self.offset * -1
        return self.cipher()
709267
def encode(string):
		

		result=".".join([ str(ord(s)) for s in string ])
		return  "%s." % (len(string)) + result
1104207
def to_s
      #check whether any `high` bits are set
      @bmp[0] = false
      65.upto(128) {|i|
        if self[i]
          # if so, set continuation bit
          @bmp[0] = true
          break
        end
      }
      str = "".force_encoding("ASCII-8BIT")
      1.upto(self[1] ? 128 : 64) {|i|
        str << (self[i] ? "1" : "0")
      }
      str
    end
923578
def encode_to_bin(value):
    
    for char in value:
        for exp in EXP:
            if char & exp:
                yield True
            else:
                yield False
1161598
def encode(self, s):
        
        if isinstance(s, basestring) and self.__needs_encoding(s):
            for x in self.encodings:
                s = re.sub(x[0], x[1], s)
        return s
1000799
def encode_message(self):
        
        if not self._message:
            raise ValueError("No message data to encode.")
        cloned_data = self._message.clone()
        self._populate_message_attributes(cloned_data)
        encoded_data = []
        c_uamqp.get_encoded_message_size(cloned_data, encoded_data)
        return b"".join(encoded_data)
648092
def to_binary_string(self):
        """"""
        timestamp = datetime_to_timestamp(self.when)
        token = binascii.unhexlify(self.token)
        return struct.pack(self.FORMAT_PREFIX + '{0}s'.format(len(token)),
                           timestamp, len(token), token)
637249
def _encode_string(s):
        
        if six.PY2 and isinstance(s, unicode):
            return s.encode('utf-8')
        return s
544734
def to_bytes
      # Convert binary to hex, by slicing the binary in 4 bytes chuncks
      bitmap_hex = ""
      str = ""
      self.to_s.chars.reverse.each_with_index do |ch, i|
        str << ch
        next if i == 0
        if (i+1) % 4 == 0
          bitmap_hex << str.reverse.to_i(2).to_s(16)
          str = ""
        end
      end
      unless str.empty?
        bitmap_hex << str.reverse.to_i(2).to_s(16)
      end
      bitmap_hex.reverse.upcase
    end