Hi Henry, > On Aug 22, 2016, at 7:00 AM, Henry Betts via swift-corelibs-dev > <swift-corelibs-dev@swift.org> wrote: > > Hi, > > I am new to the mailing list, and am interested in contributing to the swift > project.
Welcome! > > 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 > This approach makes sense - we have been putting stub functions into CF to use ICU, because ICU’s headers are not module-friendly (yet?). Our Darwin implementation also maps to the ICU constants for units (that I’m sure you found). I would love to be able to use ICU from Swift instead of implementing everything twice, but maybe that’s a tall order. - Tony
_______________________________________________ swift-corelibs-dev mailing list swift-corelibs-dev@swift.org https://lists.swift.org/mailman/listinfo/swift-corelibs-dev