> Buffer.byteLength('\uD834')
3
> Buffer.byteLength('\uDF06')
3
> Buffer.byteLength('\uD834 \uDF06')
7
// as surrogate pair
> Buffer.byteLength('\uD834\uDF06')
4
> Buffer.byteLength('\uD834', 'ucs2')
2
> Buffer.byteLength('\uDF06', 'ucs2')
2
// this one uses the space char, \u0020 in a surrogate pair
> Buffer.byteLength('\uD834 \uDF06', 'ucs2')
6
> Buffer.byteLength('\uD834\u0020\uDF06', 'ucs2')
6
// as surrogate pair
> Buffer.byteLength('\uD834\uDF06', 'ucs2')
4
> Buffer.byteLength('𝌆')
4
> Buffer.byteLength('𝌆', 'ucs2')
4
// this one has different code points, based on encoding
// \u20AC may be used instead of €
> Buffer.byteLength('€')
3
> Buffer.byteLength('€', 'ucs2')
2
Created
August 8, 2012 12:38
-
-
Save SaltwaterC/3294812 to your computer and use it in GitHub Desktop.
JavaScript string encoding
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment