半角数字を丸数字に変換

by undo
♥1 | Line 28 | Modified 2012-04-25 12:01:44 | MIT License
play

ActionScript3 source code

/**
 * Copyright undo ( http://wonderfl.net/user/undo )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/p7ip
 */

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >
    <mx:Script>
        <![CDATA[
            /**
             * 1を①に、2を②に変換する誰得スクリプト
             * ただし0は⑩に
             */
            private function clickHandler():void {
                var arry:Array = this.ti.text.split("");
                
                for(var j:int = 0; j < arry.length; j++)
                {
                    var ch:String = arry[j];
                    
                    var charCode:Number = ch.charCodeAt(0);
                    if(charCode == 48)
                    {
                        arry[j] = '⑩';
                    }
                    else if(charCode >= 49 && charCode <= 57)
                    {
                        arry[j] = String.fromCharCode(charCode+9263);
                    }
                }
                
                var result:String = arry.join('');
                
                this.out.text = result;
            }
            
        ]]>
    </mx:Script>
    <mx:TextInput id="ti" width="100%" text="1234567890" />
    <mx:Button label="↓変換↓" click="this.clickHandler()" keyDown="this.clickHandler()" />
    <mx:TextArea text="" id="out" width="100%" height="100%" />
</mx:Application>