Android String Decode decode(String s)

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

Description

decode

Declaration

public static String decode(String s) 

Method Source Code

//package com.java2s;

public class Main {
    public static String decode(String s) {
        StringBuffer stringbuffer = new StringBuffer();
        int i = s.length();
        byte byte0 = -1;
        int l = 0;
        int i1 = 0;
        int j1 = -1;
        for (; i1 < i; i1++) {
            int j;
            int k;
            switch (j = s.charAt(i1)) {
            case 37: // '%'
                j = s.charAt(++i1);//ww  w  .java2 s  .c  o  m
                int k1 = (Character.isDigit((char) j) ? j - 48
                        : (10 + Character.toLowerCase((char) j)) - 97) & 0xf;
                j = s.charAt(++i1);
                int l1 = (Character.isDigit((char) j) ? j - 48
                        : (10 + Character.toLowerCase((char) j)) - 97) & 0xf;
                k = k1 << 4 | l1;
                break;

            case 43: // '+'
                k = 32;
                break;

            default:
                k = j;
                break;

            }
            if ((k & 0xc0) == 128) {
                l = l << 6 | k & 0x3f;
                if (--j1 == 0)
                    stringbuffer.append((char) l);
            } else if ((k & 0x80) == 0)
                stringbuffer.append((char) k);
            else if ((k & 0xe0) == 192) {
                l = k & 0x1f;
                j1 = 1;
            } else if ((k & 0xf0) == 224) {
                l = k & 0xf;
                j1 = 2;
            } else if ((k & 0xf8) == 240) {
                l = k & 0x7;
                j1 = 3;
            } else if ((k & 0xfc) == 248) {
                l = k & 0x3;
                j1 = 4;
            } else {
                l = k & 0x1;
                j1 = 5;
            }
        }

        return stringbuffer.toString();
    }
}

Related

  1. decode(String str)
  2. decode(String s)
  3. decode(String str)
  4. decode(String base64)
  5. decodeYUV420SPQuarterRes(int[] rgb, byte[] yuv420sp, int width, int height)