跳到主要內容

發表文章

目前顯示的是 6月, 2016的文章

[IOS] 中文字串比大小

//程式碼 func compartStringByUnicode(string1 string1: String, string2: String, asc: Bool, index: Int)->Bool{ MyVariables.logger.debug("===============> index=\(index), asc=\(asc)") let string1LengthEnough = string1.length > index let string2LengthEnough = string2.length > index if string1LengthEnough && string2LengthEnough { let targetChar1 = string1.characters.map { String($0) }[index] let targetChar2 = string2.characters.map { String($0) }[index] for u1 in targetChar1.utf16 { for u2 in targetChar2.utf16 { if u1 == u2 { return compartStringByUnicode(string1: string1, string2: string2, asc: asc, index: (index+1)) }else{ MyVariables.logger.debug("\(targetChar1) (\(u1), \(targetChar2) (\(u2)) ==> \(u1 < u2)") if asc {