﻿    //todo:add other characters
    var main_start = 0xff01;//unicode value of starting character
    var main_end =0xff5e;//unicode value of ending character
    var main_subtract = 0xfee0;//constant value

    //space character
    var full_space = 0x3000;
    var half_space = 0x20;
    
    //width special character
    var other_src = new Array(0x3002,0x300C,0x300D,0x3001,0xFF70,0x30FC,0x2015,0x2010,0x30FB);
    //half width special character
    var other_des = new Array(0x2E,0x5B,0x5D,0x2C,0x2D,0x2D,0x2D,0x2D,0x2F);
    
    function partMulti2ASC(str)
    {
        var result = '';
        for (var i=0 ; i<str.length; i++)
        {
            code = str.charCodeAt(i);//get unicode value of current character
            if (code >= main_start && code <= main_end)//convert all alpha-number and simple punctuation
            {
                //full-width character unicode value subtracts a constant to get half width character unicode 
                //and parse it to character
                result += String.fromCharCode(code - main_subtract);
            }
            else
            {
                if(code == full_space)
                {
                     result += String.fromCharCode(half_space);
                }
                else
                {
                     result += str.charAt(i);
                }
            }
        }
        return result;
    }
    
    //first convert en alphanumber,then simple punctuation,last special punctuation
    function wholeMulti2ASC(str)
    {
        var partResult = partMulti2ASC(str);
        var result = '';
        outer:
        for(var i=0; i<partResult.length; i++)
        {
            code = partResult.charCodeAt(i);//get unicode value of current character
            for(var j=0; j<other_src.length; j++)
            {
                if(other_src[j] == code)
                {
                    result+=String.fromCharCode(other_des[j]);
                    continue outer;
                }
            }
            result += partResult.charAt(i);
        }
        return result;
    }
