@@ -126,12 +126,17 @@ public function render()
126
126
127
127
list ($ start , $ end ) = $ this ->getChangeExtent ($ fromLine , $ toLine );
128
128
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
+
135
140
$ a [$ i1 + $ i ] = $ fromLine ;
136
141
$ b [$ j1 + $ i ] = $ toLine ;
137
142
}
@@ -193,13 +198,13 @@ public function render()
193
198
private function getChangeExtent ($ fromLine , $ toLine )
194
199
{
195
200
$ 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 ) ) {
198
203
++$ start ;
199
204
}
200
205
$ end = -1 ;
201
206
$ 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 )) {
203
208
--$ end ;
204
209
}
205
210
return array (
0 commit comments