Procedure that returns (possibly encoded) string as a result of api function call
 or nil if zero characters was returned by api call
333258
def return_string( encode = nil )
      lambda do |api, *args|
        WinGui.enforce_count( args, api.prototype, -2)
        args += [string = buffer, string.length]
        num_chars = api.call(*args)
        return nil if num_chars == 0
        string = string.force_encoding('utf-16LE').encode(encode) if encode
        string.rstrip
      end
    end
897559
def called_with_string_literal?
      @string_allocation_count = 0
      method_array.each do |m|
        positions.each {|position| @string_allocation_count += 1 if m.arg_types[position] == :string_literal }
      end
      !@string_allocation_count.zero?
    end
988408
function getRemoteMethodOutput(method) {

    let returnType = 'JSON';
    let list = false;

    if (method.returns && method.returns[0]) {
        if (!SCALARS[method.returns[0].type] && typeof method.returns[0].type !== 'object') {
            returnType = `${method.returns[0].type}`;
        } else {
            returnType = `${method.returns[0].type}`;
            if (_.isArray(method.returns[0].type) && _.isString(method.returns[0].type[0])) {
                returnType = method.returns[0].type[0];
                list = true;
            } else if (typeof method.returns[0].type === 'object') {
                returnType = 'JSON';
            }
        }
    }

    let type = exchangeTypes[returnType] || returnType;
    type = (list) ? getConnection(type) : getType(type);
    type = type || getType('JSON');

    return {
        type,
        list
    };
}
740621
function _checkResult(type, err, obj, options)
{
    if (options) {
        if (options.logger) logger.logger(options.logger, 'parse:', type, options, lib.traceError(err), obj);
        if (options.datatype == "object" || options.datatype == "obj") return {};
        if (options.datatype == "list") return [];
        if (options.datatype == "str") return "";
    }
    return null;
}
1262963
def _get_string(data, position, obj_end, dummy):
    """"""
    length = _UNPACK_INT(data[position:position + 4])[0]
    position += 4
    if length < 1 or obj_end - position < length:
        raise InvalidBSON("invalid string length")
    end = position + length - 1
    if data[end:end + 1] != b"\x00":
        raise InvalidBSON("invalid end of string")
    return _utf_8_decode(data[position:end], None, True)[0], end + 1
967306
def consume_string(ending = nil)
      ending = @s.current if ending.nil?
      value  = String.new

      until @s.eos?
        case char = @s.consume
        when ending
          break

        when "\n"
          # Parse error.
          @s.reconsume
          return create_token(:bad_string,
            :error => true,
            :value => value)

        when '\\'
          case @s.peek
          when ''
            # End of the input, so do nothing.
            next

          when "\n"
            @s.consume

          else
            value << consume_escaped
          end

        else
          value << char
        end
      end

      create_token(:string, :value => value)
    end
557895
function decodeStr(s, decoder) {
  try {
    return decoder(s);
  } catch (e) {
    return QueryString.unescape(s, true);
  }
}
12
def check_symbol_to_proc
      return unless method_call.block_argument_names.count == 1
      return if method_call.block_body.nil?
      return unless method_call.block_body.sexp_type == :call
      return if method_call.arguments.count > 0

      body_method_call = MethodCall.new(method_call.block_body)

      return unless body_method_call.arguments.count.zero?
      return if body_method_call.has_block?
      return unless body_method_call.receiver.name == method_call.block_argument_names.first

      add_offense(:block_vs_symbol_to_proc)
    end
