js-han
v0.0.13
Published
簡化字轉漢字,js實現
Maintainers
Readme
簡化字轉漢字
簡化字轉漢字,js實現
- 支持《通用規範漢字表》中的全部簡化字
- 對於一對多的簡化字,人工標註規則
- 支持運行時增加自定義規則
- 簡單快速

使用
node
install
npm i js-han@latestpackage.json
{
"type": "module",
"dependencies": {
"js-han": "^0.0.10"
}
}example
import Han from 'js-han'
const hanInstance = Han.getInstance()
// 蘿蔔
console.log(hanInstance.toTraditional('萝卜'))
// 胡卜
console.log(hanInstance.toTraditional('胡卜'))
// 胡蔔
hanInstance.addRule('卜,蔔,-1|0|胡')
console.log(hanInstance.toTraditional('胡卜'))
const han = new Han()
// 頭髮
console.log(han.toTraditional('头发'))browser
<!DOCTYPE html>
<html lang="zh-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>簡化字轉漢字</title>
<script type="module">
import Han from "https://lizongying.github.io/js-han/han.min.js";
const hanInstance = Han.getInstance();
console.log(hanInstance.toTraditional('汉字'));
</script>
</head>
<body>
</body>
</html>讚賞

