@@ -62,7 +62,7 @@ private function fn_contains(array $args)
6262 if (is_array ($ args [0 ])) {
6363 return in_array ($ args [1 ], $ args [0 ]);
6464 } elseif (is_string ($ args [1 ])) {
65- return strpos ($ args [0 ], $ args [1 ]) !== false ;
65+ return mb_strpos ($ args [0 ], $ args [1 ], 0 , ' UTF-8 ' ) !== false ;
6666 } else {
6767 return null ;
6868 }
@@ -72,7 +72,7 @@ private function fn_ends_with(array $args)
7272 {
7373 $ this ->validate ('ends_with ' , $ args , [['string ' ], ['string ' ]]);
7474 list ($ search , $ suffix ) = $ args ;
75- return $ suffix === '' || substr ($ search , -strlen ($ suffix) ) === $ suffix ;
75+ return $ suffix === '' || mb_substr ($ search , -mb_strlen ($ suffix, ' UTF-8 ' ), null , ' UTF-8 ' ) === $ suffix ;
7676 }
7777
7878 private function fn_floor (array $ args )
@@ -112,7 +112,7 @@ private function fn_keys(array $args)
112112 private function fn_length (array $ args )
113113 {
114114 $ this ->validate ('length ' , $ args , [['string ' , 'array ' , 'object ' ]]);
115- return is_string ($ args [0 ]) ? strlen ($ args [0 ]) : count ((array ) $ args [0 ]);
115+ return is_string ($ args [0 ]) ? mb_strlen ($ args [0 ], ' UTF-8 ' ) : count ((array ) $ args [0 ]);
116116 }
117117
118118 private function fn_max (array $ args )
@@ -207,7 +207,7 @@ private function fn_starts_with(array $args)
207207 {
208208 $ this ->validate ('starts_with ' , $ args , [['string ' ], ['string ' ]]);
209209 list ($ search , $ prefix ) = $ args ;
210- return $ prefix === '' || strpos ($ search , $ prefix ) === 0 ;
210+ return $ prefix === '' || mb_strpos ($ search , $ prefix, 0 , ' UTF-8 ' ) === 0 ;
211211 }
212212
213213 private function fn_type (array $ args )
@@ -240,7 +240,7 @@ private function fn_to_number(array $args)
240240 if ($ type == 'number ' ) {
241241 return $ value ;
242242 } elseif ($ type == 'string ' && is_numeric ($ value )) {
243- return strpos ($ value , '. ' ) ? (float ) $ value : (int ) $ value ;
243+ return mb_strpos ($ value , '. ' , 0 , ' UTF-8 ' ) ? (float ) $ value : (int ) $ value ;
244244 } else {
245245 return null ;
246246 }
@@ -282,7 +282,7 @@ private function fn_map(array $args)
282282
283283 private function typeError ($ from , $ msg )
284284 {
285- if (strpos ($ from , ': ' )) {
285+ if (mb_strpos ($ from , ': ' , 0 , ' UTF-8 ' )) {
286286 list ($ fn , $ pos ) = explode (': ' , $ from );
287287 throw new \RuntimeException (
288288 sprintf ('Argument %d of %s %s ' , $ pos , $ fn , $ msg )
0 commit comments