IntelliJ IDEA 控制台,Unicode 打印错误
class Phone {
private String name;
private String tel;
Phone(String name, String tel) {
this.name = name;
this.tel = tel;
}
public String getName() {
return name;
}
public String getTel() {
return tel;
}
}
public class PhoneBook {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Phone phone[];
int i;
System.out.print("인원수 >> ");
int num = sc.nextInt();
phone = new Phone[num];
for(i=0; i<phone.length; i++) {
System.out.print("이름과 전화번호(이름과 번호는 빈 칸없이 입력)>>");
String name = sc.next();
String tel = sc.next();
phone[i] = new Phone(name, tel);
}
System.out.println("저장되었습니다...");
while(true) {
System.out.print("검색할 이름 >>");
String name = sc.next();
for(i=0; i<num; i++) {
if(name.equals(phone[i].getName())) {
System.out.println(name+"의 번호는 "+phone[i].getTel()+" 입니다.");
i--;
break;
}
}
if(name.equals("그만")) break;
if (i == num) System.out.println(name+"이 없습니다.");
}
sc.close();
}
}
-Xms128m
-Xmx750m
-XX:ReservedCodeCacheSize=512m
-XX:+IgnoreUnrecognizedVMOptions
-XX:+UseG1GC
-XX:SoftRefLRUPolicyMSPerMB=50
-XX:CICompilerCount=2
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-ea
-Dsun.io.useCanonCaches=false
-Djdk.http.auth.tunneling.disabledSchemes=""
-Djdk.attach.allowAttachSelf=true
-Djdk.module.illegalAccess.silent=true
-Dkotlinx.coroutines.debug=off
-Dconsole.encoding=UTF-8
-Dfile.encoding=UTF-8
我编写了打印韩文(韩文字母)的代码。但是当我运行它时,控制台显示奇怪的字母而不是韩文。例如,如果我写了 System.out.println("і");,则控制台显示 �� 而不是 Hanguel。
我已经尽力了。我将文件编码更改为 UFT-8,并在 vmoptions 上添加 -Dfile.encoding=UTF-8 和 -Dconsole.encoding=UTF-8 。我还尝试了重新启动IntelliJ IDEA、重新启动计算机、重新安装IntelliJ IDEA以及清理缓存多次。但一切都没有改变。我也尝试重建项目,但控制台显示 java: java.lang.IllegalArgumentException: 不支持发布版本 17。作为参考,我使用 openjdk-18。 IntelliJ IDEA的版本是2021.3.3。
+)我尝试了各种代码,但所有代码都没有显示韩文。上面的代码与我首先尝试的类似。
class Phone {
private String name;
private String tel;
Phone(String name, String tel) {
this.name = name;
this.tel = tel;
}
public String getName() {
return name;
}
public String getTel() {
return tel;
}
}
public class PhoneBook {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Phone phone[];
int i;
System.out.print("인원수 >> ");
int num = sc.nextInt();
phone = new Phone[num];
for(i=0; i<phone.length; i++) {
System.out.print("이름과 전화번호(이름과 번호는 빈 칸없이 입력)>>");
String name = sc.next();
String tel = sc.next();
phone[i] = new Phone(name, tel);
}
System.out.println("저장되었습니다...");
while(true) {
System.out.print("검색할 이름 >>");
String name = sc.next();
for(i=0; i<num; i++) {
if(name.equals(phone[i].getName())) {
System.out.println(name+"의 번호는 "+phone[i].getTel()+" 입니다.");
i--;
break;
}
}
if(name.equals("그만")) break;
if (i == num) System.out.println(name+"이 없습니다.");
}
sc.close();
}
}
-Xms128m
-Xmx750m
-XX:ReservedCodeCacheSize=512m
-XX:+IgnoreUnrecognizedVMOptions
-XX:+UseG1GC
-XX:SoftRefLRUPolicyMSPerMB=50
-XX:CICompilerCount=2
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-ea
-Dsun.io.useCanonCaches=false
-Djdk.http.auth.tunneling.disabledSchemes=""
-Djdk.attach.allowAttachSelf=true
-Djdk.module.illegalAccess.silent=true
-Dkotlinx.coroutines.debug=off
-Dconsole.encoding=UTF-8
-Dfile.encoding=UTF-8
I wrote codes that print Hangeul(Korean letter). But when I run it, the console show strange letters instead of Hangeul. For example, If I wrote System.out.println("가");, the console show �� instead of Hanguel.
I did all of I can. I changed File encoding to UFT-8, and added -Dfile.encoding=UTF-8 and -Dconsole.encoding=UTF-8 on vmoptions. I also tried restarting IntelliJ IDEA, restarting computer, and reinstalling IntelliJ IDEA, and cleaning caches several times. But nothing is changed. I also tried rebuilding project, but the console showed me java: java.lang.IllegalArgumentException: release version 17 is not supported. For reference, I use openjdk-18. And the version of IntelliJ IDEA is 2021.3.3.
+)I tried various codes and all of them didn't show Hangeul. Above codes are alike what I tried first.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论