Kaynağa Gözat

fixed String unicode comparison (close #250)

Nicolas Cannasse 6 yıl önce
ebeveyn
işleme
815855b1fc
2 değiştirilmiş dosya ile 12 ekleme ve 1 silme
  1. 7 0
      std/hl/Bytes.hx
  2. 5 1
      std/hl/_std/String.hx

+ 7 - 0
std/hl/Bytes.hx

@@ -91,6 +91,13 @@ package hl;
 		return 0;
 	}
 
+	#if (hl_ver >= version("1.10"))
+	@:hlNative("std","bytes_compare16")
+	public function compare16( bytes : Bytes, size : Int ) : Int {
+		return 0;
+	}
+	#end
+
 	@:hlNative("std","bytes_find")
 	public function find( pos : Int, size : Int, bytes : Bytes, bytesPos : Int, bytesSize : Int ) : Int {
 		return 0;

+ 5 - 1
std/hl/_std/String.hx

@@ -210,7 +210,11 @@ class String {
 		var s = Std.instance(v, String);
 		if( s == null )
 			return hl.Api.comparePointer(this, v);
-		var v = bytes.compare(0, s.bytes, 0, (length < s.length ? length : s.length) << 1);
+		#if (hl_ver >= version("1.10"))
+		var v = bytes.compare16(s.bytes, length < s.length ? length : s.length);		
+		#else
+		var v = bytes.compare(0, s.bytes, 0, (length < s.length ? length : s.length) << 1);		
+		#end
 		return v == 0 ? length - s.length : v;
 	}