Return to the BYTE string of Chinese Unicode

xiaoxiao2021-03-06  33

Work need such a function, the following is the implementation code, such as input "friends", the output / u0b67 / ucb53public class UnicodeByteUtil {public static void main (String [] args) {UnicodeByteUtil instance = new UnicodeByteUtil (); BufferedReader reader = new BufferedReader (NEW INPUTSTREAMREADER (System.IN)); string line; try {while ((line = reader.readline ())! = null) {if (line.trim (). Equals ("q")) System.exit 0); string s = instance.getbytes (line); system.out.println ("bytes:" s); //system.out.println ("line :" );}} catch (ooexception e) { E.PrintStackTrace ();}}

String getBytes (string s) {Try {stringbuffer out = new stringbuffer (""); byte [] bytes = s.getbytes ("unicode"); for (int i = 2; i

转载请注明原文地址:https://www.9cbs.com/read-64494.html

New Post(0)