DiffChinese
Client side javascript string diff algorithm that supports Chinese
Install / Use
/learn @mailmangroup/DiffChineseREADME
diffChinese
Introduction
This module comparea two strings and outputs the differences.
It is based on, and borrows heavily from, John Resig's Javascript Diff Algorithm (http://ejohn.org/projects/javascript-diff-algorithm/). Thanks, John!
The main difference is that this module supports finding differences in strings containing Chinese or other languages that use multi byte characters and/or don't separate words by spaces.
As an example here is how we at KAWO.com use this package in our app:

Installation
$ bower install diffChinese
Including diffChinese
RequireJS (recommended)
require.config({
paths: {
diffChinese: '../bower_components/diffChinese/dist/diffChinese'
}
});
require( [ 'diffChinese' ], function( diffChinese ) {
...
});
Basic Script Include
<script src="./bower-components/diffString/dist/diffString.min.js"></script>
<script>
...
</script>
Usage
The diffChinese package contains only one function diffChinese which can be used like this:
var beforeString = 'the quick brown fox';
var afterString = 'the quick brown dog';
var diff = diffChinese( beforeString, afterString );
// => { before: 'the quick brown <del>fox</del>', after: 'the quick brown <ins>dog</ins>' }
View on GitHub60/100
Security Score
Audited on Apr 18, 2023
No findings
