1
0

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 1 year has passed since last update.

初めに

今回はひらがなをカタカナに、カタカナをひらがなに変換する機能を紹介していきます

本文

fun String.convertKana(): String {
    val sb = StringBuilder(length)
    this.forEach {
        when (it) {
            in '\u3041'..'\u3093' -> {
                sb.append(it + 0x60)
            }
            in '\u30a1'..'\u30f3' -> {
                sb.append(it - 0x60)
            }
            else -> sb.append(it)
        }
    }
    return sb.toString()
}

最後に

今回はカナ文字の相互変換機能を備忘録として記事にしました
どなたかのお役に立てれば幸いです

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?