Android Unicode Convert fullWidthToHalfWidth(String s)

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

Description

full Width To Half Width

Declaration

public static String fullWidthToHalfWidth(String s) 

Method Source Code

//package com.java2s;

public class Main {

    public static String fullWidthToHalfWidth(String s) {
        if (isEmpty(s)) {
            return s;
        }/*from   ww w  .  j  a  va2  s  .c  o  m*/

        char[] source = s.toCharArray();
        for (int i = 0; i < source.length; i++) {
            if (source[i] == 12288) {
                source[i] = ' ';
                // } else if (source[i] == 12290) {
                // source[i] = '.';
            } else if (source[i] >= 65281 && source[i] <= 65374) {
                source[i] = (char) (source[i] - 65248);
            } else {
                source[i] = source[i];
            }
        }
        return new String(source);
    }

    /**
     * is null or its length is 0
     * 
     * <pre>
     * isEmpty(null) = true;
     * isEmpty(&quot;&quot;) = true;
     * isEmpty(&quot;  &quot;) = false;
     * </pre>
     * 
     * @param str
     * @return if string is null or its size is 0, return true, else return false.
     */
    public static boolean isEmpty(String str) {
        return (str == null || str.length() == 0);
    }
}

Related

  1. zenkakuToHankaku(String value)
  2. ToDBC(String input)
  3. unicodePreservingIndex(String paramString, int paramInt)
  4. unicodePreservingIndex(String str, int index)
  5. getEncodedSize(String value)
  6. halfWidthToFullWidth(String s)
  7. bytes2StringUNICODE(byte[] buf, int offset, int length, boolean bigEndian)
  8. asciiToBCD(byte[] ascii_buf, int asc_offset, byte[] bcd_buf, int bcd_offset, int conv_len, int type)