Flash / Flex / ActionScript/String/fromCharCode

Материал из Web эксперт
Перейти к: навигация, поиск

Converting Between Strings and Unicode or ASCII

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        trace( "New paragraph: " + String.fromCharCode( 182 ) );
        trace( "Cents: " + String.fromCharCode( 162 ) );
        trace( "Name: " + String.fromCharCode( 68, 97, 114, 114, 111, 110 ) );
    }
  }
}



Use String.frolmCharCode to create a string

 
package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var example:String = String.fromCharCode( 191 ) + String.fromCharCode( 243 ) 
                   + String.fromCharCode( 225 ) 
                   + String.fromCharCode( 241 );
        
        if ( example.charCodeAt( 0 ) == 191 ) {
          trace( "The string \"" + example + "\" has a \u00BF at the beginning." );
        }
    }
  }
}