/*JSON{ "type":"method", "class": "String", "name" : "charAt", "description" : "Return a single character at the given position in the String.", "generate" : "jswrap_string_charAt", "params" : [ [ "pos", "int", "The character number in the string. Negative values return characters from end of string (-1 = last char)"] ], "return" : ["JsVar", "The character in the string"] }*/ JsVar *jswrap_string_charAt(JsVar *parent, JsVarInt idx) { // We do this so we can handle '/0' in a string JsVar *r = jsvNewFromEmptyString(); if (r) { // out of mem? char ch = jsvGetCharInString(parent, (int)idx); jsvAppendStringBuf(r, &ch, 1); } return r; }
/*JSON{ "type" : "method", "class" : "String", "name" : "charCodeAt", "generate" : "jswrap_string_charCodeAt", "params" : [ ["pos","int","The character number in the string. Negative values return characters from end of string (-1 = last char)"] ], "return" : ["int32","The integer value of a character in the string"] } Return the integer value of a single character at the given position in the String. Note that this returns 0 not 'NaN' for out of bounds characters */ int jswrap_string_charCodeAt(JsVar *parent, JsVarInt idx) { return (unsigned char)jsvGetCharInString(parent, (size_t)idx); }
/*JSON{ "type":"method", "class": "String", "name" : "charCodeAt", "description" : ["Return the integer value of a single character at the given position in the String.", "Note that this returns 0 not 'NaN' for out of bounds characters"], "generate" : "jswrap_string_charCodeAt", "params" : [ [ "pos", "int", "The character number in the string. Negative values return characters from end of string (-1 = last char)"] ], "return" : ["int", "The integer value of a character in the string"] }*/ JsVarInt jswrap_string_charCodeAt(JsVar *parent, JsVarInt idx) { return jsvGetCharInString(parent, (int)idx); }