Ruby汉字转拼音 hanzi_to_pinyin

码农软件 · 软件分类 · 拼音转换工具包 · 2019-08-04 13:26:57

软件介绍

hanzi_to_pinyin 是 Ruby 语言将汉字转成拼音的库。

示例代码:

$ HanziToPinyin.hanzi_to_pinyin("中华人民共和国") => "zhrmghg"
$ HanziToPinyin.hanzi_2_pinyin("中华人民共和国") => "zhrmghg"
$ HanziToPinyin.hanzi_to_pinyin("喜欢Ruby") => "xhruby"
$ HanziToPinyin.hanzi_2_pinyin("喜欢Ruby") => "xhruby"

$ HanziToPinyin.is_hanzi?("你") => true
$ HanziToPinyin.is_hanzi?("a") => false

# 多音字,分隔 字字之间;分隔,字母丢弃
$ HanziToPinyin.hanzi_2_py("我们") => "wo;men"
$ HanziToPinyin.hanzi_2_py("查理Smith") => "cha,zha;li"
$ HanziToPinyin.hanzi_2_py("测试1") => "ce;shi;1"
$ HanziToPinyin.hanzi_2_py("测_试") => "ce;_;shi"
$ HanziToPinyin.hanzi_2_py("测-试").should == "ce;-;shi"

$ HanziToPinyin.is_number?("1".ord) => true
$ HanziToPinyin.is_number?("a".ord) => false

$ HanziToPinyin.is_underline?("_".ord).should be_true
$ HanziToPinyin.is_underline?("豆豆").should be_false
$ HanziToPinyin.is_dash?("-".ord).should be_true

本文地址:https://www.codercto.com/soft/d/11626.html

Operating Systems

Operating Systems

Remzi Arpaci-Dusseau、Andrea Arpaci-Dusseau / Arpaci-Dusseau Books / 2012-8-19 / USD 21.00

A book about modern operating systems. Topics are broken down into three major conceptual pieces: Virtualization, Concurrency, and Persistence. Includes all major components of modern systems includin......一起来看看 《Operating Systems》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具