ChineseConverter

public class ChineseConverter

The ChineseConverter class is used to represent and apply conversion between Traditional Chinese and Simplified Chinese to Unicode strings. An instance of this class is an immutable representation of a compiled conversion pattern.

The ChineseConverter supporting character-level conversion, phrase-level conversion, variant conversion and regional idioms among Mainland China, Taiwan and HongKong

ChineseConverter is designed to be immutable and threadsafe, so that a single instance can be used in conversion on multiple threads at once. However, the string on which it is operating should not be mutated during the course of a conversion.

  • These constants define the ChineseConverter options.

    See more

    Declaration

    Swift

    public struct Options : OptionSet
  • Returns an initialized ChineseConverter instance with the specified conversion option.

    Declaration

    Swift

    public convenience init(bundle: Bundle = .main, option: Options) throws

    Parameters

    bundle

    The bundle in which to search for the dictionary file. This method looks for the dictionary file in the bundle’s Resources/Dictionary/ directory. Default to the main bundle.

    option

    The convert’s option.

  • Return a converted string using the convert’s current option.

    Declaration

    Swift

    public func convert(_ text: String) -> String

    Parameters

    text

    The string to convert.

    Return Value

    A converted string using the convert’s current option.