javaliker / google-diff-match-patch

Automatically exported from code.google.com/p/google-diff-match-patch
Apache License 2.0
0 stars 1 forks source link

Exception in diff_commonOverlap due to ligatures in C# #54

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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 9 years ago
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

GoogleCodeExporter commented 9 years ago
Fixed (for extremely large values of 'tomorrow').

Original comment by neil.fra...@gmail.com on 11 Oct 2011 at 12:52