Просмотр исходного кода

[php] minor fix of EReg.map for unicode strings and empty matches (#8861)

Aleksandr Kuzmenko 5 лет назад
Родитель
Сommit
860c0d70d5
2 измененных файлов с 2 добавлено и 2 удалено
  1. 1 1
      std/php/Boot.hx
  2. 1 1
      std/php/_std/EReg.hx

+ 1 - 1
std/php/Boot.hx

@@ -616,7 +616,7 @@ class Boot {
 	}
 	}
 
 
 	/**
 	/**
-		Get UTF-8 code of che first character in `s` without any checks
+		Get UTF-8 code of the first character in `s` without any checks
 	**/
 	**/
 	static public inline function unsafeOrd(s:NativeString):Int {
 	static public inline function unsafeOrd(s:NativeString):Int {
 		var code = Global.ord(s[0]);
 		var code = Global.ord(s[0]);

+ 1 - 1
std/php/_std/EReg.hx

@@ -158,7 +158,7 @@ import php.*;
 			result += f(this);
 			result += f(this);
 			bytesOffset = matches[0][1];
 			bytesOffset = matches[0][1];
 			if(matches[0][0] == '') {
 			if(matches[0][0] == '') {
-				result += Global.substr(s, bytesOffset, 1);
+				result += Global.mb_substr(Global.substr(s, bytesOffset), 0, 1);
 				bytesOffset++;
 				bytesOffset++;
 			} else {
 			} else {
 				bytesOffset += Global.strlen(matches[0][0]);
 				bytesOffset += Global.strlen(matches[0][0]);