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 显示特殊字符


基础教程推荐
- Struts2 URL 无法访问 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01