BidiAlgorithm
public class BidiAlgorithm
This class implements Unicode Bidirectional Algorithm available at http://www.unicode.org/reports/tr9.
A BidiAlgorithm object provides information related to individual paragraphs in source string
by applying rule P1. It can be used to create paragraph objects by explicitly specifying the
paragraph level or deriving it from rules P2 and P3. Once a paragraph object is created,
embedding levels of characters can be queried from it.
-
Maximum explicit embedding level.
Declaration
Swift
public static let maxLevel: UInt8 -
Creates a bidi algorithm object for the specified string.
Declaration
Swift
public init?(string: String)Parameters
stringThe string to apply unicode bidirectional algorithm on.
-
Returns the boundary of the first paragraph within the specified UTF-16 range.
The boundary of the paragraph occurs after a character whose bidirectional type is Paragraph Separator (B), or the
codeUnitRange.upperLimitif no such character exists before it. The exception to this rule is when a Carriage Return (CR) is followed by a Line Feed (LF). Both CR and LF are paragraph separators, but in that case, the boundary of the paragraph is considered after LF character.Declaration
Swift
public func paragraphBoundary(inCodeUnitRange codeUnitRange: Range<Int>) -> IntParameters
codeUnitRangeThe suggested UTF-16 range of the paragraph in source string.
Return Value
The boundary of the first paragraph within the specified code unit range.
-
Returns the boundary of the first paragraph within the specified character range.
The boundary of the paragraph occurs after a character whose bidirectional type is Paragraph Separator (B), or the
characterRange.upperLimitif no such character exists before it. The exception to this rule is when a Carriage Return (CR) is followed by a Line Feed (LF). Both CR and LF are paragraph separators, but in that case, the boundary of the paragraph is considered after LF character.Declaration
Swift
public func paragraphBoundary(inCharacterRange characterRange: Range<String.Index>) -> String.IndexParameters
characterRangeThe suggested character range of the paragraph in source string.
Return Value
The boundary of the first paragraph within the specified character range.
-
Creates a paragraph object processed with Unicode Bidirectional Algorithm.
This method processes only first paragraph starting at
codeUnitRange.lowerBoundand ending at eithercodeUnitRange.upperBoundor some character before it, in accordance with Rule P1 of Unicode Bidirectional Algorithm.The paragraph level is determined by applying Rules P2-P3 and embedding levels are resolved by applying Rules X1-I2.
Declaration
Swift
public func makeParagraph(codeUnitRange: Range<Int>, direction: BaseDirection) -> BidiParagraph?Parameters
codeUnitRangeThe suggested UTF-16 range of the paragraph in source string.
directionThe base direction of the paragraph.
Return Value
A paragraph object processed with Unicode Bidirectional Algorithm.
-
Creates a paragraph object processed with Unicode Bidirectional Algorithm.
This method processes only first paragraph starting at
codeUnitRange.lowerBoundand ending at eithercodeUnitRange.upperBoundor some character before it, in accordance with Rule P1 of Unicode Bidirectional Algorithm.The paragraph level is overridden by
baseLevelparameter and embedding levels are resolved by applying Rules X1-I2.Declaration
Swift
public func makeParagraph(codeUnitRange: Range<Int>, baseLevel: UInt8) -> BidiParagraph?Parameters
codeUnitRangeThe suggested UTF-16 range of the paragraph in source string.
baseLevelBase level to override.
Return Value
A paragraph object processed with Unicode Bidirectional Algorithm.
-
Creates a paragraph object processed with Unicode Bidirectional Algorithm.
This method processes only first paragraph starting at
range.lowerBoundand ending at eitherrange.upperBoundor some character before it, in accordance with Rule P1 of Unicode Bidirectional Algorithm.The paragraph level is determined by applying Rules P2-P3 and embedding levels are resolved by applying Rules X1-I2.
Declaration
Swift
public func makeParagraph(characterRange: Range<String.Index>, direction: BaseDirection) -> BidiParagraph?Parameters
characterRangeThe suggested range of the paragraph in source string.
directionThe base direction of the paragraph.
Return Value
A paragraph object processed with Unicode Bidirectional Algorithm.
-
Creates a paragraph object processed with Unicode Bidirectional Algorithm.
This method processes only first paragraph starting at
range.lowerBoundand ending at eitherrange.upperBoundor some character before it, in accordance with Rule P1 of Unicode Bidirectional Algorithm.The paragraph level is overridden by
baseLevelparameter and embedding levels are resolved by applying Rules X1-I2.Declaration
Swift
public func makeParagraph(characterRange: Range<String.Index>, baseLevel: UInt8) -> BidiParagraph?Parameters
characterRangeThe suggested range of the paragraph in source string.
baseLevelBase level to override.
Return Value
A paragraph object processed with Unicode Bidirectional Algorithm.
View on GitHub
Install in Dash
BidiAlgorithm Class Reference