CCBridge // +convertPunctuationsToVertical().
This commit is contained in:
parent
a0400c111a
commit
fcad389e25
|
@ -11,6 +11,24 @@ import Foundation
|
||||||
public enum ChineseConverter {
|
public enum ChineseConverter {
|
||||||
public static let shared = HotenkaChineseConverter(plistDir: mgrLangModel.getBundleDataPath("convdict"))
|
public static let shared = HotenkaChineseConverter(plistDir: mgrLangModel.getBundleDataPath("convdict"))
|
||||||
|
|
||||||
|
private static var punctuationConversionTable: [(String, String)] = [
|
||||||
|
("【", "︻"), ("】", "︼"), ("〖", "︗"), ("〗", "︘"), ("〔", "︹"), ("〕", "︺"), ("《", "︽"), ("》", "︾"),
|
||||||
|
("〈", "︿"), ("〉", "﹀"), ("「", "﹁"), ("」", "﹂"), ("『", "﹃"), ("』", "﹄"), ("{", "︷"), ("}", "︸"),
|
||||||
|
("(", "︵"), (")", "︶"), ("[", "﹇"), ("]", "﹈"),
|
||||||
|
]
|
||||||
|
|
||||||
|
/// 將操作對象內的橫排標點轉為縱排標點。
|
||||||
|
/// 本來是不推薦使用的,但某些極端的排版情形下、使用的中文字型不支援縱排標點自動切換,才需要這個功能。
|
||||||
|
/// - Parameters:
|
||||||
|
/// - target: 轉換目標。
|
||||||
|
/// - convert: 是否真的執行此操作。不填寫的話,該函式不執行。
|
||||||
|
public static func hardenVerticalPunctuations(target: inout String, convert: Bool = false) {
|
||||||
|
guard convert else { return }
|
||||||
|
for neta in ChineseConverter.punctuationConversionTable {
|
||||||
|
target = target.replacingOccurrences(of: neta.0, with: neta.1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 給 JIS 轉換模式新增疊字符號支援。
|
// 給 JIS 轉換模式新增疊字符號支援。
|
||||||
private static func processKanjiRepeatSymbol(target: inout String) {
|
private static func processKanjiRepeatSymbol(target: inout String) {
|
||||||
guard !target.isEmpty else { return }
|
guard !target.isEmpty else { return }
|
||||||
|
|
Loading…
Reference in New Issue