@@ -126,12 +126,17 @@ public function render()
126126
127127 list ($ start , $ end ) = $ this ->getChangeExtent ($ fromLine , $ toLine );
128128 if ($ start != 0 || $ end != 0 ) {
129- $ last = $ end + strlen ($ fromLine );
130- $ fromLine = $ this ->mb_substr_replace ($ fromLine , "\0" , $ start , 0 );
131- $ fromLine = $ this ->mb_substr_replace ($ fromLine , "\1" , $ last + 1 , 0 );
132- $ last = $ end + strlen ($ toLine );
133- $ toLine = $ this ->mb_substr_replace ($ toLine , "\0" , $ start , 0 );
134- $ toLine = $ this ->mb_substr_replace ($ toLine , "\1" , $ last + 1 , 0 );
129+ $ realEnd = mb_strlen ($ fromLine ) + $ end ;
130+
131+ $ fromLine = mb_substr ($ fromLine , 0 , $ start ) . "\0" .
132+ mb_substr ($ fromLine , $ start , $ realEnd - $ start ) . "\1" . mb_substr ($ fromLine , $ realEnd );
133+
134+ $ realEnd = mb_strlen ($ toLine ) + $ end ;
135+
136+ $ toLine = mb_substr ($ toLine , 0 , $ start ) .
137+ "\0" . mb_substr ($ toLine , $ start , $ realEnd - $ start ) . "\1" .
138+ mb_substr ($ toLine , $ realEnd );
139+
135140 $ a [$ i1 + $ i ] = $ fromLine ;
136141 $ b [$ j1 + $ i ] = $ toLine ;
137142 }
@@ -193,13 +198,13 @@ public function render()
193198 private function getChangeExtent ($ fromLine , $ toLine )
194199 {
195200 $ start = 0 ;
196- $ limit = min (strlen ($ fromLine ), strlen ($ toLine ));
197- while ($ start < $ limit && $ fromLine{ $ start} == $ toLine{ $ start} ) {
201+ $ limit = min (mb_strlen ($ fromLine ), mb_strlen ($ toLine ));
202+ while ($ start < $ limit && mb_substr ( $ fromLine, $ start, 1 ) == mb_substr ( $ toLine, $ start, 1 ) ) {
198203 ++$ start ;
199204 }
200205 $ end = -1 ;
201206 $ limit = $ limit - $ start ;
202- while (-$ end <= $ limit && substr ($ fromLine , $ end , 1 ) == substr ($ toLine , $ end , 1 )) {
207+ while (-$ end <= $ limit && mb_substr ($ fromLine , $ end , 1 ) == mb_substr ($ toLine , $ end , 1 )) {
203208 --$ end ;
204209 }
205210 return array (
0 commit comments