@@ -45,11 +45,13 @@ func splice(slice []Diff, index int, amount int, elements ...Diff) []Diff {
45
45
}
46
46
47
47
// DiffMain finds the differences between two texts.
48
+ // If an invalid UTF-8 sequence is encountered, it will be replaced by the Unicode replacement character.
48
49
func (dmp * DiffMatchPatch ) DiffMain (text1 , text2 string , checklines bool ) []Diff {
49
50
return dmp .DiffMainRunes ([]rune (text1 ), []rune (text2 ), checklines )
50
51
}
51
52
52
53
// DiffMainRunes finds the differences between two rune sequences.
54
+ // If an invalid UTF-8 sequence is encountered, it will be replaced by the Unicode replacement character.
53
55
func (dmp * DiffMatchPatch ) DiffMainRunes (text1 , text2 []rune , checklines bool ) []Diff {
54
56
var deadline time.Time
55
57
if dmp .DiffTimeout > 0 {
@@ -209,6 +211,7 @@ func (dmp *DiffMatchPatch) diffLineMode(text1, text2 []rune, deadline time.Time)
209
211
}
210
212
211
213
// DiffBisect finds the 'middle snake' of a diff, split the problem in two and return the recursively constructed diff.
214
+ // If an invalid UTF-8 sequence is encountered, it will be replaced by the Unicode replacement character.
212
215
// See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.
213
216
func (dmp * DiffMatchPatch ) DiffBisect (text1 , text2 string , deadline time.Time ) []Diff {
214
217
// Unused in this code, but retained for interface compatibility.
@@ -353,7 +356,7 @@ func (dmp *DiffMatchPatch) DiffLinesToChars(text1, text2 string) (string, string
353
356
return string (chars1 ), string (chars2 ), lineArray
354
357
}
355
358
356
- // DiffLinesToRunes splits two texts into a list of runes. Each rune represents one line.
359
+ // DiffLinesToRunes splits two texts into a list of runes. Each rune represents one line.
357
360
func (dmp * DiffMatchPatch ) DiffLinesToRunes (text1 , text2 string ) ([]rune , []rune , []string ) {
358
361
// '\x00' is a valid character, but various debuggers don't like it. So we'll insert a junk entry to avoid generating a null character.
359
362
lineArray := []string {"" } // e.g. lineArray[4] == 'Hello\n'
0 commit comments