问题描述
在我的swing应用程序中,我将从数据库显示hindi unicode charecters。
当我显示名称时,它显示为原样,而不是作为一个印度字符串。
In my swing application I am going to display hindi unicode charecters from the database.When I am displaying name, it showing as it is, not as a hindi string.
但是当我将它硬编码到程序中时,它显示正确。问题是什么。从数据库获取数据时是否有任何charecter编码选项。我使用oracle xe与Netbeans。
But when I hardcoded it into the program it is showing correctly. What is the problem. Is there any charecter encoding option while getting the data from database. I am using oracle xe with Netbeans.
String name = rs.getString("name");
jLabel1.setText(name);
这里显示unicode charecters。
但这里
Here it displaying unicode charecters as it is.But here
String name = "\u0938\u093e\u092e\u093e\u0928\u094d\u092f";
jLabel1.setText(name);
它显示正确。问题在哪里。
It showing correctly. Where is the problem.
推荐答案
问题在于Oracle使用的编码。您必须将其设置为在数据库中使用UTF-8。很遗憾,您无法在JDBC类中修复此问题。
The issue lies in the encoding that Oracle is using. You have to set it up to use UTF-8 in the database as well. Unfortunately, you can't fix this in the JDBC classes.
这篇关于ResultSet getString unicode charecters的字符编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!