任何要求有更多字符的事情[重复]

问题描述 投票:0回答:2

询问任何问题,但不要询问更多字符

ios swift swiftui
2个回答
3
投票

试试这个:

import UIKit // Or Foundation


if let alphabetCharacterSet = Locale(identifier: "ru").exemplarCharacterSet?.intersection(CharacterSet.lowercaseLetters) {
    print(alphabetCharacterSet.characters().sorted(by: {String($0).localizedCompare(String($1)) == .orderedAscending }))
}
// If you don't sort alphabetical order is not guaranteed.

extension CharacterSet {
    func characters() -> [Character] {
        // A Unicode scalar is any Unicode code point in the range U+0000 to U+D7FF inclusive or U+E000 to U+10FFFF inclusive.
        return codePoints().compactMap { UnicodeScalar($0) }.map { Character($0) }
    }

    func codePoints() -> [Int] {
        var result: [Int] = []
        var plane = 0
        // following documentation at https://developer.apple.com/documentation/foundation/nscharacterset/1417719-bitmaprepresentation
        for (i, w) in bitmapRepresentation.enumerated() {
            let k = i % 0x2001
            if k == 0x2000 {
                // plane index byte
                plane = Int(w) << 13
                continue
            }
            let base = (plane + k) << 3
            for j in 0 ..< 8 where w & 1 << j != 0 {
                result.append(base + j)
            }
        }
        return result
    }
}

0
投票

您必须向您的项目提供 Localized.strings 基本文件,其中包含不同来源的不同文本:

喜欢 对于默认语言:

"Hello World!" = "Hello World!";

拉丁语中的类似:

"Hello World!" = "salve mundi!";
© www.soinside.com 2019 - 2024. All rights reserved.