jQuery通过pinyinUtil.js实现汉字转拼音(带声调拼音,不带声调、拼音首字母)


<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="js/pinyin_dict_withtone.js"></script>
		<script src="js/pinyinUtil.js"></script>
		<style type="text/css">
			.span_color{
				color: #9E9E9E;
				display: block;
			}
		</style>
	</head>
	<body>
		<h2>汉字转拼音</h2>
		<div>
			<span>输出类型:</span>
			<label><input type="radio" name="pinyin_type" value="0" checked />带声调拼音</label>
			<label><input type="radio" name="pinyin_type" value="1" />不带声调拼音</label>
			<label><input type="radio" name="pinyin_type" value="2" />拼音首字母</label>
		</div>
		<div>
			<span>多音字:</span>
			<label><input type="checkbox" name="polyphone" />简单支持多音字</label>
			<span class="span_color">(支持多音字仅仅是将所有可能的组合列举出来,要做到准确识别多音字还需非常完善的词库)</span>
		</div>
		<span>输入需要转化的中文内容:</span><input type="text" id="test" value="汉子转拼音" placeholder="请随便输入一些中文" />
		<h3>转换结果:</h3>
		<div id="result"></div>
		<!-- 中文转化拼音调用方法 -->
		<script src="js/index.js"></script>
	</body>
</html>

demo下载地址 

 

Guess you like

Origin blog.csdn.net/tanqingfu1/article/details/109503455