Browse Source

added fromCharCode.

Nicolas Cannasse 19 years ago
parent
commit
3541d67d9b
3 changed files with 10 additions and 14 deletions
  1. 1 13
      std/Std.hx
  2. 3 1
      std/String.hx
  3. 6 0
      std/neko/NekoString__.hx

+ 1 - 13
std/Std.hx

@@ -131,19 +131,7 @@ class Std {
 		Convert a character code into the corresponding single-char String.
 		Convert a character code into the corresponding single-char String.
 	**/
 	**/
 	public static function chr( x : Int ) : String {
 	public static function chr( x : Int ) : String {
-		return untyped
-		#if flash
-		String["fromCharCode"](x);
-		#else neko
-		{
-			var s = __dollar__smake(1);
-			__dollar__sset(s,0,x);
-			new String(s);
-		}
-		#else js
-		String.fromCharCode(x);
-		#else error
-		#end
+		return String.fromCharCode(x);
 	}
 	}
 
 
 	/**
 	/**

+ 3 - 1
std/String.hx

@@ -53,7 +53,7 @@ extern class String {
 		Returns the empty String if outside of String bounds.
 		Returns the empty String if outside of String bounds.
 	**/
 	**/
 	function charAt( index : Int) : String;
 	function charAt( index : Int) : String;
-	
+
 	/**
 	/**
 		Returns the character code at the given position.
 		Returns the character code at the given position.
 		Returns [null] if outside of String bounds.
 		Returns [null] if outside of String bounds.
@@ -89,4 +89,6 @@ extern class String {
 	**/
 	**/
 	function toString() : String;
 	function toString() : String;
 
 
+	static function fromCharCode( code : Int ) : String;
+
 }
 }

+ 6 - 0
std/neko/NekoString__.hx

@@ -170,4 +170,10 @@ class NekoString__ implements String {
 		return untyped new String(__dollar__string(s)+this.__s);
 		return untyped new String(__dollar__string(s)+this.__s);
 	}
 	}
 
 
+	static function fromCharCode( c : Int ) : String untyped {
+		var s = __dollar__smake(1);
+		__dollar__sset(s,0,x);
+		return new String(s);
+	}
+
 }
 }