0

I am trying to input the letters ÆØÅ in a program I am currently writing. I am using the java.util.Scanner to do this, however, it does not want to accept these characters mentioned above.

Scanner in = new Scanner(System.in); <br>
String input = in.nextLine(); //Inputting testÆØÅ

Code runs as if nothing is broken, however, when debugging, a diamond square appears with a question mark inside it, for every "foreign" letter. Furthermore using VS code.

Also, when adding the scanner to my watchlist and seeing its properties, there is a field named Digits which has this value: "0123456789abcdefghijklmnopqrstuvwxyz". How do I fix this, making my scanner accept ÆØÅ? Not working with scanner.

Working with JOptionPane and its showInputDialog

enter image description here

skomisa
  • 16,436
  • 7
  • 61
  • 102
  • 4
    Install (and select) a different font in VScode. That is nothing more than a missing glyph in your current font. – Elliott Frisch Oct 02 '21 at 14:26
  • It is working fine in my terminal. – xdeepakv Oct 02 '21 at 14:28
  • 1
    https://stackoverflow.com/questions/4606570/os-x-terminal-utf-8-issues – xdeepakv Oct 02 '21 at 14:29
  • @ElliottFrisch Tried it, and it did not work. Still the same quiestion marks appears. Could have something to do with a delimiter? – Erik Skjellevik Oct 03 '21 at 13:42
  • @xdeepakv Couldn't get this to work either, seems different since it's on mac... – Erik Skjellevik Oct 03 '21 at 13:43
  • @ErikSkjellevik **No**. The code is fine. It's your font. You need a font that has your Swedish characters. Without that, it can't draw them. So you get a box and question marks. [Picture is worth 1000 words (apparently)](https://i.imgur.com/kArXc6l.png). – Elliott Frisch Oct 03 '21 at 13:48
  • @ElliottFrisch It works fine when using JOptionPane though - if it was the font, then surely JOptionPane shouldn't be working? – Erik Skjellevik Oct 03 '21 at 13:51
  • @ErikSkjellevik Different font in JOptionPane (the Java font) than the VSCode terminal window (the console font controlled by VSCode). – Elliott Frisch Oct 03 '21 at 13:52
  • @ElliottFrisch Cant seem to get it to work. Just installed a new font, Ubuntu Mono, which has ÆØÅ (shows me when asking if I want to install), however the scanner does not accept ÆØÅ. And furthermore the terminal looks broken with this font:) – Erik Skjellevik Oct 03 '21 at 14:09
  • @ErikSkjellevik I added the `visual-studio-code` tag to attract a wider audience, since this seems to be an environment issue rather than a Java issue. – skomisa Oct 18 '21 at 05:23

0 Answers0