JoachimSauer wrote:Informative and interesting, thanks.
In this case (string constant inside the source code), you probably didn't compile the source code with the correct encoding. javac has a parameter called "encoding" where you can specify the character encoding of your source code and if you don't provide it, javac will use the platform default encoding (which seems to be the wrong choice in your case).
So you should either:
* put all your non-ASCII strings into resource bundles (which have a defined encoding) or
* use unicode-escapes for all non-ASCII characters ("क" is "\u0915").
Ranjan_Yengkhom wrote:If it comes out as "\u3f" (instead of failing to compile or any other value), then your source code already contains the question mark. So you already saved it wrong and have to re-type it (at least the single character).
I have tried with the parameter
c:\ javac -encoding utf8 filename.java
Still I am getting the same print i.e. \u3f
Then I studied one tutorial regarding this issueThat's one way. But since that is so problematic (you'll have to remember/make sure to always save it that way and to compile it using the correct switch), the better solution by far is not to use any non-ASCII characters in your source code.
It says that we need to save the java file in UTF-8 format. I have explored most of the editors like netbean, eclipse, JCreator, etc... there is no option to save the java file in UTF-8 format.