當前位置:首頁 » 編程語言 » java中文unicode

java中文unicode

發布時間: 2022-08-31 16:12:21

java如何將一段漢字變成unicode碼

publicclassT{
publicstaticvoidmain(String[]args){
Strings="我愛你";
System.out.println(string2Unicode(s));
}
(Stringstring){

StringBufferunicode=newStringBuffer();

for(inti=0;i<string.length();i++){

//取出每一個字元
charc=string.charAt(i);

//轉換為unicode
unicode.append("\u"+Integer.toHexString(c));
}

returnunicode.toString();
}
}

❷ java 中常用漢字 的unicode 碼范圍是多少到多少

常用漢字 的unicode 碼范圍是:u4e00-u9fa5,下面一個例子是把中英文文檔中的漢字提取出來的簡單例子:

publicclassDrawEnglish
{
privatestaticStringdraw(Stringcontent)
{
StringBufferenglish=newStringBuffer();

Stringregex="[u4e00-u9fa5。,?」「《》:!——-、]";
Patternpattern=Pattern.compile(regex);
Matchermatcher=pattern.matcher(content);
while(matcher.find())
{
Stringtemp=matcher.group();
english.append(temp);
}
returnenglish.toString();
}
publicstaticvoiddrawEnglish(Stringpath)
{
FileInputStreamfr;
BufferedReaderbr;

FileWriterfw;
BufferedWriterbw=null;
try
{
fr=newFileInputStream(path);
br=newBufferedReader(newInputStreamReader(fr,"gb2312"));
fw=newFileWriter("new1.txt");
bw=newBufferedWriter(fw);
Stringstr=null;
StringBuffersb=newStringBuffer();
while((str=br.readLine())!=null)
{
sb.append(str+" ");
}
Stringtemp=draw(sb.toString());
bw.write(temp);

}catch(FileNotFoundExceptione)
{
e.printStackTrace();
}catch(IOExceptione)
{
e.printStackTrace();
}
finally
{
try
{
if(bw!=null)bw.close();
}catch(IOExceptione)
{
e.printStackTrace();
}
}
}
publicstaticvoidmain(String[]args)
{
drawEnglish("draw1.txt");
}
}

❸ 編寫JAVA程序輸出中文字的unicode編碼

我寫的,你試試,你可以把它改寫成循環的,可以一直把字元的Unicode輸出,完善後發給我哈:
import java.io.*;
public class FindUnicode {
public static void main(String[] args) throws IOException{
InputStreamReader read = new InputStreamReader (System.in);
int ch = read.read();
System.out.print("\\u"+Integer.toHexString(ch));
read.close();
}
}

❹ 用java如何把unicode碼轉成漢字

java中將unicode碼轉換成漢字的方式是直接使用string類型,列印即可:

Stringascii="u4f01u4e1a";//這兩個unicode碼就是企業的
System.out.println(ascii);//列印出來

運行結果:

企業

Unicode只有一個字元集,中、日、韓的三種文字佔用了Unicode中0x3000到0x9FFF的部分 Unicode目前普遍採用的是UCS-2,它用兩個位元組來編碼一個字元, 比如漢字"經"的編碼是0x7ECF,注意字元編碼一般用十六進制來 表示,為了與十進制區分,十六進制以0x開頭,0x7ECF轉換成十進制 就是32463,UCS-2用兩個位元組來編碼字元,兩個位元組就是16位二進制, 2的16次方等於65536,所以UCS-2最多能編碼65536個字元。

❺ java中如何取得中文如「中國」在unicode編碼中的表示串

public class Demo
{
public static void main(String[] args)
{
String str="例子";
//數組bm保存的就是"例子"的Unicode代碼點(10進制)
int[] bm=new int[str.length()];

for(int i=0;i<str.length();i++)
{
bm[i]=str.codePointAt(i);
System.out.print(""+bm[i]+" ");
}
}
}

❻ java中Unicode到底是什麼啊

UNICODE和ASCII是一個意思 只不過他們在對字元進行表達的時候 長度不同 ASCII是美國編碼 UNICODE是統一編碼, UNICODE其實就是ASCII的擴充,因為互諒網的發展ASCII無法滿足(因為ASCII是單位元組的,容量有限)全世界的各種字元,因此要更大的更統一的編碼,於是出現了 UNICODE 。說白了 就是的設計缺陷。等以後發現外星人了,估計還要宇宙統一代碼 呵呵

❼ java中如何在中文字元和unicode編碼之間進行轉換

可以這樣來重構字元串new String(「XXX".getByte(),」UTF-8「);後面加上編碼方式

熱點內容
加密殼sdk 發布:2025-05-12 07:38:29 瀏覽:509
電腦網線通伺服器 發布:2025-05-12 07:34:59 瀏覽:679
訪問法概念 發布:2025-05-12 07:27:14 瀏覽:406
遺傳演算法例子 發布:2025-05-12 07:27:11 瀏覽:266
matlab語言編程 發布:2025-05-12 07:05:16 瀏覽:482
解壓油畫棒 發布:2025-05-12 06:56:56 瀏覽:716
如何安裝語言編譯器 發布:2025-05-12 06:55:05 瀏覽:300
c語言程序設計題目 發布:2025-05-12 06:46:46 瀏覽:712
虛擬機上傳文件 發布:2025-05-12 06:41:52 瀏覽:572
編程模特 發布:2025-05-12 06:41:51 瀏覽:271