3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

中国語を拼音(ピンイン)に変換する

Posted at

ニッチかもしれませんが、Swiftで中国語をピンインに変換する方法を紹介します。

使用するメソッドは applyTransform のみです。

使用例


let chinese = "中文"
if let transform = chinese.applyingTransform(.mandarinToLatin, reverse: false) {
    print(transform) // zhōng wén
}

補足

今回使用した.mandarinToLatinStringTransform の一つで他にも全角⇄半角の変換(.fullwidthToHalfwidth)やひらがな⇄カタカナの変換(.hiraganaToKatakana)なども用意されています。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?