Hi,

I am new to the mailing list, and am interested in contributing to the swift 
project.
 
I’ve been having a play with the ICU library’s unit formatting functions, and 
have created a simple wrapper that could be used by the various measurement 
formatters as well as the date component formatter. At the moment, this wrapper 
is written in swift, but I’m thinking it might make more sense to implement it 
as a core foundation layer, so as not to expose ICU directly to swift.

The interface for this could look something like:

enum CFUnitFormatterStyle{
    
    CFUnitFormatterStyleLong,
    CFUnitFormatterStyleMedium,
    ...
    
};

enum CFUnitFormatterUnit{
    
    CFUnitFormatterUnit_Length_Meter,
    ...
    CFUnitFormatterUnit_Mass_Gram,
    ...
    
};

struct CFUnitFormatterMeasure{
    
    double value;
    CFUnitFormatterUnit unit;
    
};

CFUnitFormatterRef CFUnitFormatterCreate(CFAllocatorRef allocator, CFLocaleRef 
locale, CFUnitFormatterStyle style, CFNumberFormatterRef numberFormatter);

CFStringRef CFUnitFormatterCreateString(CFAllocatorRef allocator, 
CFUnitFormatterRef formatter, double value, CFUnitFormatterUnit unit);

CFStringRef CFUnitFormatterCreateStringWithMeasure(CFAllocatorRef allocator, 
CFUnitFormatterRef formatter, CFUnitFormatterMeasure measure);

CFStringRef CFUnitFormatterCreateStringWithMeasures(CFAllocatorRef allocator, 
CFUnitFormatterRef formatter, CFArrayRef measures);


Looking for any thoughts and suggestions before I begin implementing this.

Henry

---
Henry Betts
henrybetts.co.uk <http://henrybetts.co.uk/>
_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev

Reply via email to