Capture Accent Words with Scanner

Asked

Viewed 812 times

4

I’m using a Java Scanner to capture Words/Phrases, but when I type in a word it contains or 'ç', the letter turns into a 'square'!

1 answer

5


By instantiating your Scanner you can inform the charset you want to use. So consider using something like this:

Scanner sc = new Scanner(System.in, "UTF-8");

The line above is an example, you must inform the charset that needs such as gifts here.

  • 1

    Well, the code you gave me didn’t work, however, starting from this I switched the "UTF-8" for "latin1" so it did work. Still Thank you!

  • Yes @Nickolascarlos, as said you can inform the charset. This was an example, you should even inform what is needed in your environment =). I will edit to better explain this, thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.