2
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 3 years have passed since last update.

すべてのひらがな・カタカナなどのリストをCharacterの配列で取得する

Posted at

ひらがな一覧

    static let hiraganaList: [Character] = {
        [UnicodeScalar("あ").value...UnicodeScalar("ん").value].joined()
            .compactMap { value in
                UnicodeScalar(value).map(Character.init)
            }
    }()

カタカナ一覧

    static let katakanaList: [Character] = {
        [UnicodeScalar("ア").value...UnicodeScalar("ン").value].joined()
            .compactMap { value in
                UnicodeScalar(value).map(Character.init)
            }
    }()

アルファベット大文字一覧

    static let upperAlphabetList: [Character] = {
        [UnicodeScalar("A").value...UnicodeScalar("Z").value].joined()
            .compactMap { value in
                UnicodeScalar(value).map(Character.init)
            }
    }()

アルファベット小文字一覧

    static let lowerAlphabetList: [Character] = {
        [UnicodeScalar("a").value...UnicodeScalar("z").value].joined()
            .compactMap { value in
                UnicodeScalar(value).map(Character.init)
            }
    }()

数字一覧

    static let numberList: [Character] = {
        [UnicodeScalar("0").value...UnicodeScalar("9").value].joined()
            .compactMap { value in
                UnicodeScalar(value).map(Character.init)
            }
    }()

2
3
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
2
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?