简体   繁体   English

JAVA:如何将gujrati(其他语言)字体存储在字符串中?

[英]JAVA:How to store gujrati(its other language) font in string?

I have an application in java. 我在Java中有一个应用程序。

This application contains one text box and button. 该应用程序包含一个文本框和一个按钮。

Now I want to save Gujrati(other language)data in to database in click event of button. 现在我想在按钮单击事件中将Gujrati(其他语言)数据保存到数据库中。

How is it possible? 这怎么可能? Actually I done this think but my string return some other format. 实际上,我是这样做的,但是我的字符串返回了其他格式。 So i don't know how to store gujrati data in to string ? 所以我不知道如何将gujrati数据存储到字符串中?

This works in Java as long as source code is in a Unicode-defined encoding, such as UTF-8 or UTF-16: 只要源代码采用Unicode定义的编码(例如UTF-8或UTF-16),它就可以在Java中工作:

String ગઉજ = "ઋઊઘ";

That part solved, you need to specify where exactly your problem lies. 解决了那部分之后,您需要指定问题所在的确切位置。

Java works in Unicode. Java使用Unicode。 Gujarati characters have unicode values as shown here 古吉拉特语字符使用Unicode值,如图所示这里

You can directly store them in a string. 您可以将它们直接存储在字符串中。 However if you can't directly take Gujrati input you can use the character class like this 但是,如果您不能直接接受古吉拉特语输入,则可以使用这样的字符类

int c = 0x0A82;
String s = Character.toString((char)c);
//s is ં 

And so on 等等

There are some changes that you should make in you website 您应该在网站中进行一些更改

In JSP file change 在JSP文件中更改

<%@ page language="java" contentType="text/html; charset=UTF-16" pageEncoding="UTF-16"%>

and in .property file 并在.property文件中

save your text in uni-code format 以Unicode格式保存您的文本

Like this(here language of uni-code character is Gujarati 像这样(这里的Unicode字符的语言是古吉拉特语

global.Name = \ન\ા\મ global.Name = \\ u0AA8 \\ u0ABE \\ u0AAE

This will surely work as it worked for me in struts2 这肯定会在struts2中为我工作

output will be : 输出将是:

નામ નામ

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM