Browse Source

[cpp] Array.splice takes 'last', not 'len'

Hugh 11 years ago
parent
commit
aceb07b806
1 changed files with 3 additions and 1 deletions
  1. 3 1
      std/cpp/_std/haxe/Utf8.hx

+ 3 - 1
std/cpp/_std/haxe/Utf8.hx

@@ -90,7 +90,9 @@ class Utf8
 
 	public static function sub( s : String, pos : Int, len : Int ) : String {
       var array:Array<Int> = untyped __global__.__hxcpp_utf8_string_to_char_array(s);
-      var sub = array.slice(pos,len);
+      var last = len < 0 ? array.length : pos+len;
+      if (last>array.length) last = array.length;
+      var sub = array.slice(pos,last);
 		return untyped __global__.__hxcpp_char_array_to_utf8_string(sub);
 	}