Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8307162

Represent jchar as a proper C/C++ UTF-16 character

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 21
    • hotspot

      C and C++ have had a language type which is properly meant to encode UTF-16 characters for a long time by this point: char16_t. Its underlying type is an unsigned short, making it entirely backwards compatible with the Java Native Interface's requirement that a jchar is an unsigned 16 bit type. With these types underlying the jchar typedef special support for jchar can be used within native C and C++ code in the JDK, as well as solving certain casting issues with native APIs, such as on Windows, all in a backwards compatible way

      Caveat: Although all the platforms we support do have an unsigned 16 bit number as the underlying type of char16_t, a new platform we may add support for in the future might technically not do so. An assert can be very easily added in such a case

            jwaters Julian Waters
            jwaters Julian Waters
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: