Java Unicode Unicode2GBK(String dataStr)

Here you can find the source of Unicode2GBK(String dataStr)

Description

Unicode GBK

License

Apache License

Declaration

public static String Unicode2GBK(String dataStr) 

Method Source Code

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

public class Main {

    public static String Unicode2GBK(String dataStr) {
        int index = 0;
        StringBuffer buffer = new StringBuffer();

        int li_len = dataStr.length();
        while (index < li_len) {
            if (index >= li_len - 1 || !"\\u".equals(dataStr.substring(index, index + 2))) {
                buffer.append(dataStr.charAt(index));

                index++;//from www.  j a  v  a  2s.c o  m
                continue;
            }

            String charStr = "";
            charStr = dataStr.substring(index + 2, index + 6);

            char letter = (char) Integer.parseInt(charStr, 16);

            buffer.append(letter);
            index += 6;
        }

        return buffer.toString();
    }
}

Related

  1. unicode(String ipStr)
  2. unicode(String s)
  3. unicode(StringBuilder buf, char c)
  4. Unicode2ASCII(String unicode)
  5. unicode2Byte(String s)
  6. unicode2native(String s)
  7. unicodeChar(char a, char b, char c, char d)
  8. unicodeCodepointToString(char cp, boolean shortenIfPossible, String prefix, boolean upperCase)
  9. unicodeConvert(String str)