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

Invalid conversion for PUA on x-windows-50220 and x-windows-50221

XMLWordPrintable

    • b131
    • 9
    • x86
    • windows_7

      ====================================================================
      SYNOPSIS
      --------
      Invalid conversion for PUA on x-windows-50220 and x-windows-50221

      OPERATING SYSTEM(S)
      -------------------
      Windows 7 x64 (Japanese)

      FULL JDK VERSION(S)
      -------------------
      java version "9-ea"
      Java(TM) SE Runtime Environment (build 9-ea+131)
      Java HotSpot(TM) 64-Bit Server VM (build 9-ea+131, mixed mode)

      java version "1.8.0_102"
      Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)

      PROBLEM DESCRIPTION
      -------------------
      Java's x-windows-50220 and x-windows-50221 converter don't follow
      Windows' 50220 and 50221 specification on UDC/PUA

      Java: 1B244275211B2842
      Windows: 1B24427F211B2842

      DBCS part should be 7F21 instead of 7521


      TESTCASE
      --------

      c2b.java
      ====================================================
      public class c2b {
        public static void main(String[] args) throws Exception {
          int i = Integer.parseInt(args[1], 16);
          char[] ca = Character.toChars(i);
          System.out.print(Character.isDefined(i) ? " " : "*");
          for(char c : ca) System.out.printf("\\u%04X",(int)c);
          System.out.print(" -> ");
          for(byte b : (new String(ca)).getBytes(args[0])) System.out.printf("\\x%02X",(int)b&0xFF);
          System.out.println();
        }
      }
      ====================================================

      c2b_1.ps1
      ====================================================
      param($code, $hex)
      $enc_r = [Text.Encoding]::GetEncoding([int]$code)
      [char[]]$ca = @()
      $ca += ([System.Convert]::ToInt32([string]$hex, 16))
      $s = ""
      $enc_r.GetBytes($ca) | foreach {$s += [System.Convert]::ToInt32($_).ToString("X2")}
      $s
      ====================================================



      REPRODUCTION INSTRUCTIONS
      -------------------------

      >jdk9\jdk-9\bin\java c2b x-windows-50220 E000
      \uE000 -> \x1B\x24\x42\x75\x21\x1B\x28\x42

      >jdk8_102\jdk1.8.0_102\jre\bin\java c2b x-windows-50220 E000
      \uE000 -> \x1B\x24\x42\x75\x21\x1B\x28\x42

      >powershell -NoProfile -ExecutionPolicy Unrestricted .\c2b_1.ps1 50220 E000
      1B24427F211B2842

      >jdk9\jdk-9\bin\java c2b x-windows-50221 E000
      \uE000 -> \x1B\x24\x42\x75\x21\x1B\x28\x42

      >jdk8_102\jdk1.8.0_102\jre\bin\java c2b x-windows-50221 E000
      \uE000 -> \x1B\x24\x42\x75\x21\x1B\x28\x42

      >powershell -NoProfile -ExecutionPolicy Unrestricted .\c2b_1.ps1 50221 E000
      1B24427F211B2842

      WORKAROUND
      ----------
      Unknown

      SUGGESTED FIX
      -------------
      N/A
      ====================================================================

            sherman Xueming Shen
            youdwei Deven You (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: