Display special characters using System.out.println(使用 System.out.println 显示特殊字符)
问题描述
我在从我的网络服务向我的数据库发送或显示带有特殊字符的文本时遇到问题.在我的日食中,我已将字符编码设置为 UTF-8,但它仍然不允许我显示字符.例如一个简单的打印,如下面的代码
I'm having trouble sending or displaying text with special characters from my webservice to my database. On my eclipse I have set the character encoding to UTF-8 but it still doesn't let me display the characters. For example a simple print like the code below
String test ="привет";
System.out.println(test);
或
String test ="привет";
String query = "insert into communication (`test`) VALUES ('"+ test +"');
PreparedStatement preparedStmt1 = con.prepareStatement(query);
preparedStmt1.executeUpdate();
控制台上的结果,如果我将其发送到我的数据库是 ??????.如何让它在控制台上正确显示并希望在数据库中显示
The result on the console and if I send this to my database is ??????. How do I get this to display correctly on the console and hopefully in the database
推荐答案
是的,它是 XXI.世纪以来,我们仍在努力解决诸如字符编码之类的问题...
Yeah, its the XXI. century and we're still struggling with things like character encoding...
我的第一个猜测是:
- 您的源文件编码可能有误(您是否使用了 Maven 之类的构建工具?可能还需要在那里设置源编码),
- 您的控制台编码可能有误(您是在 Windows 下吗?默认的命令行控制台默认不是 UTF,它依赖于本地,但您可以在注册表中稍微设置一下它的编码)
- 您的数据库编码可能不正确(表编码是什么,您能检查一下吗?)
这篇关于使用 System.out.println 显示特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 System.out.println 显示特殊字符


基础教程推荐
- Java:带有char数组的println给出乱码 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 降序排序:Java Map 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01