code: function codePointAt(str, idx){
  		if(idx === undefined){
  			idx = 0;
  		}
  		var code = str.charCodeAt(idx);
  
  		// if a high surrogate
  		if (0xD800 <= code && code <= 0xDBFF && 
  			idx < str.length - 1){
  			var hi = code;
  			var low = str.charCodeAt(idx + 1);
  			if (0xDC00 <= low && low <= 0xDFFF){
  				return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;
  			}
  			return hi;
  		}
  		
  		// if a low surrogate
  		if (0xDC00 <= code && code <= 0xDFFF &&
  			idx >= 1){
  			var hi = str.charCodeAt(idx - 1);
  			var low = code;
  			if (0xD800 <= hi && hi <= 0xDBFF){
  				return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;
  			}
  			return low;
  		}
  		
  		//just return the char if an unmatched surrogate half or a 
  		//single-char codepoint
  		return code;
  	}
docs: Private function, gets a Unicode code point from a JavaScript UTF-16 string handling surrogate pairs appropriately