Android Byte Array to Unicode Convert jisx0208ToString(byte[] b)

Here you can find the source of jisx0208ToString(byte[] b)

Description

jisx To String

Declaration

public static String jisx0208ToString(byte[] b) 

Method Source Code

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

public class Main {

    public static String jisx0208ToString(byte[] b) {
        return jisx0208ToString(b, 0, b.length);
    }/* w  ww .  ja va  2s.  c o m*/

    public static String jisx0208ToString(byte[] b, int offset, int len) {
        byte[] buf = new byte[len];
        // JISX0208 -> EUC-JP
        for (int i = 0; i < len; i++) {
            if (b[offset + i] != '\0') {
                buf[i] = (byte) (b[offset + i] | 0x80);
            } else {
                buf[i] = '\0';
            }
        }
        String str = null;
        try {
            str = new String(buf, "EUC-JP");
        } catch (UnsupportedEncodingException e) {
            str = new String(buf);
        }
        return str.trim();
    }
}

Related

  1. byteArrayLittleEndian2Int(byte[] bs)
  2. bytesToAsciiMaybe(byte[] data)
  3. bytesToAsciiMaybe(byte[] data, int offset, int length)
  4. lowerToUpper(byte[] b)
  5. lowerToUpperLatin(byte[] b)
  6. jisx0208ToString(byte[] b, int offset, int len)
  7. toBase58(byte[] b)
  8. ushort2bytesBE(int val, byte[] b, int off)
  9. ushort2bytesLE(int val, byte[] b, int off)