[stdlib] Revert hasNormalizationBoundaryBefore

This property is too specific in that it forces a particular normalization; let's not expose it this way, but instead in the future with a full normalization API.
This commit is contained in:
Tony Allevato
2018-04-22 12:01:03 -07:00
parent ff40d04555
commit 54f4c77ce7
3 changed files with 28 additions and 29 deletions

View File

@@ -68,7 +68,29 @@ internal enum _Normalization {
}
return length == string.count
}
}
extension UnicodeScalar {
// Normalization boundary - a place in a string where everything left of the
// boundary can be normalized independently from everything right of the
// boundary. The concatenation of each result is the same as if the entire
// string had been normalized as a whole.
//
// Normalization segment - a sequence of code units between two normalization
// boundaries (without any boundaries in the middle). Note that normalization
// segments can, as a process of normalization, expand, contract, and even
// produce new sub-segments.
// Whether this scalar value always has a normalization boundary before it.
internal var _hasNormalizationBoundaryBefore: Bool {
_sanityCheck(Int32(exactly: self.value) != nil, "top bit shouldn't be set")
let value = Int32(bitPattern: self.value)
return 0 != __swift_stdlib_unorm2_hasBoundaryBefore(
_Normalization._nfcNormalizer, value)
}
}
extension _Normalization {
// When normalized in NFC, some segments may expand in size (e.g. some non-BMP
// musical notes). This expansion is capped by the maximum expansion factor of
// the normal form. For NFC, that is 3x.