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

GetTextPlainUnicodeFlavor returns dataflavor with unsupported charset "utf-16l

XMLWordPrintable

    • generic
    • generic

      Incase of windows:
      --------------------
      The getTextPlainUnicodeFlavor() method returns a DataFlavor which has the following parameters:
              "text/plain;class=java.io.InputStream;charset=utf-16le"
      This encode value "utf-16le" is not supported hence the IllegalArgumentException is thrown when it is passed to the getReaderForText method.

      The following exception is thrown :

       java.io.UnsupportedEncodingException: utf-16le
              at sun.io.Converters.getConverterClass(Converters.java:97)
              at sun.io.Converters.newConverter(Converters.java:128)
              at sun.io.CharToByteConverter.getConverter(CharToByteConverter.java:71)
              at java.lang.String.getCTBConverter(String.java:154)
              at java.lang.String.getBytes(String.java:662)
              at ReaderForText$TextTransferable.getTransferData(ReaderForText.java:267
      )
              at ReaderForText$MenuItemHandler.pasteToClipboard(ReaderForText.java:172
      )
              at ReaderForText$MenuItemHandler.actionPerformed(ReaderForText.java:94)
              at java.awt.MenuItem.processActionEvent(MenuItem.java:525)
              at java.awt.MenuItem.processEvent(MenuItem.java:489)
              at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:275)
              at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:265)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:322)
              at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:10
      7)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:97)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:88)

      Testcase that reproduces this bug:

      1)ReaderForText.java : Transferable Class which extends StringSelection.
        

      To Run the sample program :

      1) Run the ReaderForText.class
      2) Do copy and paste operations using the menu items.

      Incase of Solaris 2.7:
      -----------------------
      The charset returned is "iso-10646-ucs-2" . No exception is thrown in this case and so the paste operation is successful.

            uwesunw Uwe Uwe (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: