aoenth / ConvertToPinyin

A simple Swift package for converting Chinese characters to pinyin, with or without tone marks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ConvertToPinyin

Usage

The package contains an extension on String with computed properties romanized and pinyin. The difference is that the latter contains the tone marks. Note that the conversion doesn't support Linux.

import ConvertToPinyin

let string = "你好"

print(string.romanized)
// ni hao

print(string.pinyin)
// nǐ hǎo

print(string.containsChineseCharacters)
// true

let character: Character = ""

print(string.isChineseCharacter)
// true

About

A simple Swift package for converting Chinese characters to pinyin, with or without tone marks


Languages

Language:Swift 100.0%