my dog learned polymorphism
The moose likes Java in General and the fly likes Problem with special characters Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Problem with special characters" Watch "Problem with special characters" New topic
Author

Problem with special characters

peddareddy nalini
Greenhorn

Joined: Mar 03, 2006
Posts: 1
Hi,

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.

-Nalini.
Joni Salonen
Ranch Hand

Joined: Jan 07, 2006
Posts: 53
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.

What is a "<" error?
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Problem with special characters
 
Similar Threads
[$-409]@ what is this symbol am getting from excel ??
java.sql.SQLException: ORA-00923: FROM keyword not found where expected
implement Java Programming logics
Connection Refused Error
Magnifying only a part of the image