CFNumberFormatter

Overview

CFNumberFormatter objects format the textual representations of CFNumber objects, and convert textual representations of numbers into CFNumber objects. The representation encompasses integers, floats, and doubles; floats and doubles can be formatted to a specified decimal position. You specify how strings are formatted and parsed by setting a format string and other properties of a CFNumberFormatter object.

The format of the format string is defined by Unicode Technical Standard #35; the version of the standard used varies with release of the operating system, and is described in Introduction to Data Formatting Programming Guide For Cocoa.

Unlike some other Core Foundation opaque types with names similar to a corresponding Cocoa Foundation class (such as CFString and NSString), CFNumberFormatter objects cannot be cast (“toll-free bridged”) to NSNumberFormatter objects.

Symbols

Creating a Number Formatter

func CFNumberFormatterCreate(CFAllocator!, CFLocale!, CFNumberFormatterStyle)

Creates a new CFNumberFormatter object, localized to the given locale, which will format numbers to the given style.

Configuring a Number Formatter

func CFNumberFormatterSetFormat(CFNumberFormatter!, CFString!)

Sets the format string of a number formatter.

Formatting Values

func CFNumberFormatterCreateStringWithNumber(CFAllocator!, CFNumberFormatter!, CFNumber!)

Returns a string representation of the given number using the specified number formatter.

func CFNumberFormatterCreateStringWithValue(CFAllocator!, CFNumberFormatter!, CFNumberType, UnsafeRawPointer!)

Returns a string representation of the given number or value using the specified number formatter.

func CFNumberFormatterGetDecimalInfoForCurrencyCode(CFString!, UnsafeMutablePointer<Int32>!, UnsafeMutablePointer<Double>!)

Returns the number of fraction digits that should be displayed, and the rounding increment, for a given currency.

Examining a Number Formatter

func CFNumberFormatterCopyProperty(CFNumberFormatter!, CFNumberFormatterKey!)

Returns a copy of a number formatter’s value for a given key.

func CFNumberFormatterGetFormat(CFNumberFormatter!)

Returns a format string for the given number formatter object.

func CFNumberFormatterGetLocale(CFNumberFormatter!)

Returns the locale object used to create the given number formatter object.

func CFNumberFormatterGetStyle(CFNumberFormatter!)

Returns the number style used to create the given number formatter object.

Getting the CFNumberFormatter Type ID

func CFNumberFormatterGetTypeID()

Returns the type identifier for the CFNumberFormatter opaque type.

Data Types

CFNumberFormatterStyle

Type for constants specifying a formatter style.

CFNumberFormatterOptionFlags

Type for constants specifying how numbers should be parsed.

CFNumberFormatterPadPosition

Type for constants specifying how numbers should be padded.

CFNumberFormatter

A reference to a CFNumberFormatter object.

Constants

Number Formatter Styles

Predefined number format styles.

Number Formatter Property Keys

The keys used in key-value pairs to specify the value of number formatter properties.

Number Format Options

These constants are used to specify how numbers should be parsed.

CFNumberFormatterRoundingMode

These constants are used to specify how numbers should be rounded.

Padding Positions

These constants are used to specify how numbers should be padded.