Avatar
norio_nomura 1/24/2019 3:21 AM
以前の実装も、UTF8Vewi.IndexUTF16View.IndexもどちらもencodedOffsetは同じ値を返してました。(UTF-16ベース) @swift-4.2.4 @swift-5.0.3 import Foundation let string = "\u{1F600}" print(""" utf8.endIndex.encodedOffset: \(string.utf8.endIndex.encodedOffset) utf16.endIndex.encodedOffset: \(string.utf16.endIndex.encodedOffset) distance in utf8: \(string.utf8.distance(from: string.startIndex, to: string.endIndex)) distance in utf16: \(string.utf16.distance(from: string.startIndex, to: string.endIndex)) """) (edited)