Java realizes __java_string of Chinese character to Unicode and Chinese character turning 16

Source: Internet
Author: User

In this paper, the realization method of realizing the conversion of Chinese characters into Unicode and the 16 Chinese characters by Java is described. Share to everyone for your reference. The implementation methods are as follows:

First, Chinese characters to Unicode

public static string Tounicode (string s)

{

string as[] = new String[s.length ()];

String S1 = "";

for (int i = 0; i < s.length (); i++)

{

As[i] = integer.tohexstring (S.charat (i) & 0xFFFF            );

S1 = S1 + as[i]+ "T";

return

s1;

}

Two, the Chinese character turns 16 to enter the system

public static string Tochinesehex (string s)

{

string ss = S;

byte[] bt = Ss.getbytes ();

String S1 = "";

for (int i = 0; i < bt.length i++)

{

String tempstr = integer.tohexstring (bt[i));

if (Tempstr.length () > 2)

tempstr = tempstr.substring (Tempstr.length ()-2);

S1 = S1 + tempstr + "";

}

return S1.touppercase ();

}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.