Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8750629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:54:02+00:00 2026-06-13T12:54:02+00:00

According to the Java SE 7 Specification , Java uses the Unicode UTF-16 standard

  • 0

According to the Java SE 7 Specification, Java uses the Unicode UTF-16 standard to represent characters.
When imagining a String as a simple array of 16-bit variables each containing one character, life is simple.

Unfortunately, there are code points for which 16 bits simply aren’t enough (I believe it was 16/17th of all Unicode characters). So in a String, this poses no direct problem, because when wanting to store one of these ~1.048.576 characters using an additional two bytes, simply two array positions in that String would be used.

This, without posing any direct problem, works for Strings, because there can always be an additional two bytes. Though when it comes to single variables which, in contrast to the UTF-16 encoding, have a fixed length of 16 bits, how can these characters be stored, and in particular, how does Java do it with its 2-byte “char” type?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:54:03+00:00Added an answer on June 13, 2026 at 12:54 pm

    The answer is in the javadoc :

    The char data type (and therefore the value that a Character object
    encapsulates) are based on the original Unicode specification, which
    defined characters as fixed-width 16-bit entities. The Unicode
    standard has since been changed to allow for characters whose
    representation requires more than 16 bits.

    The range of legal code
    points is now U+0000 to U+10FFFF, known as Unicode scalar value.
    (Refer to the definition of the U+n notation in the Unicode standard.)
    The set of characters from U+0000 to U+FFFF is sometimes referred to
    as the Basic Multilingual Plane (BMP). Characters whose code points
    are greater than U+FFFF are called supplementary characters. The Java
    2 platform uses the UTF-16 representation in char arrays and in the
    String and StringBuffer classes. In this representation, supplementary
    characters are represented as a pair of char values, the first from
    the high-surrogates range, (\uD800-\uDBFF), the second from the
    low-surrogates range (\uDC00-\uDFFF).

    A char value, therefore,
    represents Basic Multilingual Plane (BMP) code points, including the
    surrogate code points, or code units of the UTF-16 encoding. An int
    value represents all Unicode code points, including supplementary code
    points. The lower (least significant) 21 bits of int are used to
    represent Unicode code points and the upper (most significant) 11 bits
    must be zero.

    Unless otherwise specified, the behavior with respect to
    supplementary characters and surrogate char values is as follows: The
    methods that only accept a char value cannot support supplementary
    characters. They treat char values from the surrogate ranges as
    undefined characters. For example, Character.isLetter(‘\uD840’)
    returns false, even though this specific value if followed by any
    low-surrogate value in a string would represent a letter. The methods
    that accept an int value support all Unicode characters, including
    supplementary characters. For example, Character.isLetter(0x2F81A)
    returns true because the code point value represents a letter (a CJK
    ideograph). In the Java SE API documentation, Unicode code point is
    used for character values in the range between U+0000 and U+10FFFF,
    and Unicode code unit is used for 16-bit char values that are code
    units of the UTF-16 encoding. For more information on Unicode
    terminology, refer to the Unicode Glossary.

    Simply said :

    • the 16 bits for a char rule was designed for an old version of the Unicode standard
    • you sometimes need two chars to represent a unicode rune (code point) which isn’t in the Basic Multilingual Plane. This kindof “works” because you don’t frequently use chars, especially to handle unicode runes outside the BMP.

    Even simpler said :

    • a java char doesn’t represent a Unicode codepoint (well, not always).

    As an aside, it can be noted that the evolution of Unicode to extend past the BMP made UTF-16 globally irrelevant, now that UTF-16 doesn’t even enable a fixed byte-chars ratio. That’s why more modern languages are based on UTF-8. This manifesto helps understand it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to the JLS (Java Language Specification): The notion of subsignature is designed to
According to the Java Language Specification , constructors cannot be marked synchronized because other
According to: http://java.sun.com/docs/books/jls/second_edition/html/typesValues.doc.html 4.5.2 Variables of Reference Type A reference type can hold a
According to the Java Language Specification : If there are any enclosing try statements
According to Java specification, the size of a char data type is 16 bits
I'm writing an Android application and use HashMap<String,MyClass> . According to Java and Android
According to the Java EE 6 docs JPA 1.0 @OrderBy uses field names vs.
According to Java thread state info calling wait() will result a thread to go
According to the documentation of java.util.Pattern , the POSIX character class \p{Graph} ( [:graph:]
According to the documentation for getResultSet in java.sql.Statement , it says: Retrieves the current

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.