javaunicode编码表(java输出全部unicode字符)
本文目录
- java输出全部unicode字符
- java中如何获得一个字符的unicode编码
- 怎样用J**A打印汉字的UNICODE代码
- java 中常用汉字 的unicode 码范围是多少到多少
- java中如何输出字符变量的Unicode编码值
- java中这种编码方式是什么
- java处理unicode字符
- java’好’ unicode编码值是多少
- java中字符转换成int是ascii码还是unicode码
java输出全部unicode字符
Java显示所有的Unicode 字符,代码主要是使用*****
的drawChars()方法,来绘出Unicode 字符。在设计符合国际化的程序过程当中,仅仅能够显示本地字符是不够的,只用Unicode
字符集才能够满足同时显示多国语言字符的需要。本实例实现了如何显示Unicode 字符的方法。
Java显示所有Unicode 字符编写方法:
1.编写UnicodeDisplay 类,该类继承了Jframe 类,实现了ActionListener
接口,该类是为了显示一个图形化的界面而实现的一个显示框架类,该类负责初始化显示窗口以及负责与用户交互,按照用户指定的字体以及风格改变
Unicode 的显示,代码如下:
// 导入所需要的Java 类库
import *****.*;
import *****.*;
import *****.*;
public class UnicodeDisplay extends JFrame implements ActionListener {
int page = 0;
UnicodePanel p;
JScrollBar b;
String fontfamily = "Serif";
int fontstyle = *****;
/*构造函数,创建frame、菜单和滚动条*/
public UnicodeDisplay(String name) {
super(name);
p = new UnicodePanel(); // 创建panel
*****((char)(page * 0x100)); // 初始化panel
getContentPane().add(p, "Center"); // 使其居中
// Create and set up a scrollbar, and put it on the right
b = new JScrollBar(*****, 0, 1, 0, 0xFF);
*****(1);
*****(0x10);
*****(new AdjustmentListener() {
public void adjustmentValueChanged(AdjustmentEvent e) {
page = *****();
*****((char)(page * 0x100));
}
});
getContentPane().add(b, "East");
// 设置消息响应函数处理关闭窗口请求
*****(new WindowAdapter() {
public void windowClosing(WindowEvent e) { *****(0); }
});
// 响应PageUP、PageDown、Up 和Down 按键
*****(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
int code = *****();
int oldpage = page;
if ((code == *****_PAGE_UP) ||
(code == *****_UP)) {
if (*****()) page -= 0x10;
else page -= 1;
if (page 《 0) page = 0;
}
else if ((code == *****_PAGE_DOWN) ||
(code == *****_DOWN)) {
if (*****()) page += 0x10;
else page += 1;
if (page 》 0xff) page = 0xff;
}
if (page != oldpage) { //如果改变了当前显示页
*****((char) (page * 0x100)); // 更新显示
*****(page); // 更新滚动条
}
}
});
// 建立可以改变显示字体的菜单.
JMenuBar menubar = new JMenuBar();
*****(menubar);
*****(makemenu("Font Family",
new String {"Serif", "SansSerif", "Monospaced"},
this));
*****(makemenu("Font Style",
new String{
"Plain","Italic","Bold","BoldItalic"
}, this));
}
2.ActionPerformed()方法用于处理子菜单当中的各个选项:
public void actionPerformed(ActionEvent e) {
String cmd = *****();
if (*****("Serif")) fontfamily = "Serif";
else if (*****("SansSerif")) fontfamily = "SansSerif";
else if (*****("Monospaced")) fontfamily = "Monospaced";
else if (*****("Plain")) fontstyle = *****;
else if (*****("Italic")) fontstyle = *****;
else if (*****("Bold")) fontstyle = *****;
else if (*****("BoldItalic")) fontstyle = ***** + *****;
*****(fontfamily, fontstyle);
}
3.Makemenu()方法用于从数组当中创建菜单,代码如下:
private Jmenu makemenu(String name, String itemnames,
ActionListener listener)
{
Jmenu m = new Jmenu(name);
for(int I = 0; I 《 *****; I++) {
JmenuItem item = new JmenuItem(itemnames);
*****(listener);
*****(itemnames);
*****(item);
}
return m;
}
4.编写UnicodePanel 类,该类继承了Jcomponent,创建负责显示Unicode 的类UnicodePanel,它负责绘出一页(共有16×16=256 个)的Unicode 字符:
public static class UnicodePanel extends JComponent {
protected char base; // 指定我们显示的初始值
protected Font font = new Font("serif", *****, 18); // 指定缺省的显示字体
protected Font headingfont = new Font("monospaced", *****, 18); // 指定缺省表头字体
static final int lineheight = 25; // 指定显示一行高度
static final int charspacing = 20; // 指定显示一个Unicode 字符宽度
static final int x0 = 65;
static final int y0 = 40;
/** 指定开始显示的初始字符并且刷新Panel */
public void setBase(char base) {
***** = base;
repaint();
}
/**设定显示所用的新字体或者风格并且刷新Panel */
public void setFont(String family, int style) {
***** = new Font(family, style, 18);
repaint();
}
/** 绘出字符表的一页 */
public void paintComponent(Graphics g) {
int start = (int)base & 0xFFF0; // 设置起始显示字符
// 使用给定字体显示表头
*****(headingfont);
// 在顶端绘出0..F
for(int i=0; i 《 16; i++) {
String s = *****(i, 16);
*****(s, x0 + i*charspacing, y0-20);
}
// 绘出左边表头.
for(int i = 0; i 《 16; i++) {
int j = start + i*16;
String s = *****(j, 16);
*****(s, 10, y0+i*lineheight);
}
// 绘出Unicode 字符
*****(font);
char;
for(int i = 0; i 《 16; i++) {
for(int j = 0; j 《 16; j++) {
c = (char)(start + j*16 + i);
*****(c, 0, 1, x0 + i*charspacing, y0+j*lineheight);
}
}
}
/** 返回给定的分辨率 */
public Dimension getPreferredSize() {
return new Dimension(x0 + 16*charspacing,
y0 + 16*lineheight);
}
}
}
java中如何获得一个字符的unicode编码
java中可以使用char类提供的charAt()方法来获得字符的unicode的编码值,示例如下:
public static String getUnicode(String source){ String returnUniCode=null; String uniCodeTemp=null; for(int i=0;i《*****();i++){ uniCodeTemp = "\\u"+*****((int)*****(i));//使用char类的charAt()的方法 returnUniCode=returnUniCode==null?uniCodeTemp:returnUniCode+uniCodeTemp; } *****(source +" ’s unicode = "+returnUniCode); return returnUniCode;//返回一个字符的unicode的编码值}
怎样用J**A打印汉字的UNICODE代码
/**
* 字符串转换unicode
*/
public static String string2Unicode(String string) {
StringBuffer unicode = new StringBuffer();
for (int i = 0; i 《 *****(); i++) {
// 取出每一个字符
char c = *****(i);
// 转换为unicode
*****("\\u" + *****(c));
}
return *****();
}
/**
* unicode 转字符串
*/
public static String unicode2String(String unicode) {
StringBuffer string = new StringBuffer();
String hex = *****("\\\\u");
for (int i = 1; i 《 *****; i++) {
// 转换出每一个代码点
int data = *****(hex, 16);
// 追加成string
*****((char) data);
}
return *****();
}
java 中常用汉字 的unicode 码范围是多少到多少
常用汉字 的unicode 码范围是:\u4e00-\u9fa5,下面一个例子是把中英文文档中的汉字提取出来的简单例子:
public class DrawEnglish
{
private static String draw(String content)
{
StringBuffer english = new StringBuffer();
String regex = "";
Pattern pattern = *****(regex);
Matcher matcher = *****(content);
while(*****())
{
String temp = *****();
*****(temp);
}
return *****();
}
public static void drawEnglish(String path)
{
FileInputStream fr;
BufferedReader br;
FileWriter fw;
BufferedWriter bw = null ;
try
{
fr = new FileInputStream(path);
br = new BufferedReader(new InputStreamReader(fr,"gb2312"));
fw = new FileWriter("*****");
bw = new BufferedWriter(fw);
String str = null;
StringBuffer ** = new StringBuffer();
while((str = *****()) != null)
{
**.append(str + "\n");
}
String temp = draw(**.toString());
*****(temp);
} catch (FileNotFoundException e)
{
*****();
} catch (IOException e)
{
*****();
}
finally
{
try
{
if(bw != null) *****();
} catch (IOException e)
{
*****();
}
}
}
public static void main(String args)
{
drawEnglish("*****");
}
}
java中如何输出字符变量的Unicode编码值
java中可以使用char类提供的charAt()方法来获得字符的unicode的编码值,示例如下:
扩展资料:
Java是一门面向对象编程语言,不仅吸收了C++语言的各种优点,还摒弃了C++里难以理解的多继承、指针等概念,因此Java语言具有功能强大和简单易用两个特征。Java语言作为静态面向对象编程语言的代表,极好地实现了面向对象理论,允许程序员以优雅的思维方式进行复杂的编程。
Java具有简单性、面向对象、分布式、健壮性、安全性、平**立与可移植性、多线程、动态性等特点。Java可以编写桌面应用程序、Web应用程序、分布式系统和嵌入式系统应用程序等。
参考资料:百度百科-java
java中这种编码方式是什么
这是Unicode编码,你只要把它按下面方法打印即可:
String s="\u8c01\u80fd\u591f\u7ed9\u6211\u98ce\u9669\u6295\u8d44\u54e6!\u6211\u60f3\u501f\u5341\u4e07\u529e\u4e00\u4e2a\u517b\u6b96\u5382\u3002\u6211\u53ef\u662f\u6709\u5bb6\u5ead\u62c5\u4fdd\u7684\u54e6!#\u4e0a\u7f51\u7231\u901b\u4ec0\u4e48#";
*****(s);
打印出:
谁能够给我风险投资哦!我想借十万办一个养殖厂。我可是有家庭担保的哦!#上网爱逛什么#
java处理unicode字符
unicode编码简而言之就是将每一个字符用16位2进制数标识。但是通常都用4位的16进制数标识。
例如:
1)中文字符串"你好"的unicode码为:\u60\u597d;
2)英文字符串"ab"的unicode码为:\u0061\u0062;
其中\u是标识unicode码用的,后面的4位16进制数则是对应字符的unicode码。
unicode码在J2EE项目中应用广泛,java对unicode码提供了很好的支持。例如国际化,则是unicode的经典运用。
那么unicode的编码规则具体是什么,如何用程序实现?
1、unicode编码规则
unicode码对每一个字符用4位16进制数表示。具体规则是:将一个字符(char)的高8位与低8位分别取出,转化为16进制数,
如果转化的16进制数的长度不足2位,则在其后补0,然后将高、低8位转成的16进制字符串拼接起来并在前面补上"\u" 即可。
2、转码程序
1)字符串转unicode
/**
* 将字符串转成unicode
* @param str 待转字符串
* @return unicode字符串
*/
public String convert(String str)
{
str = (str == null ? "" : str);
String tmp;
StringBuffer ** = new StringBuffer(1000);
char c;
int i, j;
**.setLength(0);
for (i = 0; i 《 *****(); i++)
{
c = *****(i);
**.append("\\u");
j = (c 》》》8); //取出高8位
tmp = *****(j);
if (*****() == 1)
**.append("0");
**.append(tmp);
j = (c & 0xFF); //取出低8位
tmp = *****(j);
if (*****() == 1)
**.append("0");
**.append(tmp);
}
return (new String(**));
}
2)unicode转成字符串,与上述过程反向操作即可
/**
* 将unicode 字符串
* @param str 待转字符串
* @return 普通字符串
*/
public String revert(String str)
{
str = (str == null ? "" : str);
if (*****("\\u") == -1)//如果不是unicode码则原样返回
return str;
StringBuffer ** = new StringBuffer(1000);
for (int i = 0; i 《 *****() - 6;)
{
String strTemp = *****(i, i + 6);
String value = *****(2);
int c = 0;
for (int j = 0; j 《 *****(); j++)
{
char tempChar = *****(j);
int t = 0;
switch (tempChar)
{
case ’a’:
t = 10;
break;
case ’b’:
t = 11;
break;
case ’c’:
t = 12;
break;
case ’d’:
t = 13;
break;
case ’e’:
t = 14;
break;
case ’f’:
t = 15;
break;
default:
t = tempChar - 48;
break;
}
c += t * ((int) *****(16, (*****() - j - 1)));
}
**.append((char) c);
i = i + 6;
}
return **.toString();
}
java’好’ unicode编码值是多少
是\u597d
以下是用java转化得到unicode的代码,可以转化字符串。
public class Test {
public static void main(String args){
String index = "好";
for (int i = 0; i 《 *****(); i++) {
int u = (int)*****(0);
String hex = *****(u);
*****("\\u"+hex + "\t");
}
*****("\u597d");
}
}
java中字符转换成int是ascii码还是unicode码
Unicode。
1、将世界所有符号都包含了,包括ASCII码中的符号。
2、编号范围:0x000000 到 0xFFFFFF(十六进制),有110多万。
3、每个字符都有唯一Unicode编码,一般写成16进制,在前面加上U+, 例如:’马‘ 的Unicode是 U+9A6C 。J**A底层采用Unicode编码来存储字符。
更多文章:
originos系统下载安装(iqooneo3能升级originos3吗)
2026年5月6日 21:20
谭浩强第二版完整答案(请问谁有c语言程序设计(第二版)课后习题答案,谭浩强的)
2026年5月6日 21:00
javaunicode编码表(java输出全部unicode字符)
2026年5月6日 20:20
数据库原理及应用试题(数据库原理与应用的一道综合应用题,用**L语句解答 急!!! 微信发红包)
2026年5月6日 20:00
pycharm下载社区版(pycharm同时安装社区版和专业版会怎么样)
2026年5月6日 19:20
linux怎么用c语言(要怎么在linux系统中编译并运行c程序)
2026年5月6日 19:00
渐变构成作品图片(想找张平面构成作业,要求同时表现渐变发射的,急求!!!)
2026年5月6日 18:40




