title: Unicode supplementary planes in JavaFX
body: <p>I'm having problems dealing with Unicode characters from supplementary ("astral") planes in JavaFX. Specifically, I can't paste such characters in a <code>TextInputDialog</code> (I get some weird characters instead, such as <code>ð</code>), and can't use them in a WebView (they get rendered as <code>������</code>).</p>
  
  <p>The same characters are working perfectly fine if I input them via <code>JOptionPane.showInputDialog</code> and print them to the console. They even show in a JavaFX <code>Alert</code>, although it appends some junk at the end.</p>
  
  <p>Is there a way to fix these problems?</p>
  
  <p>I'm using Oracle JDK version 1.8.0_51 in Linux.<br>
  Examples of supplementary plane characters:     <br>
  If you can't see them, you may need to install additional fonts such as Symbola or Noto.</p>
  
  <p>Here's an example program (using a <code>Label</code> rather than a <code>WebView</code>):</p>
  
  <pre><code>import javax.swing.JOptionPane;
  
  import javafx.application.Application;
  import javafx.scene.Scene;
  import javafx.scene.control.Alert;
  import javafx.scene.control.Alert.AlertType;
  import javafx.scene.control.Label;
  import javafx.scene.control.TextInputDialog;
  import javafx.scene.layout.StackPane;
  import javafx.stage.Stage;
  
  public class UniTest extends Application {
      @Override
      public void start(final Stage stage) throws Exception {
          final String s = new String(new int[]{127137, 178050, 3232, 128512, 241}, 0, 5);
          System.out.println("The string: " + s);
          System.out.println("Characters: " + s.length());
          System.out.println("Code points: " + s.codePoints().count());
  
          JOptionPane.showMessageDialog(null, s, "JOptionPane", JOptionPane.INFORMATION_MESSAGE);
  
          final Alert al = new Alert(AlertType.INFORMATION);
          al.setTitle("Alert");
          al.setContentText(s);
          al.showAndWait();
  
          final TextInputDialog dlg = new TextInputDialog();
          dlg.setTitle("TextInputDialog");
          dlg.setContentText("Try to paste the string in here");
          dlg.showAndWait().ifPresent(x -&gt; System.out.println("Your input: " + x));
  
          final StackPane root = new StackPane();
          root.getChildren().add(new Label(s));
          stage.setScene(new Scene(root, 400, 300));
          stage.setTitle("Stage");
          stage.show();
      }
  
      public static void main(final String... args) {
          launch(args);
      }
  }
  </code></pre>
  
  <p>And here are the results I get:</p>
  
  <p><a href="https://i.stack.imgur.com/LgUTW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LgUTW.png" alt="screenshots"></a></p>
  
  <p>Note: not all the characters in the example are from supplementary planes, and one of the characters is only rendered correctly in the console.</p>