Java String to DBC toDBC(String s)

Here you can find the source of toDBC(String s)

Description

to DBC

License

Apache License

Declaration

public static String toDBC(String s) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static String toDBC(String s) {
        if (isEmpty(s)) {
            return s;
        }/*from   w w  w.  ja  v a 2 s. c o  m*/
        char[] chars = s.toCharArray();
        for (int i = 0, len = chars.length; i < len; i++) {
            if (chars[i] == 12288) {
                chars[i] = ' ';
            } else if (65281 <= chars[i] && chars[i] <= 65374) {
                chars[i] = (char) (chars[i] - 65248);
            } else {
                chars[i] = chars[i];
            }
        }
        return new String(chars);
    }

    public static boolean isEmpty(CharSequence s) {
        return s == null || s.length() == 0;
    }

    public static int length(CharSequence s) {
        return s == null ? 0 : s.length();
    }
}

Related

  1. ToDBC(String input)
  2. toDBC(String input)