code: def _decode_bytes(data, encoding, str_len):
          
          string = data.decode(encoding, 'replace')
          if len(string) != str_len:
              log.warning("invalid decoded string length")
          return string
docs: Generic decoding with length check.
          The string is decoded from bytes with the given encoding, then the length
          of the string is checked.
          The string is decoded using the "replace" method.
  
          :param data: bytes
          :param encoding: encoding name ("utf-8" or "utf-16")
          :param str_len: length of the decoded string
          :return: str