create_string_buffer(aString) -> character array
    create_string_buffer(anInteger) -> character array
    create_string_buffer(aString, anInteger) -> character array
773172
def create_string_buffer(init, size=None):
    
    if isinstance(init, (str, unicode)):
        if size is None:
            size = len(init) + 1
        buftype = c_char * size
        buf = buftype()
        buf.value = init
        return buf
    elif isinstance(init, (int, long)):
        buftype = c_char * init
        buf = buftype()
        return buf
    raise TypeError, init
444982
def str_to_int_array(string, base=16):
    

    int_strings = string.split()
    return [int(int_str, base) for int_str in int_strings]
1255627
def create_buffer(params, value):
    '''
    
    '''
    try:
        fv = float(value)
        return np.full(params.length, fv, np.float)
    except TypeError:
        if isinstance(value, np.ndarray):
            if (len(value)>=params.length):
                return value
        raise TypeError('Value must be a float or a numpy array ofthe required length')
1183219
function (buffer) {
        var str = '',
            uArrayVal = new Uint8Array(buffer),

            i,
            ii;

        for (i = 0, ii = uArrayVal.length; i < ii; i++) {
            str += String.fromCharCode(uArrayVal[i]);
        }

        return str;
    }
211217
function stringToUint8Array(s) {
    var a = new Uint8Array(s.length);
    for(var i = 0, j = s.length; i < j; ++i) {
        a[i] = s.charCodeAt(i);
    }
    return a;
}
277180
public void write(String str, int off, int len)  {
    	char[] chars = new char[len];
    	str.getChars(off, off+len, chars, 0);
    	buf.append(chars);
    }
551672
def add_from_string(self, buffer, length=-1):
        

        return Gtk.Builder.add_from_string(self, buffer, length)
873775
def random_string(len)
      rand_max = RAND_CHARS.bytesize
      ret = ""
      len.times{ ret << RAND_CHARS[rand(rand_max)] }
      ret
    end
1335292
function stringToArrayBuffer(text) {
      if (window.TextEncoder !== undefined) {
        return new TextEncoder().encode(text).buffer;
      }

      var array = new Uint8Array(new ArrayBuffer(text.length));

      for (var i = 0, il = text.length; i < il; i++) {
        var value = text.charCodeAt(i);

        // Replacing multi-byte character with space(0x20).
        array[i] = value > 0xff ? 0x20 : value;
      }

      return array.buffer;
    }
941126
def _encode_string(string):
    """"""
    if not isinstance(string, bytes):
        string = string.encode('utf8')
    return ffi.new('char[]', string)
1352940
function arrayLikeToString(array) {
      // Performances notes :
      // --------------------
      // String.fromCharCode.apply(null, array) is the fastest, see
      // see http://jsperf.com/converting-a-uint8array-to-a-string/2
      // but the stack is limited (and we can get huge arrays !).
      //
      // result += String.fromCharCode(array[i]); generate too many strings !
      //
      // This code is inspired by http://jsperf.com/arraybuffer-to-string-apply-performance/2
      var chunk = 65536;
      var result = [], len = array.length, type = JSZip.utils.getTypeOf(array), k = 0;

      while (k < len && chunk > 1) {
         try {
            if (type === "array" || type === "nodebuffer") {
               result.push(String.fromCharCode.apply(null, array.slice(k, Math.max(k + chunk, len))));
            } else {
               result.push(String.fromCharCode.apply(null, array.subarray(k, k + chunk)));
            }
            k += chunk;
         } catch (e) {
            chunk = Math.floor(chunk / 2);
         }
      }
      return result.join("");
   }
1084485
public void append(String str, int off, int len) {
	int restLength = buffer.length - pos;
	if (len < restLength) {
	    str.getChars(off, off + len, buffer, pos);
	    pos += len;
	}
	else {
	    str.getChars(off, off + restLength, buffer, pos);
	    curr.next = new Entity(buffer);
	    curr = curr.next;
	    length += buffer.length;
	    buffer = new char[(buffer.length > len - restLength) ? buffer.length : len - restLength];

	    str.getChars(off + restLength, off + len, buffer, 0);
	    pos = len - restLength;

	}
    }
81379
private static byte[] toByteArray(String string) {
        byte[] bytes = new byte[string.length() + 1];
        for (int i = 0; i < string.length(); i++) {
            bytes[i] = (byte) string.charAt(i);
        }
        return bytes;
    }
326883
def <<(other)
      case other
      when String
        other.each_char do |char|
          byte = char_to_byte(char)

          @chars[byte] = char
          super(byte)
        end

        return self
      when Integer
        super(other)
      else
        raise(TypeError,"can only append Strings and Integers")
      end
    end
245646
function (s) {
        var buffer = new ArrayBuffer(s.length);
        var b = new Uint8Array(buffer);
        var i;
        for (i = 0; i < s.length; i++) {
            b[i] = s.charCodeAt(i);
        }
        return b;
    }
827263
public static void appendAsString(
        final StringBuilder sb, final DirectBuffer buffer, final int index, final Encoding encoding)
    {
        switch (encoding.primitiveType())
        {
            case CHAR:
                sb.append('\'').append((char)buffer.getByte(index)).append('\'');
                break;

            case INT8:
                sb.append(buffer.getByte(index));
                break;

            case INT16:
                sb.append(buffer.getShort(index, encoding.byteOrder()));
                break;

            case INT32:
                sb.append(buffer.getInt(index, encoding.byteOrder()));
                break;

            case INT64:
                sb.append(buffer.getLong(index, encoding.byteOrder()));
                break;

            case UINT8:
                sb.append((short)(buffer.getByte(index) & 0xFF));
                break;

            case UINT16:
                sb.append(buffer.getShort(index, encoding.byteOrder()) & 0xFFFF);
                break;

            case UINT32:
                sb.append(buffer.getInt(index, encoding.byteOrder()) & 0xFFFF_FFFFL);
                break;

            case UINT64:
                sb.append(buffer.getLong(index, encoding.byteOrder()));
                break;

            case FLOAT:
                sb.append(buffer.getFloat(index, encoding.byteOrder()));
                break;

            case DOUBLE:
                sb.append(buffer.getDouble(index, encoding.byteOrder()));
                break;
        }
    }
491066
public static String createString(char[] charBuf)
    {
        if (!enabled)
        {
            return createStringFallback(charBuf);
        }

        String str = new String();
        try
        {
            // try to prevent possible final field setting execution reordering in JIT 
            // (JSR-133/JMM, "9.1.1 Post-Construction Modification of Final Fields")
            // it was a bit unclear for me if this could ever happen in a single thread
            synchronized (str)
            {
                valueField.set(str, charBuf);
                countField.set(str, charBuf.length);
            }
            synchronized (str)
            {
                // safety check, just to be sure that setting the final fields went ok
                if (str.length() != charBuf.length)
                {
                    throw new IllegalStateException(
                            "Fast java.lang.String construction failed.");
                }
            }
        }
        catch (Exception e)
        {
            handleError(e);
            str = createStringFallback(charBuf);
        }
        return str;
    }