322148
def nextvalue
      c = self.nextclean
      s = ""

      case c
      when /\"|\'/
	return(self.nextstring(c))
      when '{'
	self.back()
        return(Hash.new.from_json(self))
      when '['
	self.back()
	return(Array.new.from_json(self))
      else
	buf = ""
	while ((c =~ /"| |:|,|\]|\}|\/|\0/).nil?)
	  buf += c
	  c = self.nextchar()
	end
	self.back()
	s = buf.chomp
	case s
	when "true"
	  return(true)
	when "false"
	  return(false)
	when "null"
	  return(nil)
	when /^[0-9]|\.|-|\+/
          if s =~ /[.]/ then
            return Float(s)
          else
            return Integer(s)
          end
	end
	if (s == "")
          s = nil
        end
	return(s)
      end
    end
341737
function(string) {
            
            var i = 0;
            while(i < string.length)
            {
                if(     (// ASCII
                string[i] == 0x09 ||
                    string[i] == 0x0A ||
                    string[i] == 0x0D ||
                    (0x20 <= string[i] && string[i] <= 0x7E)
                    )
                    ) {
                    i += 1;
                    continue;
                }
                
                if(     (// non-overlong 2-byte
                (0xC2 <= string[i] && string[i] <= 0xDF) &&
                    (0x80 <= string[i+1] && string[i+1] <= 0xBF)
                    )
                    ) {
                    i += 2;
                    continue;
                }
                
                if(     (// excluding overlongs
                string[i] == 0xE0 &&
                    (0xA0 <= string[i + 1] && string[i + 1] <= 0xBF) &&
                    (0x80 <= string[i + 2] && string[i + 2] <= 0xBF)
                    ) ||
                    (// straight 3-byte
                ((0xE1 <= string[i] && string[i] <= 0xEC) ||
                    string[i] == 0xEE ||
                    string[i] == 0xEF) &&
                    (0x80 <= string[i + 1] && string[i+1] <= 0xBF) &&
                    (0x80 <= string[i+2] && string[i+2] <= 0xBF)
                    ) ||
                    (// excluding surrogates
                string[i] == 0xED &&
                    (0x80 <= string[i+1] && string[i+1] <= 0x9F) &&
                    (0x80 <= string[i+2] && string[i+2] <= 0xBF)
                    )
                    ) {
                    i += 3;
                    continue;
                }
                
                if(     (// planes 1-3
                string[i] == 0xF0 &&
                    (0x90 <= string[i + 1] && string[i + 1] <= 0xBF) &&
                    (0x80 <= string[i + 2] && string[i + 2] <= 0xBF) &&
                    (0x80 <= string[i + 3] && string[i + 3] <= 0xBF)
                    ) ||
                    (// planes 4-15
                (0xF1 <= string[i] && string[i] <= 0xF3) &&
                    (0x80 <= string[i + 1] && string[i + 1] <= 0xBF) &&
                    (0x80 <= string[i + 2] && string[i + 2] <= 0xBF) &&
                    (0x80 <= string[i + 3] && string[i + 3] <= 0xBF)
                    ) ||
                    (// plane 16
                string[i] == 0xF4 &&
                    (0x80 <= string[i + 1] && string[i + 1] <= 0x8F) &&
                    (0x80 <= string[i + 2] && string[i + 2] <= 0xBF) &&
                    (0x80 <= string[i + 3] && string[i + 3] <= 0xBF)
                    )
                    ) {
                    i += 4;
                    continue;
                }
                
                return false;
            }
            
            return true;
        }
163559
def get_string(cfunc, *args):
    
    cstr = get_ctype("const char**", cfunc, *args)
    return backend.ffi.string(cstr).decode() if cstr else None
1361646
def _get_result_string(self, key):
        

        row, col, tab = key

        result_obj = self.grid.code_array[row, col, tab]

        try:
            # Numpy object arrays are converted because of numpy repr bug
            result_obj = result_obj.tolist()

        except AttributeError:
            pass

        return unicode(result_obj)
1265352
function(arrayOfValues) {
        var i = 0,
            currentLength,
            finishedString = '';

        for (; i < arrayOfValues.length; i++) {
            currentLength = i + 1;

            if (currentLength === arrayOfValues.length) {
                finishedString += ' and ' + arrayOfValues[i];
            }
            else if (i === 0) {
                finishedString += arrayOfValues[i];
            }
            else {
                finishedString += ', ' + arrayOfValues[i];
            }
        }

        return finishedString;
    }
150164
function (method, result) {

      // result should not be undefined
      if (result === undefined) {
        console.warn('JSON-RPC2 response from method ' + methodName + ' should return a result. (JSON-RPC2 spec)')
        result = ''
      }

      var rpcMessage = {
        jsonrpc: '2.0',
        result: result,
        id: id
      }

      callback(rpcMessage)
      responseHasBeenSent = true

    }
922434
def get_code(url, code = nil, options = nil)
      code ||= if options && options.with_charset?
        shorten_fixed_charset(url, options.length, options.charset)
      else
        shorten(url)
      end
    end
1141766
def ustr(obj):
    
    if sys.version_info[0] == 2:
        # If we are getting a string, then do an explicit decode
        # else, just call the unicode method of the object
        if type(obj) in [str, basestring]:  # pragma: no cover # noqa
            return unicode(obj, DEFAULT_ENCODING)  # pragma: no cover # noqa
        else:
            return unicode(obj)  # pragma: no cover # noqa
    else:
        if type(obj) in [bytes]:
            return obj.decode(DEFAULT_ENCODING)
        else:
            return str(obj)
1149049
function (method) {
        var
          str = '' + method,
          i = str.indexOf(SUPER)
        ;
        return i < 0 ?
          false :
          isBoundary(str.charCodeAt(i - 1)) &&
          isBoundary(str.charCodeAt(i + 5));
      }