[swift-corelibs-dev] Measurement Formatters & ICU
Henry Betts
henry.betts at btconnect.com
Mon Aug 22 09:00:10 CDT 2016
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/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-corelibs-dev/attachments/20160822/b0233c8b/attachment.html>
More information about the swift-corelibs-dev
mailing list