LoginSignup
0
0

More than 1 year has passed since last update.

kotlinで平仮名をカタカナにしたい

Posted at

文字列の平仮名をカタカナに置き換えます。
特に難しくないので詳しくは書きません。

コード

object JpConverter{
    fun hiraToKata(str: String) = 
        str.map { 
            if (it.code in 0x3041..0x3093) {
                it + 0x60 
            } else {
                it
            } 
        }.joinToString("")
}

it + 0x60だけつまづきました。it + "0x60"と書いたら動かなかったので、、

最後に

ミスは指摘お願いします。
もっといい方法あれば教えてください。

0
0
1

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