Important:
I must use plain windows notepad only (neither IDE nor Notepad++ or any other text editors allowed).
So I have a simple class:
class Test{
public static void main(String[] args){
char c = 'қ';
System.out.println(c);
}
}
By default notepad saves text files using ANSII encoding, but as you can see I have a non-ANSII character in my code. I can compile and run this code via command prompt, but output is ?
instead of қ
, which seems obvious. When I change the file's encoding to UTF-8, compiler throws an error. I have read this article Illegal Character when trying to compile java code but there is no solution for my particular problem, because as I wrote above, I am not allowed to use any text editors but Windows notepad.
Thank you!
Probably you need like this:
char c = '\u039A';
I don't know the code of your 'k', but you may find it on https://www.ssec.wisc.edu/~tomw/java/unicode.html
Also hopes that Windows has this character for output in the console
ps The console of windows has a certain code page. Try to change it in console, for example:
REM change CHCP to UTF-8
CHCP 65001
CLS
and remember about different fonts in windows console, some of them can't draw specific symbols.
Yes, the problem is that javac is non-compliant in not accepting the BOM with UFT-8.
Use Notepad to save as Unicode (actually UTF-16LE).
Compile with
javac -encoding UTF-16 Test.java
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.