It is not possible to write accents correctly (Spanish) in Java programs

I tried asking for it in more general forums, as it is not directly related to programming, but I could not find the answer, so I'm here.

When I try to type characters with an accent (for example, áéíóú) using the dead key method (in the usual way on Spanish keyboards, press "and then the vowel to combine them") in each individual Java program , not made by me , for example Netbeans, Eclipse, or any .jar downloaded from the Internet, it does not write accent. When I press the double key, it writes “instead”, which would be normal behavior.

I can “write” accented characters, since I can copy them from a notebook, what I can’t do is type them directly using the usual dead key method.

The input language displayed on the language bar is Spanish, as elsewhere, and the correct location of the keys.

I tried reinstalling the JRE and looking for malware to no avail.

I am using Windows XP and the version of JRE is 1.6.0_26-b03, although it also did not work in the previous version.

+4
source share
2 answers

Java code must be UTF-8. If you encode characters using unicode \unnnn , you can use any unicode characters.

Here is how you would encode your example:

  String spanish = "\u00E1\u00E9\u00ED\u00F3\u00FA"; System.out.println(spanish); // prints áéíóú 

This works / compiles OK in Eclipse.

+5
source

Go to Control Panel → Regional Settings → Languages ​​→ [More] → [Language Panel] and check the box “Show the language bar on the desktop” so that you can see if your Java programs process keyboard input differently from your other programs.

There are various ways to enter your accent keys using AltGr + different characters or using `as a dead key (i.e. press` and then a letter to make up the accented character.)

You can also try using Alt + numeric codes on the keyboard, which may take longer, but should be easier than translating everything into Unicode code codes and inserting into strings using \u escape sequences.

There are various links for alt codes, here only one is torn from Google: http://usefulshortcuts.com/alt-codes/spanish-alt-codes.php

+1
source

All Articles