2

I'm watching ECMA-262 (JavaScript 5 edition) and cannot understand what is "code unit value"?

Can anyone tell me?

Thank you very much!

2
  • Can you add some context, like the paragraph it is mentioned in? Commented Mar 9, 2011 at 10:50
  • Pekka, thank you for your reply! The question has been answered by Mathias Bynens at below. :) Commented Mar 9, 2011 at 12:35

1 Answer 1

5

A JavaScript string is a sequence of unsigned 16-bit integers, also known as code units.

A code point is how the Unicode standard represents symbols and non-symbols. Code points are represented as a four-to-six digit hexadecimal number, typically prefixed with U+, e.g. U+0061 LATIN SMALL LETTER A.

The difference is that what can be part of a code unit depends on the character encoding that is used. A code point however, is merely the concept of a “character” that can then potentially be encoded using UTF-8, for example.

For more information, read chapter 2 of the Unicode spec, especially 2.4 Code points and characters.

Sign up to request clarification or add additional context in comments.

1 Comment

I don’t think this is correct. ecma-international.org/ecma-262/5.1/#sec-6 defines the terms "code unit" and "code point" as two separate concepts, the former being limited to characters which can be represented by 16 bits and the latter referring to a Unicode scalar value.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.