Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    private static String u_big = "U+";

    /*** this method transfer characters into unicode(U+****U+****...)
     * if bad input ,then return ""**
     *
     * s_input is a chinese or english string to be translated can not be null
     */
    private static String get_cnuni_out(String s_input) {
        int k = s_input.length();
        String res = "", ith = "";
        int ii, m;
        for (int i = 0; i < k; ++i) {
            ith = Integer.toHexString((int) (s_input.charAt(i)));
            m = ith.length();
            for (ii = 0; ii < 4 - m; ii++) {
                ith = "0" + ith;
            }
            res = res + u_big + ith;
        }
        return res;
    }
}