Exception in diff_commonOverlap due to ligatures in C#
Closed this issue · 2 comments
GoogleCodeExporter commented
What steps will reproduce the problem?
1. Run new DiffMatchPatch.diff_match_patch().diff_commonOverlap("ifi", "ifi")
2. Notice that the "fi" in the second argument is a ligature (0xfb01)
3. Exception will occur complaining about a StartIndex argument on the
Substring method
I believe this is due to the IndexOf method in C# matching the ligature and
"fi" as equal which then messes up the counts. I was able to fix by forcing an
ordinal comparison which may or may not be ideal:
int found = text2.IndexOf(pattern, StringComparison.Ordinal);
I have not investigated other languages or the rest of the library for other
places this could be interfering.
Original issue reported on code.google.com by jbran...@gmail.com
on 16 Aug 2011 at 8:43
GoogleCodeExporter commented
Both your diagnosis and your solution are absolutely correct. A check of the
code shows that all other instances of IndexOf use StringComparison.Ordinal
(with one exception that is harmless).
I'll try to get a new version out by tomorrow. Thanks!
Original comment by neil.fra...@gmail.com
on 16 Aug 2011 at 9:04
- Changed state: Accepted
GoogleCodeExporter commented
Fixed (for extremely large values of 'tomorrow').
Original comment by neil.fra...@gmail.com
on 11 Oct 2011 at 12:52
- Changed state: Fixed