Diff-match-patchgithub Address
Support C,java,javascript,lua,object-c,python
Https://github.com/google/diff-match-patch/wiki/API
The library is available in multiple languages. Regardless of the language used, the interface is the same. This page describes the API for public functionality. More instances at the top address .
each language port of the Diff Match patch is used the same API
Java version
Importjava.util.LinkedList;ImportName.fraser.neil.plaintext.diff_match_patch; Public classHello { Public Static voidMain (String args[]) {diff_match_patch dmp=NewDiff_match_patch (); LinkedList<diff_match_patch. diff> diff = Dmp.diff_main ("Hello World", "Goodbye."); //Result: [( -1, "Hell"), (1, "G"), (0, "O"), (1, "Odbye"), (0, "World")]dmp.diff_cleanupsemantic (diff); //Result: [( -1, "Hello"), (1, "Goodbye"), (0, "World")]System.out.println (diff); }}
Lua version, but bugs are unavoidable because LUA strings do not have the encoding rules set by default when initializing, and all byte rules need to be defined by themselves, so this version of LUA needs to build its own wheels.
LocalDMP =require 'Diff_match_patch'diff= Dmp.diff_main ('Hello World.','Goodbye World.')--Result: [( -1, "Hell"), (1, "G"), (0, "O"), (1, "Odbye"), (0, "World")]dmp.diff_cleanupsemantic (diff)--Result: [( -1, "Hello"), (1, "Goodbye"), (0, "World")] forI,tupleinch Ipairs(diff) Do Print('('.. tuple[1] ..', '.. tuple[2] ..')')End
An easy-to-use character-filtering, diff-Matching Patch extension library for each language version