Skip to content

t4ku/urlencode-as3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

urlencode-as3

Actionscript library to handle percent encoding/decoding.

Description

I often encounter a situation where percent encoding is done in the charset other than UTF-8 ouside of actionscript(especially at server side), and built-in methods like escape/unescape or escapeMultiByte/unecapeMutliByte doesn't help since they only support UTF-8 or charset specified in System.useCodePage.

Usage

import urlencode.URIString;

public function doSomething():void{

    var reqUrl:String="http://example.com?msg=%93%FA%96%7B%8C%EA";
    var aryParams:Array = reqUrl.replace(/.*\?(.*)/,"$1").split("&");
    var params:Object = {};

    for(var i:int=0;i < aryParams.length;i++){
        var key:String = aryParams[i].split("=")[0];
        var val:String = aryParams[i].split("=")[1];
        params[key]= val;
    }
    trace(params["msg"]); // "%93%FA%96%7B%8C%EA"

    var decoder:URIString = new URIString(params["msg"]);
    trace(decoder.decode(URIString.SHIFT_JIS)); // "日本語"

}

TODO

  • Add escape(encode) function(Only SHIFT_JIS unescaping has been implemented so far...).
  • Add charsets support other than SHIFT_JIS.

About

handles percent encoding in charsets other than UTF-8 (SJIS,EUC etc)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published