test/spec/properties.spec.js
// Note: this fails if s contains an unmatched surrogate half.
this fails if s contains an unmatched surrogate half.
this fails if s contains an unmatched surrogate half .
function encodeUtf8(s) {
    let bytes = [];
    let a = unescape(encodeURIComponent(s));
    for (let i = 0; i < a.length; ++i) {
      bytes.push(a.charCodeAt(i));
    }
    return bytes;
  }
function encodeUtf8 ( s ) { let bytes = [ ] ; let a = unescape ( encodeURIComponent ( s ) ) ; for ( let i = 0 ; i < a . length ; ++ i ) { bytes . push ( a . charCodeAt ( i ) ) ; } return bytes ; }
Note: this fails if s contains an unmatched surrogate half.
Note : this fails if s contains an unmatched surrogate half .
// a is an ascii representation of UTF-8 bytes // ref: http://monsur.hossa.in/2012/07/20/utf-8-in-javascript.html