Our applications supports different languages. When I am trying to print a String in Linux, I am getting a ? instead of a spanish special character.I should get "Aveo recibi� distinci�n de Auto" but I am getting "Aveo recibi? distinci?n de Auto". I am using UTF-8 encoding.
When i tried the same in Windows in eclipse it is printing correctly with ISO-8859-1. But when I run the same program from command prompt I get a "<" error.
Could any of you please help me out with this. Its very urgent friends.
Joined: Jan 07, 2006
The error can occur in two places: 1) When you compile or 2) when you run the program.
1) The compiler reads the source code file interpreting the bytes in it as a stream of characters using a character encoding. If it cannot interprete some byte as a character it replaces it with an "illegal character" symbol which almost always prints out as a question mark. The encoding that the compiler uses depends on the settings of the computer, or it can be set on the command line. Because the character encodings vary from platfrom to platform and user to user, it is more portable to write the source in ASCII and replace non-ASCII characters wtih unicode-escapes. For example you would write "Aveo recibi\u00f3 distinci\u00f3n de Auto." The native2ascii tool that is distributed with the JDK can make this conversion automatically.
2) When you run the program and print a String, the bytes that are printed to the console or file depend on the language settings of the user's system. If the language settings don't support some characters, they are replaced with question marks. On linux you can change the language settings by changing certain environment variables, namely LANG, LC_ALL, or LC_CTYPE. Try for example these commands: See the manual page of the "locale" command for more information on the environment variables and ways to list available locales.
But when I run the same program from command prompt I get a "<" error.