code: function fixedCharCodeAt(str, idx) {
    idx = idx || 0;
    var code = str.charCodeAt(idx), hi, low;
    if (0xD800 <= code && code <= 0xDBFF) {
      // High surrogate (could change last
      // hex to 0xDB7F to treat high private
      // surrogates as single characters)
      hi = code;
      low = str.charCodeAt(idx + 1);
      return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;
    }
    if (0xDC00 <= code && code <= 0xDFFF) {
      // Low surrogate
      // We return false to allow loops to skip this iteration since should have
      // already handled high surrogate above in the previous iteration
      return false;
      /*hi = str.charCodeAt(idx-1);
       low = code;
       return ((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000;*/
    }
    return code;
  }
docs: fixedCharCodeAt by Frank Neff, licensed GPLv2 original source: https://gist.github.com/frne/1358348