Showing posts with label encode. Show all posts
Showing posts with label encode. Show all posts

Wednesday, September 11, 2013

HTTP RAW URL Address Encode in Java as application/x-www-form-urlencoded


package com.pritom.kumar;

import java.net.URLDecoder;
import java.net.URLEncoder;

public class RawUrlEncodeDecode {
    public static void main(String[] args) throws Exception{
        String toEncode = "a & b+c_d+e / é <p>Hello</p><?xml version='1.0'><name>Pritom K Mondal</name>";
        String encoded = URLEncoder.encode(toEncode, "UTF-8");
        System.out.println("Encoded: " + encoded);
        String decoded = URLDecoder.decode(encoded, "UTF-8");
        System.out.println("Decoded: " + decoded);
    }
}

Output

Encoded: a+%26+b%2Bc_d%2Be+%2F+%C3%A9+%3Cp%3EHello%3C%2Fp%3E%3C%3Fxml+version%3D%271.0%27%3E%3Cname%3EPritom+K+Mondal%3C%2Fname%3E

Decoded: a & b+c_d+e / é <p>Hello</p><?xml version='1.0'><name>Pritom K Mondal</name>

Tuesday, June 4, 2013

jQuery plugin base64 encode and decode

http://archive.plugins.jquery.com/project/base64-encode-and-decode
https://docs.google.com/file/d/0B5nZNPW48dpFSXRrYmttSU9aNmM/edit?usp=sharing

This code was collected from the network, I just represent this, the copyright belongs to original work(s).
Usage
Whether or not to use UNICODE library:
$.base64.is_unicode = false/true;
Encode:
$.base64.encode('$.base64');
Decode:
$.base64.decode('JC5iYXNlNjQ=');