Java GBK String Convert getGBKByteLength(String data)

Here you can find the source of getGBKByteLength(String data)

Description

get GBK Byte Length

License

Open Source License

Declaration

public static int getGBKByteLength(String data) 

Method Source Code


//package com.java2s;
import java.io.UnsupportedEncodingException;

public class Main {

    public static int getGBKByteLength(String data) {
        if (data == null) {
            return 0;
        }/*from w  ww.j  a  v a  2 s.c  o m*/
        try {
            return data.getBytes("GBK").length;
        } catch (UnsupportedEncodingException e) {
            return data.getBytes().length;
        }
    }
}

Related

  1. gbk2iso(String s)
  2. gbk2Iso(String str)
  3. gbk2Utf8(String str)