mirror of
https://github.com/mii443/AzooKeyKanaKanjiConverter.git
synced 2025-12-03 02:58:27 +00:00
feat: enable InternalImportsByDefault feature flag
This commit is contained in:
@@ -7,6 +7,7 @@ import Foundation
|
|||||||
let swiftSettings: [SwiftSetting] = [
|
let swiftSettings: [SwiftSetting] = [
|
||||||
.enableUpcomingFeature("ExistentialAny"),
|
.enableUpcomingFeature("ExistentialAny"),
|
||||||
.enableUpcomingFeature("MemberImportVisibility"),
|
.enableUpcomingFeature("MemberImportVisibility"),
|
||||||
|
.enableUpcomingFeature("InternalImportsByDefault"),
|
||||||
.interoperabilityMode(.Cxx, .when(traits: ["Zenzai"]))
|
.interoperabilityMode(.Cxx, .when(traits: ["Zenzai"]))
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import KanaKanjiConverterModuleWithDefaultDictionary
|
|||||||
import ArgumentParser
|
import ArgumentParser
|
||||||
|
|
||||||
@main
|
@main
|
||||||
public struct Anco: AsyncParsableCommand {
|
struct Anco: AsyncParsableCommand {
|
||||||
public static let configuration = CommandConfiguration(
|
static let configuration = CommandConfiguration(
|
||||||
abstract: "Anco is A(zooKey) Kana-Ka(n)ji (co)nverter",
|
abstract: "Anco is A(zooKey) Kana-Ka(n)ji (co)nverter",
|
||||||
subcommands: [
|
subcommands: [
|
||||||
Subcommands.Run.self,
|
Subcommands.Run.self,
|
||||||
@@ -17,5 +17,5 @@ public struct Anco: AsyncParsableCommand {
|
|||||||
defaultSubcommand: Subcommands.Run.self
|
defaultSubcommand: Subcommands.Run.self
|
||||||
)
|
)
|
||||||
|
|
||||||
public init() {}
|
init() {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,9 +74,9 @@ extension Subcommands {
|
|||||||
if stable {
|
if stable {
|
||||||
result.execution_time = 0
|
result.execution_time = 0
|
||||||
result.timestamp = 0
|
result.timestamp = 0
|
||||||
result.items.mutatingForeach {
|
result.items.mutatingForEach {
|
||||||
$0.entropy = Double(Int($0.entropy * 10)) / 10
|
$0.entropy = Double(Int($0.entropy * 10)) / 10
|
||||||
$0.outputs.mutatingForeach {
|
$0.outputs.mutatingForEach {
|
||||||
$0.score = Double(Int($0.score))
|
$0.score = Double(Int($0.score))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ extension Subcommands {
|
|||||||
if stable {
|
if stable {
|
||||||
result.execution_time = 0
|
result.execution_time = 0
|
||||||
result.timestamp = 0
|
result.timestamp = 0
|
||||||
result.items.mutatingForeach {
|
result.items.mutatingForEach {
|
||||||
$0.outputs.mutatingForeach {
|
$0.outputs.mutatingForEach {
|
||||||
$0.score = Double(Int($0.score))
|
$0.score = Double(Int($0.score))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2022 ensan. All rights reserved.
|
// Copyright © 2022 ensan. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
public import Foundation
|
||||||
|
|
||||||
public struct ConvertRequestOptions: Sendable {
|
public struct ConvertRequestOptions: Sendable {
|
||||||
/// 変換リクエストに必要な設定データ
|
/// 変換リクエストに必要な設定データ
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import Algorithms
|
import Algorithms
|
||||||
import Foundation
|
package import Foundation
|
||||||
import SwiftUtils
|
import SwiftUtils
|
||||||
import EfficientNGram
|
import EfficientNGram
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ import EfficientNGram
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var converter = Kana2Kanji()
|
private var converter = Kana2Kanji()
|
||||||
public static let defaultSpecialCandidateProviders: [any SpecialCandidateProvider] = [
|
nonisolated public static let defaultSpecialCandidateProviders: [any SpecialCandidateProvider] = [
|
||||||
CalendarSpecialCandidateProvider(),
|
CalendarSpecialCandidateProvider(),
|
||||||
EmailAddressSpecialCandidateProvider(),
|
EmailAddressSpecialCandidateProvider(),
|
||||||
UnicodeSpecialCandidateProvider(),
|
UnicodeSpecialCandidateProvider(),
|
||||||
@@ -582,7 +582,7 @@ import EfficientNGram
|
|||||||
result.append(contentsOf: clause_candidates)
|
result.append(contentsOf: clause_candidates)
|
||||||
result.append(contentsOf: word_candidates)
|
result.append(contentsOf: word_candidates)
|
||||||
|
|
||||||
result.mutatingForeach { item in
|
result.mutatingForEach { item in
|
||||||
item.withActions(self.getAppropriateActions(item))
|
item.withActions(self.getAppropriateActions(item))
|
||||||
item.parseTemplate()
|
item.parseTemplate()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ public final class DicdataStore {
|
|||||||
self.closeKeyboard()
|
self.closeKeyboard()
|
||||||
case .importOSUserDict(let dicdata), .importDynamicUserDict(let dicdata):
|
case .importOSUserDict(let dicdata), .importDynamicUserDict(let dicdata):
|
||||||
self.dynamicUserDict = dicdata
|
self.dynamicUserDict = dicdata
|
||||||
self.dynamicUserDict.mutatingForeach {
|
self.dynamicUserDict.mutatingForEach {
|
||||||
$0.metadata = .isFromUserDictionary
|
$0.metadata = .isFromUserDictionary
|
||||||
}
|
}
|
||||||
case let .forgetMemory(candidate):
|
case let .forgetMemory(candidate):
|
||||||
@@ -258,12 +258,12 @@ public final class DicdataStore {
|
|||||||
data.append(contentsOf: LOUDS.getDataForLoudstxt3(identifier + "\(key)", indices: value.map {$0 & 2047}, cache: self.loudstxts[identifier + "\(key)"], option: self.requestOptions))
|
data.append(contentsOf: LOUDS.getDataForLoudstxt3(identifier + "\(key)", indices: value.map {$0 & 2047}, cache: self.loudstxts[identifier + "\(key)"], option: self.requestOptions))
|
||||||
}
|
}
|
||||||
if identifier == "memory" {
|
if identifier == "memory" {
|
||||||
data.mutatingForeach {
|
data.mutatingForEach {
|
||||||
$0.metadata = .isLearned
|
$0.metadata = .isLearned
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if identifier == "user" {
|
if identifier == "user" {
|
||||||
data.mutatingForeach {
|
data.mutatingForEach {
|
||||||
$0.metadata = .isFromUserDictionary
|
$0.metadata = .isFromUserDictionary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2020 ensan. All rights reserved.
|
// Copyright © 2020 ensan. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
package import Foundation
|
||||||
import SwiftUtils
|
import SwiftUtils
|
||||||
|
|
||||||
extension LOUDS {
|
extension LOUDS {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2023 ensan. All rights reserved.
|
// Copyright © 2023 ensan. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
public import Foundation
|
||||||
import SwiftUtils
|
import SwiftUtils
|
||||||
|
|
||||||
/// `TextReplacer`は前後の文脈に基づいて、現在のカーソル位置の語の置き換えを提案するためのモジュールである。
|
/// `TextReplacer`は前後の文脈に基づいて、現在のカーソル位置の語の置き換えを提案するためのモジュールである。
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
// Copyright © 2020 ensan. All rights reserved.
|
// Copyright © 2020 ensan. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
public import Foundation
|
||||||
import SwiftUtils
|
import SwiftUtils
|
||||||
|
|
||||||
public struct TemplateData: Codable, Sendable {
|
public struct TemplateData: Codable, Sendable {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import Foundation
|
package import Foundation
|
||||||
import SwiftUtils
|
import SwiftUtils
|
||||||
import EfficientNGram
|
import EfficientNGram
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
@_exported import KanaKanjiConverterModule
|
@_exported public import KanaKanjiConverterModule
|
||||||
import Foundation
|
public import Foundation
|
||||||
|
|
||||||
public extension ConvertRequestOptions {
|
public extension ConvertRequestOptions {
|
||||||
static func withDefaultDictionary(
|
static func withDefaultDictionary(
|
||||||
|
|||||||
@@ -5,20 +5,20 @@
|
|||||||
// Created by ensan on 2023/04/30.
|
// Created by ensan on 2023/04/30.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Algorithms
|
package import Algorithms
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public extension Sequence {
|
package extension Sequence {
|
||||||
/// Returns a sequence that contains the elements of this sequence followed by the elements of the given sequence.
|
/// Returns a sequence that contains the elements of this sequence followed by the elements of the given sequence.
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - sequence: A sequence of elements to chain.
|
/// - sequence: A sequence of elements to chain.
|
||||||
/// - Returns: A sequence that contains the elements of this sequence followed by the elements of the given sequence.
|
/// - Returns: A sequence that contains the elements of this sequence followed by the elements of the given sequence.
|
||||||
@inlinable func chained<S: Sequence<Element>>(_ sequence: S) -> Chain2Sequence<Self, S> {
|
func chained<S: Sequence<Element>>(_ sequence: S) -> Chain2Sequence<Self, S> {
|
||||||
chain(self, sequence)
|
chain(self, sequence)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension Collection {
|
package extension Collection {
|
||||||
/// Returns a `Set` containing the elements of this sequence with transformed values.
|
/// Returns a `Set` containing the elements of this sequence with transformed values.
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - transform: A closure that transforms each element of this sequence into a value that can be hashed.
|
/// - transform: A closure that transforms each element of this sequence into a value that can be hashed.
|
||||||
@@ -60,18 +60,18 @@ public extension Collection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension MutableCollection {
|
package extension MutableCollection {
|
||||||
/// Calls the given closure with a pointer to the array's mutable contiguous storage.
|
/// Calls the given closure with a pointer to the array's mutable contiguous storage.
|
||||||
/// - Parameter
|
/// - Parameter
|
||||||
/// - transform: A closure that takes a pointer to the array's mutable contiguous storage.
|
/// - transform: A closure that takes a pointer to the array's mutable contiguous storage.
|
||||||
@inlinable mutating func mutatingForeach(transform closure: (inout Element) throws -> Void) rethrows {
|
@inlinable mutating func mutatingForEach(transform closure: (inout Element) throws -> Void) rethrows {
|
||||||
for index in self.indices {
|
for index in self.indices {
|
||||||
try closure(&self[index])
|
try closure(&self[index])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension Collection {
|
package extension Collection {
|
||||||
/// Returns a SubSequence containing the elements of this sequence up to the first element that does not satisfy the given predicate.
|
/// Returns a SubSequence containing the elements of this sequence up to the first element that does not satisfy the given predicate.
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - condition: A closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element should be included.
|
/// - condition: A closure that takes an element of the sequence as its argument and returns a Boolean value indicating whether the element should be included.
|
||||||
@@ -85,7 +85,7 @@ public extension Collection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension Collection where Self.Element: Equatable {
|
package extension Collection where Self.Element: Equatable {
|
||||||
/// Returns a Bool value indicating whether the collection has the given prefix.
|
/// Returns a Bool value indicating whether the collection has the given prefix.
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - prefix: A collection to search for at the start of this collection.
|
/// - prefix: A collection to search for at the start of this collection.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public enum CharacterUtils {
|
package enum CharacterUtils {
|
||||||
/// 小書きのかなカナ集合
|
/// 小書きのかなカナ集合
|
||||||
private static let kogakiKana: Set<Character> = [
|
private static let kogakiKana: Set<Character> = [
|
||||||
"ぁ", "ぃ", "ぅ", "ぇ", "ぉ", "ゕ", "ゖ", "っ", "ゃ", "ゅ", "ょ", "ゎ",
|
"ぁ", "ぃ", "ぅ", "ぇ", "ぉ", "ゕ", "ゖ", "っ", "ゃ", "ゅ", "ょ", "ゎ",
|
||||||
@@ -26,12 +26,12 @@ public enum CharacterUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// ローマ字(a-z, A-Zか否か)
|
/// ローマ字(a-z, A-Zか否か)
|
||||||
@inlinable public static func isRomanLetter(_ character: Character) -> Bool {
|
@inlinable package static func isRomanLetter(_ character: Character) -> Bool {
|
||||||
character.isASCII && character.isCased
|
character.isASCII && character.isCased
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 自分が小書きであれば該当する文字を返す。
|
/// 自分が小書きであれば該当する文字を返す。
|
||||||
public static func kogaki(_ character: Character) -> Character {
|
package static func kogaki(_ character: Character) -> Character {
|
||||||
switch character {
|
switch character {
|
||||||
case "あ": return "ぁ"
|
case "あ": return "ぁ"
|
||||||
case "い": return "ぃ"
|
case "い": return "ぃ"
|
||||||
@@ -62,7 +62,7 @@ public enum CharacterUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 小書きから大書きを返す
|
/// 小書きから大書きを返す
|
||||||
public static func ogaki(_ character: Character) -> Character {
|
package static func ogaki(_ character: Character) -> Character {
|
||||||
switch character {
|
switch character {
|
||||||
case "ぁ": return "あ"
|
case "ぁ": return "あ"
|
||||||
case "ぃ": return "い"
|
case "ぃ": return "い"
|
||||||
@@ -93,11 +93,11 @@ public enum CharacterUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 濁点付きか否か
|
/// 濁点付きか否か
|
||||||
public static func isDakuten(_ character: Character) -> Bool {
|
package static func isDakuten(_ character: Character) -> Bool {
|
||||||
dakutenKana.contains(character)
|
dakutenKana.contains(character)
|
||||||
}
|
}
|
||||||
/// 濁点をつけて返す
|
/// 濁点をつけて返す
|
||||||
public static func dakuten(_ character: Character) -> Character {
|
package static func dakuten(_ character: Character) -> Character {
|
||||||
switch character {
|
switch character {
|
||||||
case"う": return "ゔ"
|
case"う": return "ゔ"
|
||||||
case"か": return "が"
|
case"か": return "が"
|
||||||
@@ -145,7 +145,7 @@ public enum CharacterUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// 濁点を外して返す
|
/// 濁点を外して返す
|
||||||
public static func mudakuten(_ character: Character) -> Character {
|
package static func mudakuten(_ character: Character) -> Character {
|
||||||
switch character {
|
switch character {
|
||||||
case"ゔ": return "う"
|
case"ゔ": return "う"
|
||||||
case"が": return "か"
|
case"が": return "か"
|
||||||
@@ -193,14 +193,14 @@ public enum CharacterUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// 半濁点かどうか
|
/// 半濁点かどうか
|
||||||
public static func isHandakuten(_ character: Character) -> Bool {
|
package static func isHandakuten(_ character: Character) -> Bool {
|
||||||
[
|
[
|
||||||
"ぱ", "ぴ", "ぷ", "ぺ", "ぽ",
|
"ぱ", "ぴ", "ぷ", "ぺ", "ぽ",
|
||||||
"パ", "ピ", "プ", "ペ", "ポ"
|
"パ", "ピ", "プ", "ペ", "ポ"
|
||||||
].contains(character)
|
].contains(character)
|
||||||
}
|
}
|
||||||
/// 半濁点をつけて返す
|
/// 半濁点をつけて返す
|
||||||
public static func handakuten(_ character: Character) -> Character {
|
package static func handakuten(_ character: Character) -> Character {
|
||||||
switch character {
|
switch character {
|
||||||
case"は": return "ぱ"
|
case"は": return "ぱ"
|
||||||
case"ひ": return "ぴ"
|
case"ひ": return "ぴ"
|
||||||
@@ -216,7 +216,7 @@ public enum CharacterUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// 半濁点を外して返す
|
/// 半濁点を外して返す
|
||||||
public static func muhandakuten(_ character: Character) -> Character {
|
package static func muhandakuten(_ character: Character) -> Character {
|
||||||
switch character {
|
switch character {
|
||||||
case"ぱ": return "は"
|
case"ぱ": return "は"
|
||||||
case"ぴ": return "ひ"
|
case"ぴ": return "ひ"
|
||||||
@@ -233,7 +233,7 @@ public enum CharacterUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 濁点、小書き、半濁点などを相互に変換する関数。
|
/// 濁点、小書き、半濁点などを相互に変換する関数。
|
||||||
public static func requestChange(_ character: Character) -> String {
|
package static func requestChange(_ character: Character) -> String {
|
||||||
if character.isLowercase {
|
if character.isLowercase {
|
||||||
return character.uppercased()
|
return character.uppercased()
|
||||||
}
|
}
|
||||||
@@ -285,7 +285,7 @@ public enum CharacterUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension Character {
|
package extension Character {
|
||||||
/// Returns the Katakanized version of the character.
|
/// Returns the Katakanized version of the character.
|
||||||
@inlinable func toKatakana() -> Character {
|
@inlinable func toKatakana() -> Character {
|
||||||
if self.unicodeScalars.count != 1 {
|
if self.unicodeScalars.count != 1 {
|
||||||
|
|||||||
@@ -6,14 +6,14 @@
|
|||||||
// Copyright © 2022 ensan. All rights reserved.
|
// Copyright © 2022 ensan. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
package import Foundation
|
||||||
|
|
||||||
extension Data {
|
package extension Data {
|
||||||
/// Converts this data to an array of the given type.
|
/// Converts this data to an array of the given type.
|
||||||
/// - Parameter:
|
/// - Parameter:
|
||||||
/// - type: The type to convert this data to.
|
/// - type: The type to convert this data to.
|
||||||
/// - Returns: An array of the given type.
|
/// - Returns: An array of the given type.
|
||||||
@inlinable public func toArray<T>(of type: T.Type) -> [T] {
|
func toArray<T>(of type: T.Type) -> [T] {
|
||||||
self.withUnsafeBytes {pointer -> [T] in
|
self.withUnsafeBytes {pointer -> [T] in
|
||||||
Array(
|
Array(
|
||||||
UnsafeBufferPointer(
|
UnsafeBufferPointer(
|
||||||
|
|||||||
@@ -8,16 +8,16 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public extension StringProtocol {
|
package extension StringProtocol {
|
||||||
/// ローマ字と数字のみかどうか
|
/// ローマ字と数字のみかどうか
|
||||||
/// - note: 空文字列の場合`false`を返す。
|
/// - note: 空文字列の場合`false`を返す。
|
||||||
@inlinable
|
@usableFromInline
|
||||||
var onlyRomanAlphabetOrNumber: Bool {
|
var onlyRomanAlphabetOrNumber: Bool {
|
||||||
!isEmpty && range(of: "[^a-zA-Z0-9]", options: .regularExpression) == nil
|
!isEmpty && range(of: "[^a-zA-Z0-9]", options: .regularExpression) == nil
|
||||||
}
|
}
|
||||||
/// ローマ字のみかどうか
|
/// ローマ字のみかどうか
|
||||||
/// - note: 空文字列の場合`false`を返す。
|
/// - note: 空文字列の場合`false`を返す。
|
||||||
@inlinable
|
@usableFromInline
|
||||||
var onlyRomanAlphabet: Bool {
|
var onlyRomanAlphabet: Bool {
|
||||||
!isEmpty && range(of: "[^a-zA-Z]", options: .regularExpression) == nil
|
!isEmpty && range(of: "[^a-zA-Z]", options: .regularExpression) == nil
|
||||||
}
|
}
|
||||||
@@ -35,20 +35,21 @@ public extension StringProtocol {
|
|||||||
}
|
}
|
||||||
/// 英語として許容可能な文字のみで構成されているか。
|
/// 英語として許容可能な文字のみで構成されているか。
|
||||||
/// - note: 空文字列の場合`false`を返す。
|
/// - note: 空文字列の場合`false`を返す。
|
||||||
@inlinable
|
@usableFromInline
|
||||||
var isEnglishSentence: Bool {
|
var isEnglishSentence: Bool {
|
||||||
!isEmpty && range(of: "[^0-9a-zA-Z\n !'_<>\\[\\]{}*@`\\^|~=\"#$%&\\+\\(\\),\\-\\./:;?’\\\\]", options: .regularExpression) == nil
|
!isEmpty && range(of: "[^0-9a-zA-Z\n !'_<>\\[\\]{}*@`\\^|~=\"#$%&\\+\\(\\),\\-\\./:;?’\\\\]", options: .regularExpression) == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 仮名か
|
/// 仮名か
|
||||||
@inlinable
|
@usableFromInline
|
||||||
var isKana: Bool {
|
var isKana: Bool {
|
||||||
!isEmpty && range(of: "[^ぁ-ゖァ-ヶ]", options: .regularExpression) == nil
|
!isEmpty && range(of: "[^ぁ-ゖァ-ヶ]", options: .regularExpression) == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a String value in which Hiraganas are all converted to Katakana.
|
/// Returns a String value in which Hiraganas are all converted to Katakana.
|
||||||
/// - Returns: A String value in which Hiraganas are all converted to Katakana.
|
/// - Returns: A String value in which Hiraganas are all converted to Katakana.
|
||||||
@inlinable func toKatakana() -> String {
|
@usableFromInline
|
||||||
|
func toKatakana() -> String {
|
||||||
// カタカナはutf16で常に2バイトなので、utf16単位で処理して良い
|
// カタカナはutf16で常に2バイトなので、utf16単位で処理して良い
|
||||||
let result = self.utf16.map { scalar -> UInt16 in
|
let result = self.utf16.map { scalar -> UInt16 in
|
||||||
if 0x3041 <= scalar && scalar <= 0x3096 {
|
if 0x3041 <= scalar && scalar <= 0x3096 {
|
||||||
@@ -62,7 +63,8 @@ public extension StringProtocol {
|
|||||||
|
|
||||||
/// Returns a String value in which Katakana are all converted to Hiragana.
|
/// Returns a String value in which Katakana are all converted to Hiragana.
|
||||||
/// - Returns: A String value in which Katakana are all converted to Hiragana.
|
/// - Returns: A String value in which Katakana are all converted to Hiragana.
|
||||||
@inlinable func toHiragana() -> String {
|
@usableFromInline
|
||||||
|
func toHiragana() -> String {
|
||||||
// ひらがなはutf16で常に2バイトなので、utf16単位で処理して良い
|
// ひらがなはutf16で常に2バイトなので、utf16単位で処理して良い
|
||||||
let result = self.utf16.map { scalar -> UInt16 in
|
let result = self.utf16.map { scalar -> UInt16 in
|
||||||
if 0x30A1 <= scalar && scalar <= 0x30F6 {
|
if 0x30A1 <= scalar && scalar <= 0x30F6 {
|
||||||
|
|||||||
Reference in New Issue
Block a user