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

    string

    The 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.upperLimit if 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>) -> Int

    Parameters

    codeUnitRange

    The 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.upperLimit if 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.Index

    Parameters

    characterRange

    The 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.lowerBound and ending at either codeUnitRange.upperBound or 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

    codeUnitRange

    The suggested UTF-16 range of the paragraph in source string.

    direction

    The 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.lowerBound and ending at either codeUnitRange.upperBound or some character before it, in accordance with Rule P1 of Unicode Bidirectional Algorithm.

    The paragraph level is overridden by baseLevel parameter and embedding levels are resolved by applying Rules X1-I2.

    Declaration

    Swift

    public func makeParagraph(codeUnitRange: Range<Int>, baseLevel: UInt8) -> BidiParagraph?

    Parameters

    codeUnitRange

    The suggested UTF-16 range of the paragraph in source string.

    baseLevel

    Base 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.lowerBound and ending at either range.upperBound or 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

    characterRange

    The suggested range of the paragraph in source string.

    direction

    The 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.lowerBound and ending at either range.upperBound or some character before it, in accordance with Rule P1 of Unicode Bidirectional Algorithm.

    The paragraph level is overridden by baseLevel parameter and embedding levels are resolved by applying Rules X1-I2.

    Declaration

    Swift

    public func makeParagraph(characterRange: Range<String.Index>, baseLevel: UInt8) -> BidiParagraph?

    Parameters

    characterRange

    The suggested range of the paragraph in source string.

    baseLevel

    Base level to override.

    Return Value

    A paragraph object processed with Unicode Bidirectional Algorithm.