Skip to content

Commit 3a2ad05

Browse files
committed
[stdlib] Add "isDefined", "hasNormalizationBoundaryBefore" to Unicode.Scalar.Properties
1 parent 354f2ad commit 3a2ad05

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

stdlib/public/core/UnicodeScalarProperties.swift

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,3 +1407,43 @@ extension Unicode.Scalar.Properties {
14071407
return result != icuNoNumericValue ? result : .nan
14081408
}
14091409
}
1410+
1411+
/// Additional queries that do not correspond precisely to a named Unicode
1412+
/// property.
1413+
extension Unicode.Scalar.Properties {
1414+
1415+
/// A Boolean property indicating whether the supported version of Unicode has
1416+
/// assigned a code point to the value of this scalar.
1417+
///
1418+
/// The value of this property may change depending on the platform, operating
1419+
/// system version, and versions of system libraries in use.
1420+
///
1421+
/// ```
1422+
/// print(("A" as Unicode.Scalar).properties.isDefined)
1423+
/// // Prints "true"
1424+
/// print(("\u{ABCDE}" as Unicode.Scalar).properties.isDefined)
1425+
/// // Prints "false"
1426+
/// ```
1427+
public var isDefined: Bool {
1428+
return __swift_stdlib_u_isdefined(_value) != 0
1429+
}
1430+
1431+
/// A Boolean property indicating whether a normalization boundary always
1432+
/// occurs before this scalar.
1433+
///
1434+
/// A normalization boundary is a position in a string where everything to the
1435+
/// left of the boundary can be normalized independently of everything to the
1436+
/// right of the boundary. The concatenation of each such normalization result
1437+
/// is thus the same as if the entire string had been normalized as a whole.
1438+
///
1439+
/// ```
1440+
/// print(("A" as Unicode.Scalar).properties.hasNormalizationBoundaryBefore)
1441+
/// // Prints "true"
1442+
/// print(("\u{0301}" as Unicode.Scalar).properties.hasNormalizationBoundaryBefore)
1443+
/// // Prints "false"
1444+
/// ```
1445+
public var hasNormalizationBoundaryBefore: Bool {
1446+
return __swift_stdlib_unorm2_hasBoundaryBefore(
1447+
_Normalization._nfcNormalizer, _value) != 0
1448+
}
1449+
}

0 commit comments

Comments
 (0)