Open Chinese Convert: node/demo.js

Open Chinese Convert 1.0.2 A project for conversion between Traditional and Simplified Chinese

- Main Page
- Modules
- Classes
- Examples

All Classes Functions Typedefs Modules
node/demo.js

This is an example of how to use the Node.js API.

// In your project you should replace './opencc' with 'opencc'
var OpenCC = require('./opencc');
// Load the default Simplified to Traditional config
var opencc = new OpenCC('s2t.json');
// Sync API
var converted = opencc.convertSync("汉字");
console.log(converted);
// Async API
opencc.convert("汉字", function (err, converted) {
console.log(converted);
});