pango 3.2.5-x64-mingw32 → 3.2.6-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/COPYING.LIB +502 -0
- data/README.md +25 -0
- data/Rakefile +8 -8
- data/ext/pango/extconf.rb +4 -1
- data/ext/pango/pango.def +1 -0
- data/ext/pango/rb-pango-attr-list.c +3 -3
- data/ext/pango/rb-pango-attribute.c +67 -57
- data/ext/pango/rb-pango-conversions.h +3 -3
- data/ext/pango/rb-pango-private.h +0 -1
- data/ext/pango/rb-pango.c +0 -1
- data/ext/pango/rb-pango.h +2 -1
- data/lib/2.2/pango.so +0 -0
- data/lib/2.3/pango.so +0 -0
- data/lib/2.4/pango.so +0 -0
- data/lib/2.5/pango.so +0 -0
- data/lib/pango/loader.rb +13 -1
- data/lib/pango/rectangle.rb +7 -1
- data/pango.gemspec +43 -0
- data/vendor/local/bin/derb.exe +0 -0
- data/vendor/local/bin/escapesrc.exe +0 -0
- data/vendor/local/bin/fribidi.exe +0 -0
- data/vendor/local/bin/genbrk.exe +0 -0
- data/vendor/local/bin/genccode.exe +0 -0
- data/vendor/local/bin/gencfu.exe +0 -0
- data/vendor/local/bin/gencmn.exe +0 -0
- data/vendor/local/bin/gencnval.exe +0 -0
- data/vendor/local/bin/gendict.exe +0 -0
- data/vendor/local/bin/gennorm2.exe +0 -0
- data/vendor/local/bin/genrb.exe +0 -0
- data/vendor/local/bin/gensprep.exe +0 -0
- data/vendor/local/bin/hb-ot-shape-closure.exe +0 -0
- data/vendor/local/bin/hb-shape.exe +0 -0
- data/vendor/local/bin/hb-subset.exe +0 -0
- data/vendor/local/bin/hb-view.exe +0 -0
- data/vendor/local/bin/icu-config +13 -8
- data/vendor/local/bin/icuinfo.exe +0 -0
- data/vendor/local/bin/icupkg.exe +0 -0
- data/vendor/local/bin/libfribidi-0.dll +0 -0
- data/vendor/local/bin/libgraphene-1.0-0.dll +0 -0
- data/vendor/local/bin/libharfbuzz-0.dll +0 -0
- data/vendor/local/bin/libharfbuzz-subset-0.dll +0 -0
- data/vendor/local/bin/libpango-1.0-0.dll +0 -0
- data/vendor/local/bin/libpangocairo-1.0-0.dll +0 -0
- data/vendor/local/bin/libpangoft2-1.0-0.dll +0 -0
- data/vendor/local/bin/libpangowin32-1.0-0.dll +0 -0
- data/vendor/local/bin/makeconv.exe +0 -0
- data/vendor/local/bin/pango-view.exe +0 -0
- data/vendor/local/bin/pkgdata.exe +0 -0
- data/vendor/local/bin/uconv.exe +0 -0
- data/vendor/local/include/fribidi/fribidi-config.h +2 -2
- data/vendor/local/include/harfbuzz/hb-blob.h +2 -0
- data/vendor/local/include/harfbuzz/hb-common.h +24 -3
- data/vendor/local/include/harfbuzz/hb-face.h +4 -0
- data/vendor/local/include/harfbuzz/hb-map.h +104 -0
- data/vendor/local/include/harfbuzz/hb-ot-layout.h +1 -1
- data/vendor/local/include/harfbuzz/hb-set.h +0 -2
- data/vendor/local/include/harfbuzz/hb-subset-plan.hh +46 -25
- data/vendor/local/include/harfbuzz/hb-subset.h +4 -1
- data/vendor/local/include/harfbuzz/hb-version.h +3 -3
- data/vendor/local/include/harfbuzz/hb.h +1 -0
- data/vendor/local/include/pango-1.0/pango/pango-features.h +2 -2
- data/vendor/local/include/unicode/alphaindex.h +2 -1
- data/vendor/local/include/unicode/appendable.h +25 -25
- data/vendor/local/include/unicode/basictz.h +1 -1
- data/vendor/local/include/unicode/brkiter.h +19 -24
- data/vendor/local/include/unicode/bytestream.h +26 -13
- data/vendor/local/include/unicode/bytestrie.h +2 -2
- data/vendor/local/include/unicode/bytestriebuilder.h +4 -5
- data/vendor/local/include/unicode/calendar.h +11 -11
- data/vendor/local/include/unicode/caniter.h +3 -3
- data/vendor/local/include/unicode/casemap.h +494 -0
- data/vendor/local/include/unicode/char16ptr.h +302 -0
- data/vendor/local/include/unicode/chariter.h +22 -18
- data/vendor/local/include/unicode/choicfmt.h +1 -1
- data/vendor/local/include/unicode/coleitr.h +2 -1
- data/vendor/local/include/unicode/coll.h +17 -17
- data/vendor/local/include/unicode/compactdecimalformat.h +10 -2
- data/vendor/local/include/unicode/curramt.h +5 -5
- data/vendor/local/include/unicode/currpinf.h +1 -1
- data/vendor/local/include/unicode/currunit.h +24 -6
- data/vendor/local/include/unicode/datefmt.h +3 -2
- data/vendor/local/include/unicode/dbbi.h +1 -1
- data/vendor/local/include/unicode/dcfmtsym.h +89 -13
- data/vendor/local/include/unicode/decimfmt.h +38 -39
- data/vendor/local/include/unicode/docmain.h +7 -2
- data/vendor/local/include/unicode/dtfmtsym.h +7 -6
- data/vendor/local/include/unicode/dtintrv.h +2 -2
- data/vendor/local/include/unicode/dtitvfmt.h +2 -2
- data/vendor/local/include/unicode/dtitvinf.h +1 -3
- data/vendor/local/include/unicode/dtptngen.h +48 -24
- data/vendor/local/include/unicode/dtrule.h +1 -1
- data/vendor/local/include/unicode/edits.h +424 -0
- data/vendor/local/include/unicode/enumset.h +1 -1
- data/vendor/local/include/unicode/errorcode.h +2 -2
- data/vendor/local/include/unicode/fieldpos.h +1 -1
- data/vendor/local/include/unicode/filteredbrk.h +35 -5
- data/vendor/local/include/unicode/fmtable.h +1 -1
- data/vendor/local/include/unicode/format.h +1 -1
- data/vendor/local/include/unicode/fpositer.h +11 -3
- data/vendor/local/include/unicode/gender.h +1 -1
- data/vendor/local/include/unicode/gregocal.h +1 -1
- data/vendor/local/include/unicode/icudataver.h +1 -1
- data/vendor/local/include/unicode/icuplug.h +1 -1
- data/vendor/local/include/unicode/idna.h +2 -2
- data/vendor/local/include/unicode/listformatter.h +4 -2
- data/vendor/local/include/unicode/localpointer.h +6 -43
- data/vendor/local/include/unicode/locdspnm.h +2 -1
- data/vendor/local/include/unicode/locid.h +7 -6
- data/vendor/local/include/unicode/measfmt.h +18 -7
- data/vendor/local/include/unicode/measunit.h +31 -60
- data/vendor/local/include/unicode/measure.h +1 -1
- data/vendor/local/include/unicode/messagepattern.h +2 -2
- data/vendor/local/include/unicode/msgfmt.h +2 -2
- data/vendor/local/include/unicode/normalizer2.h +130 -16
- data/vendor/local/include/unicode/normlzr.h +5 -5
- data/vendor/local/include/unicode/nounit.h +111 -0
- data/vendor/local/include/unicode/numberformatter.h +2194 -0
- data/vendor/local/include/unicode/numfmt.h +81 -7
- data/vendor/local/include/unicode/numsys.h +2 -2
- data/vendor/local/include/unicode/parseerr.h +3 -3
- data/vendor/local/include/unicode/parsepos.h +1 -1
- data/vendor/local/include/unicode/platform.h +66 -63
- data/vendor/local/include/unicode/plurfmt.h +1 -1
- data/vendor/local/include/unicode/plurrule.h +23 -4
- data/vendor/local/include/unicode/ptypes.h +1 -1
- data/vendor/local/include/unicode/putil.h +4 -4
- data/vendor/local/include/unicode/rbbi.h +105 -134
- data/vendor/local/include/unicode/rbnf.h +65 -3
- data/vendor/local/include/unicode/rbtz.h +1 -1
- data/vendor/local/include/unicode/regex.h +17 -17
- data/vendor/local/include/unicode/region.h +1 -1
- data/vendor/local/include/unicode/reldatefmt.h +4 -5
- data/vendor/local/include/unicode/rep.h +4 -4
- data/vendor/local/include/unicode/resbund.h +3 -3
- data/vendor/local/include/unicode/schriter.h +3 -3
- data/vendor/local/include/unicode/scientificnumberformatter.h +1 -1
- data/vendor/local/include/unicode/search.h +1 -1
- data/vendor/local/include/unicode/selfmt.h +1 -1
- data/vendor/local/include/unicode/simpleformatter.h +31 -25
- data/vendor/local/include/unicode/simpletz.h +5 -3
- data/vendor/local/include/unicode/smpdtfmt.h +17 -7
- data/vendor/local/include/unicode/sortkey.h +1 -1
- data/vendor/local/include/unicode/std_string.h +6 -8
- data/vendor/local/include/unicode/strenum.h +5 -5
- data/vendor/local/include/unicode/stringoptions.h +198 -0
- data/vendor/local/include/unicode/stringpiece.h +1 -3
- data/vendor/local/include/unicode/stringtriebuilder.h +19 -19
- data/vendor/local/include/unicode/stsearch.h +1 -1
- data/vendor/local/include/unicode/symtable.h +1 -1
- data/vendor/local/include/unicode/tblcoll.h +13 -13
- data/vendor/local/include/unicode/timezone.h +5 -5
- data/vendor/local/include/unicode/tmunit.h +1 -1
- data/vendor/local/include/unicode/tmutamt.h +1 -1
- data/vendor/local/include/unicode/tmutfmt.h +1 -1
- data/vendor/local/include/unicode/translit.h +2 -2
- data/vendor/local/include/unicode/tzfmt.h +4 -4
- data/vendor/local/include/unicode/tznames.h +3 -5
- data/vendor/local/include/unicode/tzrule.h +1 -1
- data/vendor/local/include/unicode/tztrans.h +1 -1
- data/vendor/local/include/unicode/ubidi.h +11 -8
- data/vendor/local/include/unicode/ubiditransform.h +16 -19
- data/vendor/local/include/unicode/ubrk.h +61 -4
- data/vendor/local/include/unicode/ucal.h +3 -3
- data/vendor/local/include/unicode/ucasemap.h +7 -47
- data/vendor/local/include/unicode/ucat.h +1 -1
- data/vendor/local/include/unicode/uchar.h +62 -37
- data/vendor/local/include/unicode/ucharstrie.h +48 -48
- data/vendor/local/include/unicode/ucharstriebuilder.h +12 -12
- data/vendor/local/include/unicode/uchriter.h +33 -29
- data/vendor/local/include/unicode/uclean.h +15 -13
- data/vendor/local/include/unicode/ucnv.h +11 -11
- data/vendor/local/include/unicode/ucnv_cb.h +1 -1
- data/vendor/local/include/unicode/ucnv_err.h +7 -7
- data/vendor/local/include/unicode/ucnvsel.h +1 -1
- data/vendor/local/include/unicode/ucol.h +6 -6
- data/vendor/local/include/unicode/ucoleitr.h +3 -3
- data/vendor/local/include/unicode/uconfig.h +8 -5
- data/vendor/local/include/unicode/ucsdet.h +7 -3
- data/vendor/local/include/unicode/ucurr.h +14 -1
- data/vendor/local/include/unicode/udat.h +39 -41
- data/vendor/local/include/unicode/udata.h +2 -2
- data/vendor/local/include/unicode/udateintervalformat.h +1 -1
- data/vendor/local/include/unicode/udatpg.h +56 -5
- data/vendor/local/include/unicode/udisplaycontext.h +4 -8
- data/vendor/local/include/unicode/uenum.h +5 -3
- data/vendor/local/include/unicode/ufieldpositer.h +1 -1
- data/vendor/local/include/unicode/uformattable.h +2 -2
- data/vendor/local/include/unicode/ugender.h +1 -1
- data/vendor/local/include/unicode/uidna.h +2 -2
- data/vendor/local/include/unicode/uiter.h +2 -2
- data/vendor/local/include/unicode/uldnames.h +1 -1
- data/vendor/local/include/unicode/ulistformatter.h +4 -4
- data/vendor/local/include/unicode/uloc.h +29 -16
- data/vendor/local/include/unicode/ulocdata.h +5 -5
- data/vendor/local/include/unicode/umachine.h +81 -38
- data/vendor/local/include/unicode/umisc.h +2 -2
- data/vendor/local/include/unicode/umsg.h +2 -2
- data/vendor/local/include/unicode/unifilt.h +2 -2
- data/vendor/local/include/unicode/unifunct.h +1 -1
- data/vendor/local/include/unicode/unimatch.h +1 -1
- data/vendor/local/include/unicode/unirepl.h +1 -1
- data/vendor/local/include/unicode/uniset.h +5 -4
- data/vendor/local/include/unicode/unistr.h +322 -208
- data/vendor/local/include/unicode/unorm.h +9 -9
- data/vendor/local/include/unicode/unorm2.h +3 -26
- data/vendor/local/include/unicode/unum.h +71 -11
- data/vendor/local/include/unicode/unumsys.h +1 -1
- data/vendor/local/include/unicode/uobject.h +2 -2
- data/vendor/local/include/unicode/upluralrules.h +51 -6
- data/vendor/local/include/unicode/uregex.h +2 -2
- data/vendor/local/include/unicode/uregion.h +2 -2
- data/vendor/local/include/unicode/ureldatefmt.h +33 -39
- data/vendor/local/include/unicode/urename.h +18 -17
- data/vendor/local/include/unicode/urep.h +1 -1
- data/vendor/local/include/unicode/ures.h +9 -9
- data/vendor/local/include/unicode/uscript.h +10 -3
- data/vendor/local/include/unicode/usearch.h +3 -3
- data/vendor/local/include/unicode/uset.h +2 -2
- data/vendor/local/include/unicode/usetiter.h +1 -1
- data/vendor/local/include/unicode/ushape.h +3 -3
- data/vendor/local/include/unicode/uspoof.h +24 -29
- data/vendor/local/include/unicode/usprep.h +7 -7
- data/vendor/local/include/unicode/ustdio.h +1 -1
- data/vendor/local/include/unicode/ustream.h +2 -9
- data/vendor/local/include/unicode/ustring.h +3 -13
- data/vendor/local/include/unicode/ustringtrie.h +2 -2
- data/vendor/local/include/unicode/utext.h +16 -16
- data/vendor/local/include/unicode/utf.h +19 -19
- data/vendor/local/include/unicode/utf16.h +128 -8
- data/vendor/local/include/unicode/utf32.h +2 -2
- data/vendor/local/include/unicode/utf8.h +177 -121
- data/vendor/local/include/unicode/utf_old.h +40 -7
- data/vendor/local/include/unicode/utmscale.h +8 -1
- data/vendor/local/include/unicode/utrace.h +4 -4
- data/vendor/local/include/unicode/utrans.h +3 -3
- data/vendor/local/include/unicode/utypes.h +13 -10
- data/vendor/local/include/unicode/uvernum.h +18 -11
- data/vendor/local/include/unicode/uversion.h +10 -4
- data/vendor/local/include/unicode/vtzone.h +1 -1
- data/vendor/local/lib/cmake/harfbuzz/harfbuzz-config.cmake +1 -1
- data/vendor/local/lib/icu/{58.2 → 61.1}/Makefile.inc +7 -7
- data/vendor/local/lib/icu/{58.2 → 61.1}/pkgdata.inc +2 -2
- data/vendor/local/lib/icu/Makefile.inc +7 -7
- data/vendor/local/lib/icu/pkgdata.inc +2 -2
- data/vendor/local/lib/icudt.dll +0 -0
- data/vendor/local/lib/{icudt58.dll → icudt61.dll} +0 -0
- data/vendor/local/lib/icuin.dll +0 -0
- data/vendor/local/lib/icuin61.dll +0 -0
- data/vendor/local/lib/icuio.dll +0 -0
- data/vendor/local/lib/{icuio58.dll → icuio61.dll} +0 -0
- data/vendor/local/lib/icutest.dll +0 -0
- data/vendor/local/lib/{icutest58.dll → icutest61.dll} +0 -0
- data/vendor/local/lib/icutu.dll +0 -0
- data/vendor/local/lib/icutu61.dll +0 -0
- data/vendor/local/lib/icuuc.dll +0 -0
- data/vendor/local/lib/icuuc61.dll +0 -0
- data/vendor/local/lib/libfribidi.dll.a +0 -0
- data/vendor/local/lib/libgraphene-1.0.dll.a +0 -0
- data/vendor/local/lib/libharfbuzz-icu.a +0 -0
- data/vendor/local/lib/libharfbuzz-icu.la +3 -3
- data/vendor/local/lib/libharfbuzz-subset.dll.a +0 -0
- data/vendor/local/lib/libharfbuzz-subset.la +3 -3
- data/vendor/local/lib/libharfbuzz.dll.a +0 -0
- data/vendor/local/lib/libharfbuzz.la +3 -3
- data/vendor/local/lib/libicudt.dll.a +0 -0
- data/vendor/local/lib/libicuin.dll.a +0 -0
- data/vendor/local/lib/libicuio.dll.a +0 -0
- data/vendor/local/lib/libicutest.dll.a +0 -0
- data/vendor/local/lib/libicutu.dll.a +0 -0
- data/vendor/local/lib/libicuuc.dll.a +0 -0
- data/vendor/local/lib/libpango-1.0.dll.a +0 -0
- data/vendor/local/lib/libpango-1.0.la +2 -2
- data/vendor/local/lib/libpangocairo-1.0.dll.a +0 -0
- data/vendor/local/lib/libpangocairo-1.0.la +2 -2
- data/vendor/local/lib/libpangoft2-1.0.dll.a +0 -0
- data/vendor/local/lib/libpangoft2-1.0.la +2 -2
- data/vendor/local/lib/libpangowin32-1.0.dll.a +0 -0
- data/vendor/local/lib/libpangowin32-1.0.la +2 -2
- data/vendor/local/lib/pkgconfig/fribidi.pc +1 -1
- data/vendor/local/lib/pkgconfig/harfbuzz-icu.pc +1 -1
- data/vendor/local/lib/pkgconfig/harfbuzz-subset.pc +1 -1
- data/vendor/local/lib/pkgconfig/harfbuzz.pc +1 -1
- data/vendor/local/lib/pkgconfig/icu-i18n.pc +7 -7
- data/vendor/local/lib/pkgconfig/icu-io.pc +7 -7
- data/vendor/local/lib/pkgconfig/icu-uc.pc +7 -7
- data/vendor/local/lib/pkgconfig/pango.pc +2 -2
- data/vendor/local/lib/pkgconfig/pangocairo.pc +2 -2
- data/vendor/local/lib/pkgconfig/pangoft2.pc +2 -2
- data/vendor/local/lib/pkgconfig/pangowin32.pc +1 -1
- data/vendor/local/libexec/installed-tests/graphene-1.0/box.exe +0 -0
- data/vendor/local/libexec/installed-tests/graphene-1.0/euler.exe +0 -0
- data/vendor/local/libexec/installed-tests/graphene-1.0/frustum.exe +0 -0
- data/vendor/local/libexec/installed-tests/graphene-1.0/matrix.exe +0 -0
- data/vendor/local/libexec/installed-tests/graphene-1.0/plane.exe +0 -0
- data/vendor/local/libexec/installed-tests/graphene-1.0/point.exe +0 -0
- data/vendor/local/libexec/installed-tests/graphene-1.0/point3d.exe +0 -0
- data/vendor/local/libexec/installed-tests/graphene-1.0/quad.exe +0 -0
- data/vendor/local/libexec/installed-tests/graphene-1.0/quaternion.exe +0 -0
- data/vendor/local/libexec/installed-tests/graphene-1.0/ray.exe +0 -0
- data/vendor/local/libexec/installed-tests/graphene-1.0/rect.exe +0 -0
- data/vendor/local/libexec/installed-tests/graphene-1.0/simd.exe +0 -0
- data/vendor/local/libexec/installed-tests/graphene-1.0/size.exe +0 -0
- data/vendor/local/libexec/installed-tests/graphene-1.0/sphere.exe +0 -0
- data/vendor/local/libexec/installed-tests/graphene-1.0/triangle.exe +0 -0
- data/vendor/local/libexec/installed-tests/graphene-1.0/vec2.exe +0 -0
- data/vendor/local/libexec/installed-tests/graphene-1.0/vec3.exe +0 -0
- data/vendor/local/libexec/installed-tests/graphene-1.0/vec4.exe +0 -0
- data/vendor/local/share/gtk-doc/html/harfbuzz/harfbuzz-Buffers.html +5 -3
- data/vendor/local/share/gtk-doc/html/harfbuzz/harfbuzz-hb-common.html +5 -0
- data/vendor/local/share/gtk-doc/html/harfbuzz/harfbuzz.devhelp2 +1 -0
- data/vendor/local/share/gtk-doc/html/harfbuzz/pt02.html +1 -1
- data/vendor/local/share/gtk-doc/html/pango/index.html +1 -1
- data/vendor/local/share/gtk-doc/html/pango/pango-Version-Checking.html +2 -2
- data/vendor/local/share/icu/{58.2 → 61.1}/LICENSE +32 -3
- data/vendor/local/share/icu/{58.2 → 61.1}/config/mh-mingw64 +4 -0
- data/vendor/local/share/icu/{58.2 → 61.1}/install-sh +0 -0
- data/vendor/local/share/icu/{58.2 → 61.1}/mkinstalldirs +0 -0
- data/vendor/local/share/man/man1/derb.1 +2 -2
- data/vendor/local/share/man/man1/genbrk.1 +2 -2
- data/vendor/local/share/man/man1/gencfu.1 +1 -1
- data/vendor/local/share/man/man1/gencnval.1 +3 -3
- data/vendor/local/share/man/man1/gendict.1 +2 -2
- data/vendor/local/share/man/man1/genrb.1 +3 -3
- data/vendor/local/share/man/man1/icu-config.1 +2 -2
- data/vendor/local/share/man/man1/makeconv.1 +5 -5
- data/vendor/local/share/man/man1/pkgdata.1 +2 -2
- data/vendor/local/share/man/man1/uconv.1 +9 -9
- data/vendor/local/share/man/man3/fribidi_charset_to_unicode.3 +98 -0
- data/vendor/local/share/man/man3/fribidi_debug_status.3 +44 -0
- data/vendor/local/share/man/man3/fribidi_get_bidi_type.3 +58 -0
- data/vendor/local/share/man/man3/fribidi_get_bidi_type_name.3 +56 -0
- data/vendor/local/share/man/man3/fribidi_get_bidi_types.3 +68 -0
- data/vendor/local/share/man/man3/fribidi_get_bracket.3 +59 -0
- data/vendor/local/share/man/man3/fribidi_get_bracket_types.3 +73 -0
- data/vendor/local/share/man/man3/fribidi_get_joining_type.3 +87 -0
- data/vendor/local/share/man/man3/fribidi_get_joining_type_name.3 +83 -0
- data/vendor/local/share/man/man3/fribidi_get_joining_types.3 +96 -0
- data/vendor/local/share/man/man3/fribidi_get_mirror_char.3 +68 -0
- data/vendor/local/share/man/man3/fribidi_get_par_direction.3 +100 -0
- data/vendor/local/share/man/man3/fribidi_get_par_embedding_levels.3 +98 -0
- data/vendor/local/share/man/man3/fribidi_get_par_embedding_levels_ex.3 +114 -0
- data/vendor/local/share/man/man3/fribidi_get_type.3 +50 -0
- data/vendor/local/share/man/man3/fribidi_get_type_internal.3 +50 -0
- data/vendor/local/share/man/man3/fribidi_join_arabic.3 +92 -0
- data/vendor/local/share/man/man3/fribidi_log2vis.3 +124 -0
- data/vendor/local/share/man/man3/fribidi_log2vis_get_embedding_levels.3 +97 -0
- data/vendor/local/share/man/man3/fribidi_mirroring_status.3 +44 -0
- data/vendor/local/share/man/man3/fribidi_parse_charset.3 +78 -0
- data/vendor/local/share/man/man3/fribidi_remove_bidi_marks.3 +96 -0
- data/vendor/local/share/man/man3/fribidi_reorder_line.3 +146 -0
- data/vendor/local/share/man/man3/fribidi_reorder_nsm_status.3 +44 -0
- data/vendor/local/share/man/man3/fribidi_set_debug.3 +48 -0
- data/vendor/local/share/man/man3/fribidi_set_mirroring.3 +58 -0
- data/vendor/local/share/man/man3/fribidi_set_reorder_nsm.3 +60 -0
- data/vendor/local/share/man/man3/fribidi_shape.3 +89 -0
- data/vendor/local/share/man/man3/fribidi_shape_arabic.3 +95 -0
- data/vendor/local/share/man/man3/fribidi_shape_mirroring.3 +71 -0
- data/vendor/local/share/man/man3/fribidi_unicode_to_charset.3 +99 -0
- data/vendor/local/share/man/man8/genccode.8 +2 -2
- data/vendor/local/share/man/man8/gencmn.8 +3 -3
- data/vendor/local/share/man/man8/gensprep.8 +3 -3
- data/vendor/local/share/man/man8/icupkg.8 +1 -1
- metadata +58 -59
- data/ext/pango/rb-pango-context.c +0 -79
- data/vendor/local/lib/icuin58.dll +0 -0
- data/vendor/local/lib/icutu58.dll +0 -0
- data/vendor/local/lib/icuuc58.dll +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
//
|
1
|
+
// © 2016 and later: Unicode, Inc. and others.
|
2
2
|
// License & terms of use: http://www.unicode.org/copyright.html
|
3
3
|
/*
|
4
4
|
********************************************************************
|
@@ -168,7 +168,7 @@ public:
|
|
168
168
|
* @param mode The normalization mode.
|
169
169
|
* @deprecated ICU 56 Use Normalizer2 instead.
|
170
170
|
*/
|
171
|
-
Normalizer(
|
171
|
+
Normalizer(ConstChar16Ptr str, int32_t length, UNormalizationMode mode);
|
172
172
|
|
173
173
|
/**
|
174
174
|
* Creates a new <code>Normalizer</code> object for iterating over the
|
@@ -704,7 +704,7 @@ public:
|
|
704
704
|
* @param status a UErrorCode
|
705
705
|
* @deprecated ICU 56 Use Normalizer2 instead.
|
706
706
|
*/
|
707
|
-
void setText(
|
707
|
+
void setText(ConstChar16Ptr newText,
|
708
708
|
int32_t length,
|
709
709
|
UErrorCode &status);
|
710
710
|
/**
|
@@ -796,8 +796,8 @@ Normalizer::compare(const UnicodeString &s1, const UnicodeString &s2,
|
|
796
796
|
uint32_t options,
|
797
797
|
UErrorCode &errorCode) {
|
798
798
|
// all argument checking is done in unorm_compare
|
799
|
-
return unorm_compare(s1.getBuffer(), s1.length(),
|
800
|
-
s2.getBuffer(), s2.length(),
|
799
|
+
return unorm_compare(toUCharPtr(s1.getBuffer()), s1.length(),
|
800
|
+
toUCharPtr(s2.getBuffer()), s2.length(),
|
801
801
|
options,
|
802
802
|
&errorCode);
|
803
803
|
}
|
@@ -0,0 +1,111 @@
|
|
1
|
+
// © 2017 and later: Unicode, Inc. and others.
|
2
|
+
// License & terms of use: http://www.unicode.org/copyright.html
|
3
|
+
/*
|
4
|
+
*******************************************************************************
|
5
|
+
* Copyright (C) 2009-2017, International Business Machines Corporation, *
|
6
|
+
* Google, and others. All Rights Reserved. *
|
7
|
+
*******************************************************************************
|
8
|
+
*/
|
9
|
+
|
10
|
+
#ifndef __NOUNIT_H__
|
11
|
+
#define __NOUNIT_H__
|
12
|
+
|
13
|
+
#include "unicode/utypes.h"
|
14
|
+
|
15
|
+
#if !UCONFIG_NO_FORMATTING
|
16
|
+
|
17
|
+
#include "unicode/measunit.h"
|
18
|
+
|
19
|
+
/**
|
20
|
+
* \file
|
21
|
+
* \brief C++ API: units for percent and permille
|
22
|
+
*/
|
23
|
+
|
24
|
+
U_NAMESPACE_BEGIN
|
25
|
+
|
26
|
+
#ifndef U_HIDE_DRAFT_API
|
27
|
+
/**
|
28
|
+
* Dimensionless unit for percent and permille.
|
29
|
+
* @see NumberFormatter
|
30
|
+
* @draft ICU 60
|
31
|
+
*/
|
32
|
+
class U_I18N_API NoUnit: public MeasureUnit {
|
33
|
+
public:
|
34
|
+
/**
|
35
|
+
* Returns an instance for the base unit (dimensionless and no scaling).
|
36
|
+
*
|
37
|
+
* @return a NoUnit instance
|
38
|
+
* @draft ICU 60
|
39
|
+
*/
|
40
|
+
static NoUnit U_EXPORT2 base();
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Returns an instance for percent, or 1/100 of a base unit.
|
44
|
+
*
|
45
|
+
* @return a NoUnit instance
|
46
|
+
* @draft ICU 60
|
47
|
+
*/
|
48
|
+
static NoUnit U_EXPORT2 percent();
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Returns an instance for permille, or 1/1000 of a base unit.
|
52
|
+
*
|
53
|
+
* @return a NoUnit instance
|
54
|
+
* @draft ICU 60
|
55
|
+
*/
|
56
|
+
static NoUnit U_EXPORT2 permille();
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Copy operator.
|
60
|
+
* @draft ICU 60
|
61
|
+
*/
|
62
|
+
NoUnit(const NoUnit& other);
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Return a polymorphic clone of this object. The result will
|
66
|
+
* have the same class as returned by getDynamicClassID().
|
67
|
+
* @draft ICU 60
|
68
|
+
*/
|
69
|
+
virtual UObject* clone() const;
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Returns a unique class ID for this object POLYMORPHICALLY.
|
73
|
+
* This method implements a simple form of RTTI used by ICU.
|
74
|
+
* @return The class ID for this object. All objects of a given
|
75
|
+
* class have the same class ID. Objects of other classes have
|
76
|
+
* different class IDs.
|
77
|
+
* @draft ICU 60
|
78
|
+
*/
|
79
|
+
virtual UClassID getDynamicClassID() const;
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Returns the class ID for this class. This is used to compare to
|
83
|
+
* the return value of getDynamicClassID().
|
84
|
+
* @return The class ID for all objects of this class.
|
85
|
+
* @draft ICU 60
|
86
|
+
*/
|
87
|
+
static UClassID U_EXPORT2 getStaticClassID();
|
88
|
+
|
89
|
+
/**
|
90
|
+
* Destructor.
|
91
|
+
* @draft ICU 60
|
92
|
+
*/
|
93
|
+
virtual ~NoUnit();
|
94
|
+
|
95
|
+
private:
|
96
|
+
/**
|
97
|
+
* Constructor
|
98
|
+
* @internal (private)
|
99
|
+
*/
|
100
|
+
NoUnit(const char* subtype);
|
101
|
+
|
102
|
+
};
|
103
|
+
#endif /* U_HIDE_DRAFT_API */
|
104
|
+
|
105
|
+
U_NAMESPACE_END
|
106
|
+
|
107
|
+
#endif /* #if !UCONFIG_NO_FORMATTING */
|
108
|
+
|
109
|
+
#endif // __NOUNIT_H__
|
110
|
+
//eof
|
111
|
+
//
|
@@ -0,0 +1,2194 @@
|
|
1
|
+
// © 2017 and later: Unicode, Inc. and others.
|
2
|
+
// License & terms of use: http://www.unicode.org/copyright.html
|
3
|
+
|
4
|
+
#include "unicode/utypes.h"
|
5
|
+
|
6
|
+
#if !UCONFIG_NO_FORMATTING
|
7
|
+
#ifndef __NUMBERFORMATTER_H__
|
8
|
+
#define __NUMBERFORMATTER_H__
|
9
|
+
|
10
|
+
#include "unicode/appendable.h"
|
11
|
+
#include "unicode/dcfmtsym.h"
|
12
|
+
#include "unicode/currunit.h"
|
13
|
+
#include "unicode/fieldpos.h"
|
14
|
+
#include "unicode/fpositer.h"
|
15
|
+
#include "unicode/measunit.h"
|
16
|
+
#include "unicode/nounit.h"
|
17
|
+
#include "unicode/plurrule.h"
|
18
|
+
#include "unicode/ucurr.h"
|
19
|
+
#include "unicode/unum.h"
|
20
|
+
|
21
|
+
#ifndef U_HIDE_DRAFT_API
|
22
|
+
|
23
|
+
/**
|
24
|
+
* \file
|
25
|
+
* \brief C++ API: Library for localized number formatting introduced in ICU 60.
|
26
|
+
*
|
27
|
+
* This library was introduced in ICU 60 to simplify the process of formatting localized number strings.
|
28
|
+
* Basic usage examples:
|
29
|
+
*
|
30
|
+
* <pre>
|
31
|
+
* // Most basic usage:
|
32
|
+
* NumberFormatter::withLocale(...).format(123).toString(); // 1,234 in en-US
|
33
|
+
*
|
34
|
+
* // Custom notation, unit, and rounding strategy:
|
35
|
+
* NumberFormatter::with()
|
36
|
+
* .notation(Notation::compactShort())
|
37
|
+
* .unit(CurrencyUnit("EUR", status))
|
38
|
+
* .rounding(Rounder::maxDigits(2))
|
39
|
+
* .locale(...)
|
40
|
+
* .format(1234)
|
41
|
+
* .toString(); // €1.2K in en-US
|
42
|
+
*
|
43
|
+
* // Create a formatter in a singleton for use later:
|
44
|
+
* static const LocalizedNumberFormatter formatter = NumberFormatter::withLocale(...)
|
45
|
+
* .unit(NoUnit::percent())
|
46
|
+
* .rounding(Rounder::fixedFraction(3));
|
47
|
+
* formatter.format(5.9831).toString(); // 5.983% in en-US
|
48
|
+
*
|
49
|
+
* // Create a "template" in a singleton but without setting a locale until the call site:
|
50
|
+
* static const UnlocalizedNumberFormatter template = NumberFormatter::with()
|
51
|
+
* .sign(UNumberSignDisplay::UNUM_SIGN_ALWAYS)
|
52
|
+
* .adoptUnit(MeasureUnit::createMeter(status))
|
53
|
+
* .unitWidth(UNumberUnitWidth::UNUM_UNIT_WIDTH_FULL_NAME);
|
54
|
+
* template.locale(...).format(1234).toString(); // +1,234 meters in en-US
|
55
|
+
* </pre>
|
56
|
+
*
|
57
|
+
* <p>
|
58
|
+
* This API offers more features than DecimalFormat and is geared toward new users of ICU.
|
59
|
+
*
|
60
|
+
* <p>
|
61
|
+
* NumberFormatter instances are immutable and thread safe. This means that invoking a configuration method has no
|
62
|
+
* effect on the receiving instance; you must store and use the new number formatter instance it returns instead.
|
63
|
+
*
|
64
|
+
* <pre>
|
65
|
+
* UnlocalizedNumberFormatter formatter = UnlocalizedNumberFormatter::with().notation(Notation::scientific());
|
66
|
+
* formatter.rounding(Rounder.maxFraction(2)); // does nothing!
|
67
|
+
* formatter.locale(Locale.getEnglish()).format(9.8765).toString(); // prints "9.8765E0", not "9.88E0"
|
68
|
+
* </pre>
|
69
|
+
*
|
70
|
+
* <p>
|
71
|
+
* This API is based on the <em>fluent</em> design pattern popularized by libraries such as Google's Guava. For
|
72
|
+
* extensive details on the design of this API, read <a href="https://goo.gl/szi5VB">the design doc</a>.
|
73
|
+
*
|
74
|
+
* @author Shane Carr
|
75
|
+
*/
|
76
|
+
|
77
|
+
/**
|
78
|
+
* An enum declaring how to render units, including currencies. Example outputs when formatting 123 USD and 123
|
79
|
+
* meters in <em>en-CA</em>:
|
80
|
+
*
|
81
|
+
* <p>
|
82
|
+
* <ul>
|
83
|
+
* <li>NARROW*: "$123.00" and "123 m"
|
84
|
+
* <li>SHORT: "US$ 123.00" and "123 m"
|
85
|
+
* <li>FULL_NAME: "123.00 US dollars" and "123 meters"
|
86
|
+
* <li>ISO_CODE: "USD 123.00" and undefined behavior
|
87
|
+
* <li>HIDDEN: "123.00" and "123"
|
88
|
+
* </ul>
|
89
|
+
*
|
90
|
+
* <p>
|
91
|
+
* This enum is similar to {@link com.ibm.icu.text.MeasureFormat.FormatWidth}.
|
92
|
+
*
|
93
|
+
* @draft ICU 60
|
94
|
+
*/
|
95
|
+
typedef enum UNumberUnitWidth {
|
96
|
+
/**
|
97
|
+
* Print an abbreviated version of the unit name. Similar to SHORT, but always use the shortest available
|
98
|
+
* abbreviation or symbol. This option can be used when the context hints at the identity of the unit. For more
|
99
|
+
* information on the difference between NARROW and SHORT, see SHORT.
|
100
|
+
*
|
101
|
+
* <p>
|
102
|
+
* In CLDR, this option corresponds to the "Narrow" format for measure units and the "¤¤¤¤¤" placeholder for
|
103
|
+
* currencies.
|
104
|
+
*
|
105
|
+
* @draft ICU 60
|
106
|
+
*/
|
107
|
+
UNUM_UNIT_WIDTH_NARROW,
|
108
|
+
|
109
|
+
/**
|
110
|
+
* Print an abbreviated version of the unit name. Similar to NARROW, but use a slightly wider abbreviation or
|
111
|
+
* symbol when there may be ambiguity. This is the default behavior.
|
112
|
+
*
|
113
|
+
* <p>
|
114
|
+
* For example, in <em>es-US</em>, the SHORT form for Fahrenheit is "{0} °F", but the NARROW form is "{0}°",
|
115
|
+
* since Fahrenheit is the customary unit for temperature in that locale.
|
116
|
+
*
|
117
|
+
* <p>
|
118
|
+
* In CLDR, this option corresponds to the "Short" format for measure units and the "¤" placeholder for
|
119
|
+
* currencies.
|
120
|
+
*
|
121
|
+
* @draft ICU 60
|
122
|
+
*/
|
123
|
+
UNUM_UNIT_WIDTH_SHORT,
|
124
|
+
|
125
|
+
/**
|
126
|
+
* Print the full name of the unit, without any abbreviations.
|
127
|
+
*
|
128
|
+
* <p>
|
129
|
+
* In CLDR, this option corresponds to the default format for measure units and the "¤¤¤" placeholder for
|
130
|
+
* currencies.
|
131
|
+
*
|
132
|
+
* @draft ICU 60
|
133
|
+
*/
|
134
|
+
UNUM_UNIT_WIDTH_FULL_NAME,
|
135
|
+
|
136
|
+
/**
|
137
|
+
* Use the three-digit ISO XXX code in place of the symbol for displaying currencies. The behavior of this
|
138
|
+
* option is currently undefined for use with measure units.
|
139
|
+
*
|
140
|
+
* <p>
|
141
|
+
* In CLDR, this option corresponds to the "¤¤" placeholder for currencies.
|
142
|
+
*
|
143
|
+
* @draft ICU 60
|
144
|
+
*/
|
145
|
+
UNUM_UNIT_WIDTH_ISO_CODE,
|
146
|
+
|
147
|
+
/**
|
148
|
+
* Format the number according to the specified unit, but do not display the unit. For currencies, apply
|
149
|
+
* monetary symbols and formats as with SHORT, but omit the currency symbol. For measure units, the behavior is
|
150
|
+
* equivalent to not specifying the unit at all.
|
151
|
+
*
|
152
|
+
* @draft ICU 60
|
153
|
+
*/
|
154
|
+
UNUM_UNIT_WIDTH_HIDDEN
|
155
|
+
|
156
|
+
#ifndef U_HIDE_INTERNAL_API
|
157
|
+
,
|
158
|
+
/**
|
159
|
+
* One more than the highest UNumberUnitWidth value.
|
160
|
+
*
|
161
|
+
* @internal ICU 60: The numeric value may change over time; see ICU ticket #12420.
|
162
|
+
*/
|
163
|
+
UNUM_UNIT_WIDTH_COUNT
|
164
|
+
#endif // U_HIDE_INTERNAL_API
|
165
|
+
} UNumberUnitWidth;
|
166
|
+
|
167
|
+
/**
|
168
|
+
* An enum declaring the strategy for when and how to display grouping separators (i.e., the
|
169
|
+
* separator, often a comma or period, after every 2-3 powers of ten). The choices are several
|
170
|
+
* pre-built strategies for different use cases that employ locale data whenever possible. Example
|
171
|
+
* outputs for 1234 and 1234567 in <em>en-IN</em>:
|
172
|
+
*
|
173
|
+
* <ul>
|
174
|
+
* <li>OFF: 1234 and 12345
|
175
|
+
* <li>MIN2: 1234 and 12,34,567
|
176
|
+
* <li>AUTO: 1,234 and 12,34,567
|
177
|
+
* <li>ON_ALIGNED: 1,234 and 12,34,567
|
178
|
+
* <li>THOUSANDS: 1,234 and 1,234,567
|
179
|
+
* </ul>
|
180
|
+
*
|
181
|
+
* <p>
|
182
|
+
* The default is AUTO, which displays grouping separators unless the locale data says that grouping
|
183
|
+
* is not customary. To force grouping for all numbers greater than 1000 consistently across locales,
|
184
|
+
* use ON_ALIGNED. On the other hand, to display grouping less frequently than the default, use MIN2
|
185
|
+
* or OFF. See the docs of each option for details.
|
186
|
+
*
|
187
|
+
* <p>
|
188
|
+
* Note: This enum specifies the strategy for grouping sizes. To set which character to use as the
|
189
|
+
* grouping separator, use the "symbols" setter.
|
190
|
+
*
|
191
|
+
* @draft ICU 61
|
192
|
+
*/
|
193
|
+
typedef enum UGroupingStrategy {
|
194
|
+
/**
|
195
|
+
* Do not display grouping separators in any locale.
|
196
|
+
*
|
197
|
+
* @draft ICU 61
|
198
|
+
*/
|
199
|
+
UNUM_GROUPING_OFF,
|
200
|
+
|
201
|
+
/**
|
202
|
+
* Display grouping using locale defaults, except do not show grouping on values smaller than
|
203
|
+
* 10000 (such that there is a <em>minimum of two digits</em> before the first separator).
|
204
|
+
*
|
205
|
+
* <p>
|
206
|
+
* Note that locales may restrict grouping separators to be displayed only on 1 million or
|
207
|
+
* greater (for example, ee and hu) or disable grouping altogether (for example, bg currency).
|
208
|
+
*
|
209
|
+
* <p>
|
210
|
+
* Locale data is used to determine whether to separate larger numbers into groups of 2
|
211
|
+
* (customary in South Asia) or groups of 3 (customary in Europe and the Americas).
|
212
|
+
*
|
213
|
+
* @draft ICU 61
|
214
|
+
*/
|
215
|
+
UNUM_GROUPING_MIN2,
|
216
|
+
|
217
|
+
/**
|
218
|
+
* Display grouping using the default strategy for all locales. This is the default behavior.
|
219
|
+
*
|
220
|
+
* <p>
|
221
|
+
* Note that locales may restrict grouping separators to be displayed only on 1 million or
|
222
|
+
* greater (for example, ee and hu) or disable grouping altogether (for example, bg currency).
|
223
|
+
*
|
224
|
+
* <p>
|
225
|
+
* Locale data is used to determine whether to separate larger numbers into groups of 2
|
226
|
+
* (customary in South Asia) or groups of 3 (customary in Europe and the Americas).
|
227
|
+
*
|
228
|
+
* @draft ICU 61
|
229
|
+
*/
|
230
|
+
UNUM_GROUPING_AUTO,
|
231
|
+
|
232
|
+
/**
|
233
|
+
* Always display the grouping separator on values of at least 1000.
|
234
|
+
*
|
235
|
+
* <p>
|
236
|
+
* This option ignores the locale data that restricts or disables grouping, described in MIN2 and
|
237
|
+
* AUTO. This option may be useful to normalize the alignment of numbers, such as in a
|
238
|
+
* spreadsheet.
|
239
|
+
*
|
240
|
+
* <p>
|
241
|
+
* Locale data is used to determine whether to separate larger numbers into groups of 2
|
242
|
+
* (customary in South Asia) or groups of 3 (customary in Europe and the Americas).
|
243
|
+
*
|
244
|
+
* @draft ICU 61
|
245
|
+
*/
|
246
|
+
UNUM_GROUPING_ON_ALIGNED,
|
247
|
+
|
248
|
+
/**
|
249
|
+
* Use the Western defaults: groups of 3 and enabled for all numbers 1000 or greater. Do not use
|
250
|
+
* locale data for determining the grouping strategy.
|
251
|
+
*
|
252
|
+
* @draft ICU 61
|
253
|
+
*/
|
254
|
+
UNUM_GROUPING_THOUSANDS
|
255
|
+
|
256
|
+
} UGroupingStrategy;
|
257
|
+
|
258
|
+
/**
|
259
|
+
* An enum declaring how to denote positive and negative numbers. Example outputs when formatting
|
260
|
+
* 123, 0, and -123 in <em>en-US</em>:
|
261
|
+
*
|
262
|
+
* <ul>
|
263
|
+
* <li>AUTO: "123", "0", and "-123"
|
264
|
+
* <li>ALWAYS: "+123", "+0", and "-123"
|
265
|
+
* <li>NEVER: "123", "0", and "123"
|
266
|
+
* <li>ACCOUNTING: "$123", "$0", and "($123)"
|
267
|
+
* <li>ACCOUNTING_ALWAYS: "+$123", "+$0", and "($123)"
|
268
|
+
* <li>EXCEPT_ZERO: "+123", "0", and "-123"
|
269
|
+
* <li>ACCOUNTING_EXCEPT_ZERO: "+$123", "$0", and "($123)"
|
270
|
+
* </ul>
|
271
|
+
*
|
272
|
+
* <p>
|
273
|
+
* The exact format, including the position and the code point of the sign, differ by locale.
|
274
|
+
*
|
275
|
+
* @draft ICU 60
|
276
|
+
*/
|
277
|
+
typedef enum UNumberSignDisplay {
|
278
|
+
/**
|
279
|
+
* Show the minus sign on negative numbers, and do not show the sign on positive numbers. This is the default
|
280
|
+
* behavior.
|
281
|
+
*
|
282
|
+
* @draft ICU 60
|
283
|
+
*/
|
284
|
+
UNUM_SIGN_AUTO,
|
285
|
+
|
286
|
+
/**
|
287
|
+
* Show the minus sign on negative numbers and the plus sign on positive numbers, including zero.
|
288
|
+
* To hide the sign on zero, see {@link UNUM_SIGN_EXCEPT_ZERO}.
|
289
|
+
*
|
290
|
+
* @draft ICU 60
|
291
|
+
*/
|
292
|
+
UNUM_SIGN_ALWAYS,
|
293
|
+
|
294
|
+
/**
|
295
|
+
* Do not show the sign on positive or negative numbers.
|
296
|
+
*
|
297
|
+
* @draft ICU 60
|
298
|
+
*/
|
299
|
+
UNUM_SIGN_NEVER,
|
300
|
+
|
301
|
+
/**
|
302
|
+
* Use the locale-dependent accounting format on negative numbers, and do not show the sign on positive numbers.
|
303
|
+
*
|
304
|
+
* <p>
|
305
|
+
* The accounting format is defined in CLDR and varies by locale; in many Western locales, the format is a pair
|
306
|
+
* of parentheses around the number.
|
307
|
+
*
|
308
|
+
* <p>
|
309
|
+
* Note: Since CLDR defines the accounting format in the monetary context only, this option falls back to the
|
310
|
+
* AUTO sign display strategy when formatting without a currency unit. This limitation may be lifted in the
|
311
|
+
* future.
|
312
|
+
*
|
313
|
+
* @draft ICU 60
|
314
|
+
*/
|
315
|
+
UNUM_SIGN_ACCOUNTING,
|
316
|
+
|
317
|
+
/**
|
318
|
+
* Use the locale-dependent accounting format on negative numbers, and show the plus sign on
|
319
|
+
* positive numbers, including zero. For more information on the accounting format, see the
|
320
|
+
* ACCOUNTING sign display strategy. To hide the sign on zero, see
|
321
|
+
* {@link UNUM_SIGN_ACCOUNTING_EXCEPT_ZERO}.
|
322
|
+
*
|
323
|
+
* @draft ICU 60
|
324
|
+
*/
|
325
|
+
UNUM_SIGN_ACCOUNTING_ALWAYS,
|
326
|
+
|
327
|
+
/**
|
328
|
+
* Show the minus sign on negative numbers and the plus sign on positive numbers. Do not show a
|
329
|
+
* sign on zero.
|
330
|
+
*
|
331
|
+
* @draft ICU 61
|
332
|
+
*/
|
333
|
+
UNUM_SIGN_EXCEPT_ZERO,
|
334
|
+
|
335
|
+
/**
|
336
|
+
* Use the locale-dependent accounting format on negative numbers, and show the plus sign on
|
337
|
+
* positive numbers. Do not show a sign on zero. For more information on the accounting format,
|
338
|
+
* see the ACCOUNTING sign display strategy.
|
339
|
+
*
|
340
|
+
* @draft ICU 61
|
341
|
+
*/
|
342
|
+
UNUM_SIGN_ACCOUNTING_EXCEPT_ZERO
|
343
|
+
|
344
|
+
#ifndef U_HIDE_INTERNAL_API
|
345
|
+
,
|
346
|
+
/**
|
347
|
+
* One more than the highest UNumberSignDisplay value.
|
348
|
+
*
|
349
|
+
* @internal ICU 60: The numeric value may change over time; see ICU ticket #12420.
|
350
|
+
*/
|
351
|
+
UNUM_SIGN_COUNT
|
352
|
+
#endif // U_HIDE_INTERNAL_API
|
353
|
+
} UNumberSignDisplay;
|
354
|
+
|
355
|
+
/**
|
356
|
+
* An enum declaring how to render the decimal separator.
|
357
|
+
*
|
358
|
+
* <p>
|
359
|
+
* <ul>
|
360
|
+
* <li>UNUM_DECIMAL_SEPARATOR_AUTO: "1", "1.1"
|
361
|
+
* <li>UNUM_DECIMAL_SEPARATOR_ALWAYS: "1.", "1.1"
|
362
|
+
* </ul>
|
363
|
+
*/
|
364
|
+
typedef enum UNumberDecimalSeparatorDisplay {
|
365
|
+
/**
|
366
|
+
* Show the decimal separator when there are one or more digits to display after the separator, and do not show
|
367
|
+
* it otherwise. This is the default behavior.
|
368
|
+
*
|
369
|
+
* @draft ICU 60
|
370
|
+
*/
|
371
|
+
UNUM_DECIMAL_SEPARATOR_AUTO,
|
372
|
+
|
373
|
+
/**
|
374
|
+
* Always show the decimal separator, even if there are no digits to display after the separator.
|
375
|
+
*
|
376
|
+
* @draft ICU 60
|
377
|
+
*/
|
378
|
+
UNUM_DECIMAL_SEPARATOR_ALWAYS
|
379
|
+
|
380
|
+
#ifndef U_HIDE_INTERNAL_API
|
381
|
+
,
|
382
|
+
/**
|
383
|
+
* One more than the highest UNumberDecimalSeparatorDisplay value.
|
384
|
+
*
|
385
|
+
* @internal ICU 60: The numeric value may change over time; see ICU ticket #12420.
|
386
|
+
*/
|
387
|
+
UNUM_DECIMAL_SEPARATOR_COUNT
|
388
|
+
#endif // U_HIDE_INTERNAL_API
|
389
|
+
} UNumberDecimalMarkDisplay;
|
390
|
+
|
391
|
+
U_NAMESPACE_BEGIN namespace number { // icu::number
|
392
|
+
|
393
|
+
// Forward declarations:
|
394
|
+
class UnlocalizedNumberFormatter;
|
395
|
+
class LocalizedNumberFormatter;
|
396
|
+
class FormattedNumber;
|
397
|
+
class Notation;
|
398
|
+
class ScientificNotation;
|
399
|
+
class Rounder;
|
400
|
+
class FractionRounder;
|
401
|
+
class CurrencyRounder;
|
402
|
+
class IncrementRounder;
|
403
|
+
class IntegerWidth;
|
404
|
+
|
405
|
+
namespace impl {
|
406
|
+
|
407
|
+
#ifndef U_HIDE_INTERNAL_API
|
408
|
+
/**
|
409
|
+
* Datatype for minimum/maximum fraction digits. Must be able to hold kMaxIntFracSig.
|
410
|
+
*
|
411
|
+
* @internal
|
412
|
+
*/
|
413
|
+
typedef int16_t digits_t;
|
414
|
+
|
415
|
+
/**
|
416
|
+
* Use a default threshold of 3. This means that the third time .format() is called, the data structures get built
|
417
|
+
* using the "safe" code path. The first two calls to .format() will trigger the unsafe code path.
|
418
|
+
*
|
419
|
+
* @internal
|
420
|
+
*/
|
421
|
+
static constexpr int32_t DEFAULT_THRESHOLD = 3;
|
422
|
+
#endif // U_HIDE_INTERNAL_API
|
423
|
+
|
424
|
+
// Forward declarations:
|
425
|
+
class Padder;
|
426
|
+
struct MacroProps;
|
427
|
+
struct MicroProps;
|
428
|
+
class DecimalQuantity;
|
429
|
+
struct NumberFormatterResults;
|
430
|
+
class NumberFormatterImpl;
|
431
|
+
struct ParsedPatternInfo;
|
432
|
+
class ScientificModifier;
|
433
|
+
class MultiplierProducer;
|
434
|
+
class MutablePatternModifier;
|
435
|
+
class LongNameHandler;
|
436
|
+
class ScientificHandler;
|
437
|
+
class CompactHandler;
|
438
|
+
class Modifier;
|
439
|
+
class NumberStringBuilder;
|
440
|
+
|
441
|
+
} // namespace impl
|
442
|
+
|
443
|
+
// Reserve extra names in case they are added as classes in the future:
|
444
|
+
typedef Notation CompactNotation;
|
445
|
+
typedef Notation SimpleNotation;
|
446
|
+
|
447
|
+
/**
|
448
|
+
* A class that defines the notation style to be used when formatting numbers in NumberFormatter.
|
449
|
+
*
|
450
|
+
* @draft ICU 60
|
451
|
+
*/
|
452
|
+
class U_I18N_API Notation : public UMemory {
|
453
|
+
public:
|
454
|
+
/**
|
455
|
+
* Print the number using scientific notation (also known as scientific form, standard index form, or standard form
|
456
|
+
* in the UK). The format for scientific notation varies by locale; for example, many Western locales display the
|
457
|
+
* number in the form "#E0", where the number is displayed with one digit before the decimal separator, zero or more
|
458
|
+
* digits after the decimal separator, and the corresponding power of 10 displayed after the "E".
|
459
|
+
*
|
460
|
+
* <p>
|
461
|
+
* Example outputs in <em>en-US</em> when printing 8.765E4 through 8.765E-3:
|
462
|
+
*
|
463
|
+
* <pre>
|
464
|
+
* 8.765E4
|
465
|
+
* 8.765E3
|
466
|
+
* 8.765E2
|
467
|
+
* 8.765E1
|
468
|
+
* 8.765E0
|
469
|
+
* 8.765E-1
|
470
|
+
* 8.765E-2
|
471
|
+
* 8.765E-3
|
472
|
+
* 0E0
|
473
|
+
* </pre>
|
474
|
+
*
|
475
|
+
* @return A ScientificNotation for chaining or passing to the NumberFormatter notation() setter.
|
476
|
+
* @draft ICU 60
|
477
|
+
*/
|
478
|
+
static ScientificNotation scientific();
|
479
|
+
|
480
|
+
/**
|
481
|
+
* Print the number using engineering notation, a variant of scientific notation in which the exponent must be
|
482
|
+
* divisible by 3.
|
483
|
+
*
|
484
|
+
* <p>
|
485
|
+
* Example outputs in <em>en-US</em> when printing 8.765E4 through 8.765E-3:
|
486
|
+
*
|
487
|
+
* <pre>
|
488
|
+
* 87.65E3
|
489
|
+
* 8.765E3
|
490
|
+
* 876.5E0
|
491
|
+
* 87.65E0
|
492
|
+
* 8.765E0
|
493
|
+
* 876.5E-3
|
494
|
+
* 87.65E-3
|
495
|
+
* 8.765E-3
|
496
|
+
* 0E0
|
497
|
+
* </pre>
|
498
|
+
*
|
499
|
+
* @return A ScientificNotation for chaining or passing to the NumberFormatter notation() setter.
|
500
|
+
* @draft ICU 60
|
501
|
+
*/
|
502
|
+
static ScientificNotation engineering();
|
503
|
+
|
504
|
+
/**
|
505
|
+
* Print the number using short-form compact notation.
|
506
|
+
*
|
507
|
+
* <p>
|
508
|
+
* <em>Compact notation</em>, defined in Unicode Technical Standard #35 Part 3 Section 2.4.1, prints numbers with
|
509
|
+
* localized prefixes or suffixes corresponding to different powers of ten. Compact notation is similar to
|
510
|
+
* engineering notation in how it scales numbers.
|
511
|
+
*
|
512
|
+
* <p>
|
513
|
+
* Compact notation is ideal for displaying large numbers (over ~1000) to humans while at the same time minimizing
|
514
|
+
* screen real estate.
|
515
|
+
*
|
516
|
+
* <p>
|
517
|
+
* In short form, the powers of ten are abbreviated. In <em>en-US</em>, the abbreviations are "K" for thousands, "M"
|
518
|
+
* for millions, "B" for billions, and "T" for trillions. Example outputs in <em>en-US</em> when printing 8.765E7
|
519
|
+
* through 8.765E0:
|
520
|
+
*
|
521
|
+
* <pre>
|
522
|
+
* 88M
|
523
|
+
* 8.8M
|
524
|
+
* 876K
|
525
|
+
* 88K
|
526
|
+
* 8.8K
|
527
|
+
* 876
|
528
|
+
* 88
|
529
|
+
* 8.8
|
530
|
+
* </pre>
|
531
|
+
*
|
532
|
+
* <p>
|
533
|
+
* When compact notation is specified without an explicit rounding strategy, numbers are rounded off to the closest
|
534
|
+
* integer after scaling the number by the corresponding power of 10, but with a digit shown after the decimal
|
535
|
+
* separator if there is only one digit before the decimal separator. The default compact notation rounding strategy
|
536
|
+
* is equivalent to:
|
537
|
+
*
|
538
|
+
* <pre>
|
539
|
+
* Rounder.integer().withMinDigits(2)
|
540
|
+
* </pre>
|
541
|
+
*
|
542
|
+
* @return A CompactNotation for passing to the NumberFormatter notation() setter.
|
543
|
+
* @draft ICU 60
|
544
|
+
*/
|
545
|
+
static CompactNotation compactShort();
|
546
|
+
|
547
|
+
/**
|
548
|
+
* Print the number using long-form compact notation. For more information on compact notation, see
|
549
|
+
* {@link #compactShort}.
|
550
|
+
*
|
551
|
+
* <p>
|
552
|
+
* In long form, the powers of ten are spelled out fully. Example outputs in <em>en-US</em> when printing 8.765E7
|
553
|
+
* through 8.765E0:
|
554
|
+
*
|
555
|
+
* <pre>
|
556
|
+
* 88 million
|
557
|
+
* 8.8 million
|
558
|
+
* 876 thousand
|
559
|
+
* 88 thousand
|
560
|
+
* 8.8 thousand
|
561
|
+
* 876
|
562
|
+
* 88
|
563
|
+
* 8.8
|
564
|
+
* </pre>
|
565
|
+
*
|
566
|
+
* @return A CompactNotation for passing to the NumberFormatter notation() setter.
|
567
|
+
* @draft ICU 60
|
568
|
+
*/
|
569
|
+
static CompactNotation compactLong();
|
570
|
+
|
571
|
+
/**
|
572
|
+
* Print the number using simple notation without any scaling by powers of ten. This is the default behavior.
|
573
|
+
*
|
574
|
+
* <p>
|
575
|
+
* Since this is the default behavior, this method needs to be called only when it is necessary to override a
|
576
|
+
* previous setting.
|
577
|
+
*
|
578
|
+
* <p>
|
579
|
+
* Example outputs in <em>en-US</em> when printing 8.765E7 through 8.765E0:
|
580
|
+
*
|
581
|
+
* <pre>
|
582
|
+
* 87,650,000
|
583
|
+
* 8,765,000
|
584
|
+
* 876,500
|
585
|
+
* 87,650
|
586
|
+
* 8,765
|
587
|
+
* 876.5
|
588
|
+
* 87.65
|
589
|
+
* 8.765
|
590
|
+
* </pre>
|
591
|
+
*
|
592
|
+
* @return A SimpleNotation for passing to the NumberFormatter notation() setter.
|
593
|
+
* @draft ICU 60
|
594
|
+
*/
|
595
|
+
static SimpleNotation simple();
|
596
|
+
|
597
|
+
private:
|
598
|
+
enum NotationType {
|
599
|
+
NTN_SCIENTIFIC, NTN_COMPACT, NTN_SIMPLE, NTN_ERROR
|
600
|
+
} fType;
|
601
|
+
|
602
|
+
union NotationUnion {
|
603
|
+
// For NTN_SCIENTIFIC
|
604
|
+
struct ScientificSettings {
|
605
|
+
int8_t fEngineeringInterval;
|
606
|
+
bool fRequireMinInt;
|
607
|
+
impl::digits_t fMinExponentDigits;
|
608
|
+
UNumberSignDisplay fExponentSignDisplay;
|
609
|
+
} scientific;
|
610
|
+
|
611
|
+
// For NTN_COMPACT
|
612
|
+
UNumberCompactStyle compactStyle;
|
613
|
+
|
614
|
+
// For NTN_ERROR
|
615
|
+
UErrorCode errorCode;
|
616
|
+
} fUnion;
|
617
|
+
|
618
|
+
typedef NotationUnion::ScientificSettings ScientificSettings;
|
619
|
+
|
620
|
+
Notation(const NotationType &type, const NotationUnion &union_) : fType(type), fUnion(union_) {}
|
621
|
+
|
622
|
+
Notation(UErrorCode errorCode) : fType(NTN_ERROR) {
|
623
|
+
fUnion.errorCode = errorCode;
|
624
|
+
}
|
625
|
+
|
626
|
+
Notation() : fType(NTN_SIMPLE), fUnion() {}
|
627
|
+
|
628
|
+
UBool copyErrorTo(UErrorCode &status) const {
|
629
|
+
if (fType == NTN_ERROR) {
|
630
|
+
status = fUnion.errorCode;
|
631
|
+
return TRUE;
|
632
|
+
}
|
633
|
+
return FALSE;
|
634
|
+
}
|
635
|
+
|
636
|
+
// To allow MacroProps to initialize empty instances:
|
637
|
+
friend struct impl::MacroProps;
|
638
|
+
friend class ScientificNotation;
|
639
|
+
|
640
|
+
// To allow implementation to access internal types:
|
641
|
+
friend class impl::NumberFormatterImpl;
|
642
|
+
friend class impl::ScientificModifier;
|
643
|
+
friend class impl::ScientificHandler;
|
644
|
+
};
|
645
|
+
|
646
|
+
/**
|
647
|
+
* A class that defines the scientific notation style to be used when formatting numbers in NumberFormatter.
|
648
|
+
*
|
649
|
+
* <p>
|
650
|
+
* To create a ScientificNotation, use one of the factory methods in {@link Notation}.
|
651
|
+
*
|
652
|
+
* @draft ICU 60
|
653
|
+
*/
|
654
|
+
class U_I18N_API ScientificNotation : public Notation {
|
655
|
+
public:
|
656
|
+
/**
|
657
|
+
* Sets the minimum number of digits to show in the exponent of scientific notation, padding with zeros if
|
658
|
+
* necessary. Useful for fixed-width display.
|
659
|
+
*
|
660
|
+
* <p>
|
661
|
+
* For example, with minExponentDigits=2, the number 123 will be printed as "1.23E02" in <em>en-US</em> instead of
|
662
|
+
* the default "1.23E2".
|
663
|
+
*
|
664
|
+
* @param minExponentDigits
|
665
|
+
* The minimum number of digits to show in the exponent.
|
666
|
+
* @return A ScientificNotation, for chaining.
|
667
|
+
* @draft ICU 60
|
668
|
+
*/
|
669
|
+
ScientificNotation withMinExponentDigits(int32_t minExponentDigits) const;
|
670
|
+
|
671
|
+
/**
|
672
|
+
* Sets whether to show the sign on positive and negative exponents in scientific notation. The default is AUTO,
|
673
|
+
* showing the minus sign but not the plus sign.
|
674
|
+
*
|
675
|
+
* <p>
|
676
|
+
* For example, with exponentSignDisplay=ALWAYS, the number 123 will be printed as "1.23E+2" in <em>en-US</em>
|
677
|
+
* instead of the default "1.23E2".
|
678
|
+
*
|
679
|
+
* @param exponentSignDisplay
|
680
|
+
* The strategy for displaying the sign in the exponent.
|
681
|
+
* @return A ScientificNotation, for chaining.
|
682
|
+
* @draft ICU 60
|
683
|
+
*/
|
684
|
+
ScientificNotation withExponentSignDisplay(UNumberSignDisplay exponentSignDisplay) const;
|
685
|
+
|
686
|
+
private:
|
687
|
+
// Inherit constructor
|
688
|
+
using Notation::Notation;
|
689
|
+
|
690
|
+
friend class Notation;
|
691
|
+
};
|
692
|
+
|
693
|
+
// Reserve extra names in case they are added as classes in the future:
|
694
|
+
typedef Rounder DigitRounder;
|
695
|
+
|
696
|
+
/**
|
697
|
+
* A class that defines the rounding strategy to be used when formatting numbers in NumberFormatter.
|
698
|
+
*
|
699
|
+
* <p>
|
700
|
+
* To create a Rounder, use one of the factory methods.
|
701
|
+
*
|
702
|
+
* @draft ICU 60
|
703
|
+
*/
|
704
|
+
class U_I18N_API Rounder : public UMemory {
|
705
|
+
|
706
|
+
public:
|
707
|
+
/**
|
708
|
+
* Show all available digits to full precision.
|
709
|
+
*
|
710
|
+
* <p>
|
711
|
+
* <strong>NOTE:</strong> When formatting a <em>double</em>, this method, along with {@link #minFraction} and
|
712
|
+
* {@link #minDigits}, will trigger complex algorithm similar to <em>Dragon4</em> to determine the low-order digits
|
713
|
+
* and the number of digits to display based on the value of the double. If the number of fraction places or
|
714
|
+
* significant digits can be bounded, consider using {@link #maxFraction} or {@link #maxDigits} instead to maximize
|
715
|
+
* performance. For more information, read the following blog post.
|
716
|
+
*
|
717
|
+
* <p>
|
718
|
+
* http://www.serpentine.com/blog/2011/06/29/here-be-dragons-advances-in-problems-you-didnt-even-know-you-had/
|
719
|
+
*
|
720
|
+
* @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
|
721
|
+
* @draft ICU 60
|
722
|
+
*/
|
723
|
+
static Rounder unlimited();
|
724
|
+
|
725
|
+
/**
|
726
|
+
* Show numbers rounded if necessary to the nearest integer.
|
727
|
+
*
|
728
|
+
* @return A FractionRounder for chaining or passing to the NumberFormatter rounding() setter.
|
729
|
+
* @draft ICU 60
|
730
|
+
*/
|
731
|
+
static FractionRounder integer();
|
732
|
+
|
733
|
+
/**
|
734
|
+
* Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator).
|
735
|
+
* Additionally, pad with zeros to ensure that this number of places are always shown.
|
736
|
+
*
|
737
|
+
* <p>
|
738
|
+
* Example output with minMaxFractionPlaces = 3:
|
739
|
+
*
|
740
|
+
* <p>
|
741
|
+
* 87,650.000<br>
|
742
|
+
* 8,765.000<br>
|
743
|
+
* 876.500<br>
|
744
|
+
* 87.650<br>
|
745
|
+
* 8.765<br>
|
746
|
+
* 0.876<br>
|
747
|
+
* 0.088<br>
|
748
|
+
* 0.009<br>
|
749
|
+
* 0.000 (zero)
|
750
|
+
*
|
751
|
+
* <p>
|
752
|
+
* This method is equivalent to {@link #minMaxFraction} with both arguments equal.
|
753
|
+
*
|
754
|
+
* @param minMaxFractionPlaces
|
755
|
+
* The minimum and maximum number of numerals to display after the decimal separator (rounding if too
|
756
|
+
* long or padding with zeros if too short).
|
757
|
+
* @return A FractionRounder for chaining or passing to the NumberFormatter rounding() setter.
|
758
|
+
* @draft ICU 60
|
759
|
+
*/
|
760
|
+
static FractionRounder fixedFraction(int32_t minMaxFractionPlaces);
|
761
|
+
|
762
|
+
/**
|
763
|
+
* Always show at least a certain number of fraction places after the decimal separator, padding with zeros if
|
764
|
+
* necessary. Do not perform rounding (display numbers to their full precision).
|
765
|
+
*
|
766
|
+
* <p>
|
767
|
+
* <strong>NOTE:</strong> If you are formatting <em>doubles</em>, see the performance note in {@link #unlimited}.
|
768
|
+
*
|
769
|
+
* @param minFractionPlaces
|
770
|
+
* The minimum number of numerals to display after the decimal separator (padding with zeros if
|
771
|
+
* necessary).
|
772
|
+
* @return A FractionRounder for chaining or passing to the NumberFormatter rounding() setter.
|
773
|
+
* @draft ICU 60
|
774
|
+
*/
|
775
|
+
static FractionRounder minFraction(int32_t minFractionPlaces);
|
776
|
+
|
777
|
+
/**
|
778
|
+
* Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator).
|
779
|
+
* Unlike the other fraction rounding strategies, this strategy does <em>not</em> pad zeros to the end of the
|
780
|
+
* number.
|
781
|
+
*
|
782
|
+
* @param maxFractionPlaces
|
783
|
+
* The maximum number of numerals to display after the decimal mark (rounding if necessary).
|
784
|
+
* @return A FractionRounder for chaining or passing to the NumberFormatter rounding() setter.
|
785
|
+
* @draft ICU 60
|
786
|
+
*/
|
787
|
+
static FractionRounder maxFraction(int32_t maxFractionPlaces);
|
788
|
+
|
789
|
+
/**
|
790
|
+
* Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator);
|
791
|
+
* in addition, always show at least a certain number of places after the decimal separator, padding with zeros if
|
792
|
+
* necessary.
|
793
|
+
*
|
794
|
+
* @param minFractionPlaces
|
795
|
+
* The minimum number of numerals to display after the decimal separator (padding with zeros if
|
796
|
+
* necessary).
|
797
|
+
* @param maxFractionPlaces
|
798
|
+
* The maximum number of numerals to display after the decimal separator (rounding if necessary).
|
799
|
+
* @return A FractionRounder for chaining or passing to the NumberFormatter rounding() setter.
|
800
|
+
* @draft ICU 60
|
801
|
+
*/
|
802
|
+
static FractionRounder minMaxFraction(int32_t minFractionPlaces, int32_t maxFractionPlaces);
|
803
|
+
|
804
|
+
/**
|
805
|
+
* Show numbers rounded if necessary to a certain number of significant digits or significant figures. Additionally,
|
806
|
+
* pad with zeros to ensure that this number of significant digits/figures are always shown.
|
807
|
+
*
|
808
|
+
* <p>
|
809
|
+
* This method is equivalent to {@link #minMaxDigits} with both arguments equal.
|
810
|
+
*
|
811
|
+
* @param minMaxSignificantDigits
|
812
|
+
* The minimum and maximum number of significant digits to display (rounding if too long or padding with
|
813
|
+
* zeros if too short).
|
814
|
+
* @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
|
815
|
+
* @draft ICU 60
|
816
|
+
*/
|
817
|
+
static DigitRounder fixedDigits(int32_t minMaxSignificantDigits);
|
818
|
+
|
819
|
+
/**
|
820
|
+
* Always show at least a certain number of significant digits/figures, padding with zeros if necessary. Do not
|
821
|
+
* perform rounding (display numbers to their full precision).
|
822
|
+
*
|
823
|
+
* <p>
|
824
|
+
* <strong>NOTE:</strong> If you are formatting <em>doubles</em>, see the performance note in {@link #unlimited}.
|
825
|
+
*
|
826
|
+
* @param minSignificantDigits
|
827
|
+
* The minimum number of significant digits to display (padding with zeros if too short).
|
828
|
+
* @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
|
829
|
+
* @draft ICU 60
|
830
|
+
*/
|
831
|
+
static DigitRounder minDigits(int32_t minSignificantDigits);
|
832
|
+
|
833
|
+
/**
|
834
|
+
* Show numbers rounded if necessary to a certain number of significant digits/figures.
|
835
|
+
*
|
836
|
+
* @param maxSignificantDigits
|
837
|
+
* The maximum number of significant digits to display (rounding if too long).
|
838
|
+
* @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
|
839
|
+
* @draft ICU 60
|
840
|
+
*/
|
841
|
+
static DigitRounder maxDigits(int32_t maxSignificantDigits);
|
842
|
+
|
843
|
+
/**
|
844
|
+
* Show numbers rounded if necessary to a certain number of significant digits/figures; in addition, always show at
|
845
|
+
* least a certain number of significant digits, padding with zeros if necessary.
|
846
|
+
*
|
847
|
+
* @param minSignificantDigits
|
848
|
+
* The minimum number of significant digits to display (padding with zeros if necessary).
|
849
|
+
* @param maxSignificantDigits
|
850
|
+
* The maximum number of significant digits to display (rounding if necessary).
|
851
|
+
* @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
|
852
|
+
* @draft ICU 60
|
853
|
+
*/
|
854
|
+
static DigitRounder minMaxDigits(int32_t minSignificantDigits, int32_t maxSignificantDigits);
|
855
|
+
|
856
|
+
/**
|
857
|
+
* Show numbers rounded if necessary to the closest multiple of a certain rounding increment. For example, if the
|
858
|
+
* rounding increment is 0.5, then round 1.2 to 1 and round 1.3 to 1.5.
|
859
|
+
*
|
860
|
+
* <p>
|
861
|
+
* In order to ensure that numbers are padded to the appropriate number of fraction places, call
|
862
|
+
* withMinFraction() on the return value of this method.
|
863
|
+
* For example, to round to the nearest 0.5 and always display 2 numerals after the
|
864
|
+
* decimal separator (to display 1.2 as "1.00" and 1.3 as "1.50"), you can run:
|
865
|
+
*
|
866
|
+
* <pre>
|
867
|
+
* Rounder::increment(0.5).withMinFraction(2)
|
868
|
+
* </pre>
|
869
|
+
*
|
870
|
+
* @param roundingIncrement
|
871
|
+
* The increment to which to round numbers.
|
872
|
+
* @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
|
873
|
+
* @draft ICU 60
|
874
|
+
*/
|
875
|
+
static IncrementRounder increment(double roundingIncrement);
|
876
|
+
|
877
|
+
/**
|
878
|
+
* Show numbers rounded and padded according to the rules for the currency unit. The most common rounding settings
|
879
|
+
* for currencies include <code>Rounder.fixedFraction(2)</code>, <code>Rounder.integer()</code>, and
|
880
|
+
* <code>Rounder.increment(0.05)</code> for cash transactions ("nickel rounding").
|
881
|
+
*
|
882
|
+
* <p>
|
883
|
+
* The exact rounding details will be resolved at runtime based on the currency unit specified in the
|
884
|
+
* NumberFormatter chain. To round according to the rules for one currency while displaying the symbol for another
|
885
|
+
* currency, the withCurrency() method can be called on the return value of this method.
|
886
|
+
*
|
887
|
+
* @param currencyUsage
|
888
|
+
* Either STANDARD (for digital transactions) or CASH (for transactions where the rounding increment may
|
889
|
+
* be limited by the available denominations of cash or coins).
|
890
|
+
* @return A CurrencyRounder for chaining or passing to the NumberFormatter rounding() setter.
|
891
|
+
* @draft ICU 60
|
892
|
+
*/
|
893
|
+
static CurrencyRounder currency(UCurrencyUsage currencyUsage);
|
894
|
+
|
895
|
+
/**
|
896
|
+
* Sets the rounding mode to use when picking the direction to round (up or down). Common values
|
897
|
+
* include HALF_EVEN, HALF_UP, and FLOOR. The default is HALF_EVEN.
|
898
|
+
*
|
899
|
+
* @param roundingMode
|
900
|
+
* The RoundingMode to use.
|
901
|
+
* @return A Rounder for passing to the NumberFormatter rounding() setter.
|
902
|
+
* @draft ICU 60
|
903
|
+
*/
|
904
|
+
Rounder withMode(UNumberFormatRoundingMode roundingMode) const;
|
905
|
+
|
906
|
+
private:
|
907
|
+
enum RounderType {
|
908
|
+
RND_BOGUS,
|
909
|
+
RND_NONE,
|
910
|
+
RND_FRACTION,
|
911
|
+
RND_SIGNIFICANT,
|
912
|
+
RND_FRACTION_SIGNIFICANT,
|
913
|
+
RND_INCREMENT,
|
914
|
+
RND_CURRENCY,
|
915
|
+
RND_PASS_THROUGH,
|
916
|
+
RND_ERROR
|
917
|
+
} fType;
|
918
|
+
|
919
|
+
union RounderUnion {
|
920
|
+
struct FractionSignificantSettings {
|
921
|
+
// For RND_FRACTION, RND_SIGNIFICANT, and RND_FRACTION_SIGNIFICANT
|
922
|
+
impl::digits_t fMinFrac;
|
923
|
+
impl::digits_t fMaxFrac;
|
924
|
+
impl::digits_t fMinSig;
|
925
|
+
impl::digits_t fMaxSig;
|
926
|
+
} fracSig;
|
927
|
+
struct IncrementSettings {
|
928
|
+
double fIncrement;
|
929
|
+
impl::digits_t fMinFrac;
|
930
|
+
} increment; // For RND_INCREMENT
|
931
|
+
UCurrencyUsage currencyUsage; // For RND_CURRENCY
|
932
|
+
UErrorCode errorCode; // For RND_ERROR
|
933
|
+
} fUnion;
|
934
|
+
|
935
|
+
typedef RounderUnion::FractionSignificantSettings FractionSignificantSettings;
|
936
|
+
typedef RounderUnion::IncrementSettings IncrementSettings;
|
937
|
+
|
938
|
+
UNumberFormatRoundingMode fRoundingMode;
|
939
|
+
|
940
|
+
Rounder(const RounderType &type, const RounderUnion &union_, UNumberFormatRoundingMode roundingMode)
|
941
|
+
: fType(type), fUnion(union_), fRoundingMode(roundingMode) {}
|
942
|
+
|
943
|
+
Rounder(UErrorCode errorCode) : fType(RND_ERROR) {
|
944
|
+
fUnion.errorCode = errorCode;
|
945
|
+
}
|
946
|
+
|
947
|
+
Rounder() : fType(RND_BOGUS) {}
|
948
|
+
|
949
|
+
bool isBogus() const {
|
950
|
+
return fType == RND_BOGUS;
|
951
|
+
}
|
952
|
+
|
953
|
+
UBool copyErrorTo(UErrorCode &status) const {
|
954
|
+
if (fType == RND_ERROR) {
|
955
|
+
status = fUnion.errorCode;
|
956
|
+
return TRUE;
|
957
|
+
}
|
958
|
+
return FALSE;
|
959
|
+
}
|
960
|
+
|
961
|
+
// On the parent type so that this method can be called internally on Rounder instances.
|
962
|
+
Rounder withCurrency(const CurrencyUnit ¤cy, UErrorCode &status) const;
|
963
|
+
|
964
|
+
/** NON-CONST: mutates the current instance. */
|
965
|
+
void setLocaleData(const CurrencyUnit ¤cy, UErrorCode &status);
|
966
|
+
|
967
|
+
void apply(impl::DecimalQuantity &value, UErrorCode &status) const;
|
968
|
+
|
969
|
+
/** Version of {@link #apply} that obeys minInt constraints. Used for scientific notation compatibility mode. */
|
970
|
+
void apply(impl::DecimalQuantity &value, int32_t minInt, UErrorCode status);
|
971
|
+
|
972
|
+
/**
|
973
|
+
* Rounding endpoint used by Engineering and Compact notation. Chooses the most appropriate multiplier (magnitude
|
974
|
+
* adjustment), applies the adjustment, rounds, and returns the chosen multiplier.
|
975
|
+
*
|
976
|
+
* <p>
|
977
|
+
* In most cases, this is simple. However, when rounding the number causes it to cross a multiplier boundary, we
|
978
|
+
* need to re-do the rounding. For example, to display 999,999 in Engineering notation with 2 sigfigs, first you
|
979
|
+
* guess the multiplier to be -3. However, then you end up getting 1000E3, which is not the correct output. You then
|
980
|
+
* change your multiplier to be -6, and you get 1.0E6, which is correct.
|
981
|
+
*
|
982
|
+
* @param input The quantity to process.
|
983
|
+
* @param producer Function to call to return a multiplier based on a magnitude.
|
984
|
+
* @return The number of orders of magnitude the input was adjusted by this method.
|
985
|
+
*/
|
986
|
+
int32_t
|
987
|
+
chooseMultiplierAndApply(impl::DecimalQuantity &input, const impl::MultiplierProducer &producer,
|
988
|
+
UErrorCode &status);
|
989
|
+
|
990
|
+
static FractionRounder constructFraction(int32_t minFrac, int32_t maxFrac);
|
991
|
+
|
992
|
+
static Rounder constructSignificant(int32_t minSig, int32_t maxSig);
|
993
|
+
|
994
|
+
static Rounder
|
995
|
+
constructFractionSignificant(const FractionRounder &base, int32_t minSig, int32_t maxSig);
|
996
|
+
|
997
|
+
static IncrementRounder constructIncrement(double increment, int32_t minFrac);
|
998
|
+
|
999
|
+
static CurrencyRounder constructCurrency(UCurrencyUsage usage);
|
1000
|
+
|
1001
|
+
static Rounder constructPassThrough();
|
1002
|
+
|
1003
|
+
// To allow MacroProps/MicroProps to initialize bogus instances:
|
1004
|
+
friend struct impl::MacroProps;
|
1005
|
+
friend struct impl::MicroProps;
|
1006
|
+
|
1007
|
+
// To allow NumberFormatterImpl to access isBogus() and other internal methods:
|
1008
|
+
friend class impl::NumberFormatterImpl;
|
1009
|
+
|
1010
|
+
// To give access to apply() and chooseMultiplierAndApply():
|
1011
|
+
friend class impl::MutablePatternModifier;
|
1012
|
+
friend class impl::LongNameHandler;
|
1013
|
+
friend class impl::ScientificHandler;
|
1014
|
+
friend class impl::CompactHandler;
|
1015
|
+
|
1016
|
+
// To allow child classes to call private methods:
|
1017
|
+
friend class FractionRounder;
|
1018
|
+
friend class CurrencyRounder;
|
1019
|
+
friend class IncrementRounder;
|
1020
|
+
};
|
1021
|
+
|
1022
|
+
/**
|
1023
|
+
* A class that defines a rounding strategy based on a number of fraction places and optionally significant digits to be
|
1024
|
+
* used when formatting numbers in NumberFormatter.
|
1025
|
+
*
|
1026
|
+
* <p>
|
1027
|
+
* To create a FractionRounder, use one of the factory methods on Rounder.
|
1028
|
+
*
|
1029
|
+
* @draft ICU 60
|
1030
|
+
*/
|
1031
|
+
class U_I18N_API FractionRounder : public Rounder {
|
1032
|
+
public:
|
1033
|
+
/**
|
1034
|
+
* Ensure that no less than this number of significant digits are retained when rounding according to fraction
|
1035
|
+
* rules.
|
1036
|
+
*
|
1037
|
+
* <p>
|
1038
|
+
* For example, with integer rounding, the number 3.141 becomes "3". However, with minimum figures set to 2, 3.141
|
1039
|
+
* becomes "3.1" instead.
|
1040
|
+
*
|
1041
|
+
* <p>
|
1042
|
+
* This setting does not affect the number of trailing zeros. For example, 3.01 would print as "3", not "3.0".
|
1043
|
+
*
|
1044
|
+
* @param minSignificantDigits
|
1045
|
+
* The number of significant figures to guarantee.
|
1046
|
+
* @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
|
1047
|
+
* @draft ICU 60
|
1048
|
+
*/
|
1049
|
+
Rounder withMinDigits(int32_t minSignificantDigits) const;
|
1050
|
+
|
1051
|
+
/**
|
1052
|
+
* Ensure that no more than this number of significant digits are retained when rounding according to fraction
|
1053
|
+
* rules.
|
1054
|
+
*
|
1055
|
+
* <p>
|
1056
|
+
* For example, with integer rounding, the number 123.4 becomes "123". However, with maximum figures set to 2, 123.4
|
1057
|
+
* becomes "120" instead.
|
1058
|
+
*
|
1059
|
+
* <p>
|
1060
|
+
* This setting does not affect the number of trailing zeros. For example, with fixed fraction of 2, 123.4 would
|
1061
|
+
* become "120.00".
|
1062
|
+
*
|
1063
|
+
* @param maxSignificantDigits
|
1064
|
+
* Round the number to no more than this number of significant figures.
|
1065
|
+
* @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
|
1066
|
+
* @draft ICU 60
|
1067
|
+
*/
|
1068
|
+
Rounder withMaxDigits(int32_t maxSignificantDigits) const;
|
1069
|
+
|
1070
|
+
private:
|
1071
|
+
// Inherit constructor
|
1072
|
+
using Rounder::Rounder;
|
1073
|
+
|
1074
|
+
// To allow parent class to call this class's constructor:
|
1075
|
+
friend class Rounder;
|
1076
|
+
};
|
1077
|
+
|
1078
|
+
/**
|
1079
|
+
* A class that defines a rounding strategy parameterized by a currency to be used when formatting numbers in
|
1080
|
+
* NumberFormatter.
|
1081
|
+
*
|
1082
|
+
* <p>
|
1083
|
+
* To create a CurrencyRounder, use one of the factory methods on Rounder.
|
1084
|
+
*
|
1085
|
+
* @draft ICU 60
|
1086
|
+
*/
|
1087
|
+
class U_I18N_API CurrencyRounder : public Rounder {
|
1088
|
+
public:
|
1089
|
+
/**
|
1090
|
+
* Associates a currency with this rounding strategy.
|
1091
|
+
*
|
1092
|
+
* <p>
|
1093
|
+
* <strong>Calling this method is <em>not required</em></strong>, because the currency specified in unit()
|
1094
|
+
* is automatically applied to currency rounding strategies. However,
|
1095
|
+
* this method enables you to override that automatic association.
|
1096
|
+
*
|
1097
|
+
* <p>
|
1098
|
+
* This method also enables numbers to be formatted using currency rounding rules without explicitly using a
|
1099
|
+
* currency format.
|
1100
|
+
*
|
1101
|
+
* @param currency
|
1102
|
+
* The currency to associate with this rounding strategy.
|
1103
|
+
* @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
|
1104
|
+
* @draft ICU 60
|
1105
|
+
*/
|
1106
|
+
Rounder withCurrency(const CurrencyUnit ¤cy) const;
|
1107
|
+
|
1108
|
+
private:
|
1109
|
+
// Inherit constructor
|
1110
|
+
using Rounder::Rounder;
|
1111
|
+
|
1112
|
+
// To allow parent class to call this class's constructor:
|
1113
|
+
friend class Rounder;
|
1114
|
+
};
|
1115
|
+
|
1116
|
+
/**
|
1117
|
+
* A class that defines a rounding strategy parameterized by a rounding increment to be used when formatting numbers in
|
1118
|
+
* NumberFormatter.
|
1119
|
+
*
|
1120
|
+
* <p>
|
1121
|
+
* To create an IncrementRounder, use one of the factory methods on Rounder.
|
1122
|
+
*
|
1123
|
+
* @draft ICU 60
|
1124
|
+
*/
|
1125
|
+
class U_I18N_API IncrementRounder : public Rounder {
|
1126
|
+
public:
|
1127
|
+
/**
|
1128
|
+
* Specifies the minimum number of fraction digits to render after the decimal separator, padding with zeros if
|
1129
|
+
* necessary. By default, no trailing zeros are added.
|
1130
|
+
*
|
1131
|
+
* <p>
|
1132
|
+
* For example, if the rounding increment is 0.5 and minFrac is 2, then the resulting strings include "0.00",
|
1133
|
+
* "0.50", "1.00", and "1.50".
|
1134
|
+
*
|
1135
|
+
* <p>
|
1136
|
+
* Note: In ICU4J, this functionality is accomplished via the scale of the BigDecimal rounding increment.
|
1137
|
+
*
|
1138
|
+
* @param minFrac The minimum number of digits after the decimal separator.
|
1139
|
+
* @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
|
1140
|
+
* @draft ICU 60
|
1141
|
+
*/
|
1142
|
+
Rounder withMinFraction(int32_t minFrac) const;
|
1143
|
+
|
1144
|
+
private:
|
1145
|
+
// Inherit constructor
|
1146
|
+
using Rounder::Rounder;
|
1147
|
+
|
1148
|
+
// To allow parent class to call this class's constructor:
|
1149
|
+
friend class Rounder;
|
1150
|
+
};
|
1151
|
+
|
1152
|
+
/**
|
1153
|
+
* A class that defines the strategy for padding and truncating integers before the decimal separator.
|
1154
|
+
*
|
1155
|
+
* <p>
|
1156
|
+
* To create an IntegerWidth, use one of the factory methods.
|
1157
|
+
*
|
1158
|
+
* @draft ICU 60
|
1159
|
+
* @see NumberFormatter
|
1160
|
+
*/
|
1161
|
+
class U_I18N_API IntegerWidth : public UMemory {
|
1162
|
+
public:
|
1163
|
+
/**
|
1164
|
+
* Pad numbers at the beginning with zeros to guarantee a certain number of numerals before the decimal separator.
|
1165
|
+
*
|
1166
|
+
* <p>
|
1167
|
+
* For example, with minInt=3, the number 55 will get printed as "055".
|
1168
|
+
*
|
1169
|
+
* @param minInt
|
1170
|
+
* The minimum number of places before the decimal separator.
|
1171
|
+
* @return An IntegerWidth for chaining or passing to the NumberFormatter integerWidth() setter.
|
1172
|
+
* @draft ICU 60
|
1173
|
+
* @see NumberFormatter
|
1174
|
+
*/
|
1175
|
+
static IntegerWidth zeroFillTo(int32_t minInt);
|
1176
|
+
|
1177
|
+
/**
|
1178
|
+
* Truncate numbers exceeding a certain number of numerals before the decimal separator.
|
1179
|
+
*
|
1180
|
+
* For example, with maxInt=3, the number 1234 will get printed as "234".
|
1181
|
+
*
|
1182
|
+
* @param maxInt
|
1183
|
+
* The maximum number of places before the decimal separator. maxInt == -1 means no
|
1184
|
+
* truncation.
|
1185
|
+
* @return An IntegerWidth for passing to the NumberFormatter integerWidth() setter.
|
1186
|
+
* @draft ICU 60
|
1187
|
+
* @see NumberFormatter
|
1188
|
+
*/
|
1189
|
+
IntegerWidth truncateAt(int32_t maxInt);
|
1190
|
+
|
1191
|
+
private:
|
1192
|
+
union {
|
1193
|
+
struct {
|
1194
|
+
impl::digits_t fMinInt;
|
1195
|
+
impl::digits_t fMaxInt;
|
1196
|
+
} minMaxInt;
|
1197
|
+
UErrorCode errorCode;
|
1198
|
+
} fUnion;
|
1199
|
+
bool fHasError = false;
|
1200
|
+
|
1201
|
+
IntegerWidth(impl::digits_t minInt, impl::digits_t maxInt);
|
1202
|
+
|
1203
|
+
IntegerWidth(UErrorCode errorCode) { // NOLINT
|
1204
|
+
fUnion.errorCode = errorCode;
|
1205
|
+
fHasError = true;
|
1206
|
+
}
|
1207
|
+
|
1208
|
+
IntegerWidth() { // NOLINT
|
1209
|
+
fUnion.minMaxInt.fMinInt = -1;
|
1210
|
+
}
|
1211
|
+
|
1212
|
+
bool isBogus() const {
|
1213
|
+
return !fHasError && fUnion.minMaxInt.fMinInt == -1;
|
1214
|
+
}
|
1215
|
+
|
1216
|
+
UBool copyErrorTo(UErrorCode &status) const {
|
1217
|
+
if (fHasError) {
|
1218
|
+
status = fUnion.errorCode;
|
1219
|
+
return TRUE;
|
1220
|
+
}
|
1221
|
+
return FALSE;
|
1222
|
+
}
|
1223
|
+
|
1224
|
+
void apply(impl::DecimalQuantity &quantity, UErrorCode &status) const;
|
1225
|
+
|
1226
|
+
// To allow MacroProps/MicroProps to initialize empty instances:
|
1227
|
+
friend struct impl::MacroProps;
|
1228
|
+
friend struct impl::MicroProps;
|
1229
|
+
|
1230
|
+
// To allow NumberFormatterImpl to access isBogus() and perform other operations:
|
1231
|
+
friend class impl::NumberFormatterImpl;
|
1232
|
+
};
|
1233
|
+
|
1234
|
+
namespace impl {
|
1235
|
+
|
1236
|
+
// Do not enclose entire SymbolsWrapper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
|
1237
|
+
/** @internal */
|
1238
|
+
class U_I18N_API SymbolsWrapper : public UMemory {
|
1239
|
+
public:
|
1240
|
+
/** @internal */
|
1241
|
+
SymbolsWrapper() : fType(SYMPTR_NONE), fPtr{nullptr} {}
|
1242
|
+
|
1243
|
+
/** @internal */
|
1244
|
+
SymbolsWrapper(const SymbolsWrapper &other);
|
1245
|
+
|
1246
|
+
/** @internal */
|
1247
|
+
~SymbolsWrapper();
|
1248
|
+
|
1249
|
+
/** @internal */
|
1250
|
+
SymbolsWrapper &operator=(const SymbolsWrapper &other);
|
1251
|
+
|
1252
|
+
#ifndef U_HIDE_INTERNAL_API
|
1253
|
+
/**
|
1254
|
+
* The provided object is copied, but we do not adopt it.
|
1255
|
+
* @internal
|
1256
|
+
*/
|
1257
|
+
void setTo(const DecimalFormatSymbols &dfs);
|
1258
|
+
|
1259
|
+
/**
|
1260
|
+
* Adopt the provided object.
|
1261
|
+
* @internal
|
1262
|
+
*/
|
1263
|
+
void setTo(const NumberingSystem *ns);
|
1264
|
+
|
1265
|
+
/**
|
1266
|
+
* Whether the object is currently holding a DecimalFormatSymbols.
|
1267
|
+
* @internal
|
1268
|
+
*/
|
1269
|
+
bool isDecimalFormatSymbols() const;
|
1270
|
+
|
1271
|
+
/**
|
1272
|
+
* Whether the object is currently holding a NumberingSystem.
|
1273
|
+
* @internal
|
1274
|
+
*/
|
1275
|
+
bool isNumberingSystem() const;
|
1276
|
+
|
1277
|
+
/**
|
1278
|
+
* Get the DecimalFormatSymbols pointer. No ownership change.
|
1279
|
+
* @internal
|
1280
|
+
*/
|
1281
|
+
const DecimalFormatSymbols *getDecimalFormatSymbols() const;
|
1282
|
+
|
1283
|
+
/**
|
1284
|
+
* Get the NumberingSystem pointer. No ownership change.
|
1285
|
+
* @internal
|
1286
|
+
*/
|
1287
|
+
const NumberingSystem *getNumberingSystem() const;
|
1288
|
+
|
1289
|
+
/** @internal */
|
1290
|
+
UBool copyErrorTo(UErrorCode &status) const {
|
1291
|
+
if (fType == SYMPTR_DFS && fPtr.dfs == nullptr) {
|
1292
|
+
status = U_MEMORY_ALLOCATION_ERROR;
|
1293
|
+
return TRUE;
|
1294
|
+
} else if (fType == SYMPTR_NS && fPtr.ns == nullptr) {
|
1295
|
+
status = U_MEMORY_ALLOCATION_ERROR;
|
1296
|
+
return TRUE;
|
1297
|
+
}
|
1298
|
+
return FALSE;
|
1299
|
+
}
|
1300
|
+
#endif // U_HIDE_INTERNAL_API
|
1301
|
+
|
1302
|
+
private:
|
1303
|
+
enum SymbolsPointerType {
|
1304
|
+
SYMPTR_NONE, SYMPTR_DFS, SYMPTR_NS
|
1305
|
+
} fType;
|
1306
|
+
|
1307
|
+
union {
|
1308
|
+
const DecimalFormatSymbols *dfs;
|
1309
|
+
const NumberingSystem *ns;
|
1310
|
+
} fPtr;
|
1311
|
+
|
1312
|
+
void doCopyFrom(const SymbolsWrapper &other);
|
1313
|
+
|
1314
|
+
void doCleanup();
|
1315
|
+
};
|
1316
|
+
|
1317
|
+
// Do not enclose entire Grouper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
|
1318
|
+
/** @internal */
|
1319
|
+
class U_I18N_API Grouper : public UMemory {
|
1320
|
+
public:
|
1321
|
+
#ifndef U_HIDE_INTERNAL_API
|
1322
|
+
/** @internal */
|
1323
|
+
static Grouper forStrategy(UGroupingStrategy grouping);
|
1324
|
+
|
1325
|
+
// Future: static Grouper forProperties(DecimalFormatProperties& properties);
|
1326
|
+
|
1327
|
+
/** @internal */
|
1328
|
+
Grouper(int16_t grouping1, int16_t grouping2, int16_t minGrouping)
|
1329
|
+
: fGrouping1(grouping1), fGrouping2(grouping2), fMinGrouping(minGrouping) {}
|
1330
|
+
#endif // U_HIDE_INTERNAL_API
|
1331
|
+
|
1332
|
+
private:
|
1333
|
+
/**
|
1334
|
+
* The grouping sizes, with the following special values:
|
1335
|
+
* <ul>
|
1336
|
+
* <li>-1 = no grouping
|
1337
|
+
* <li>-2 = needs locale data
|
1338
|
+
* <li>-4 = fall back to Western grouping if not in locale
|
1339
|
+
* </ul>
|
1340
|
+
*/
|
1341
|
+
int16_t fGrouping1;
|
1342
|
+
int16_t fGrouping2;
|
1343
|
+
|
1344
|
+
/**
|
1345
|
+
* The minimum gropuing size, with the following special values:
|
1346
|
+
* <ul>
|
1347
|
+
* <li>-2 = needs locale data
|
1348
|
+
* <li>-3 = no less than 2
|
1349
|
+
* </ul>
|
1350
|
+
*/
|
1351
|
+
int16_t fMinGrouping;
|
1352
|
+
|
1353
|
+
Grouper() : fGrouping1(-3) {};
|
1354
|
+
|
1355
|
+
bool isBogus() const {
|
1356
|
+
return fGrouping1 == -3;
|
1357
|
+
}
|
1358
|
+
|
1359
|
+
/** NON-CONST: mutates the current instance. */
|
1360
|
+
void setLocaleData(const impl::ParsedPatternInfo &patternInfo, const Locale& locale);
|
1361
|
+
|
1362
|
+
bool groupAtPosition(int32_t position, const impl::DecimalQuantity &value) const;
|
1363
|
+
|
1364
|
+
// To allow MacroProps/MicroProps to initialize empty instances:
|
1365
|
+
friend struct MacroProps;
|
1366
|
+
friend struct MicroProps;
|
1367
|
+
|
1368
|
+
// To allow NumberFormatterImpl to access isBogus() and perform other operations:
|
1369
|
+
friend class NumberFormatterImpl;
|
1370
|
+
};
|
1371
|
+
|
1372
|
+
// Do not enclose entire Padder with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
|
1373
|
+
/** @internal */
|
1374
|
+
class U_I18N_API Padder : public UMemory {
|
1375
|
+
public:
|
1376
|
+
#ifndef U_HIDE_INTERNAL_API
|
1377
|
+
/** @internal */
|
1378
|
+
static Padder none();
|
1379
|
+
|
1380
|
+
/** @internal */
|
1381
|
+
static Padder codePoints(UChar32 cp, int32_t targetWidth, UNumberFormatPadPosition position);
|
1382
|
+
#endif // U_HIDE_INTERNAL_API
|
1383
|
+
|
1384
|
+
private:
|
1385
|
+
UChar32 fWidth; // -3 = error; -2 = bogus; -1 = no padding
|
1386
|
+
union {
|
1387
|
+
struct {
|
1388
|
+
int32_t fCp;
|
1389
|
+
UNumberFormatPadPosition fPosition;
|
1390
|
+
} padding;
|
1391
|
+
UErrorCode errorCode;
|
1392
|
+
} fUnion;
|
1393
|
+
|
1394
|
+
Padder(UChar32 cp, int32_t width, UNumberFormatPadPosition position);
|
1395
|
+
|
1396
|
+
Padder(int32_t width);
|
1397
|
+
|
1398
|
+
Padder(UErrorCode errorCode) : fWidth(-3) { // NOLINT
|
1399
|
+
fUnion.errorCode = errorCode;
|
1400
|
+
}
|
1401
|
+
|
1402
|
+
Padder() : fWidth(-2) {} // NOLINT
|
1403
|
+
|
1404
|
+
bool isBogus() const {
|
1405
|
+
return fWidth == -2;
|
1406
|
+
}
|
1407
|
+
|
1408
|
+
UBool copyErrorTo(UErrorCode &status) const {
|
1409
|
+
if (fWidth == -3) {
|
1410
|
+
status = fUnion.errorCode;
|
1411
|
+
return TRUE;
|
1412
|
+
}
|
1413
|
+
return FALSE;
|
1414
|
+
}
|
1415
|
+
|
1416
|
+
bool isValid() const {
|
1417
|
+
return fWidth > 0;
|
1418
|
+
}
|
1419
|
+
|
1420
|
+
int32_t padAndApply(const impl::Modifier &mod1, const impl::Modifier &mod2,
|
1421
|
+
impl::NumberStringBuilder &string, int32_t leftIndex, int32_t rightIndex,
|
1422
|
+
UErrorCode &status) const;
|
1423
|
+
|
1424
|
+
// To allow MacroProps/MicroProps to initialize empty instances:
|
1425
|
+
friend struct MacroProps;
|
1426
|
+
friend struct MicroProps;
|
1427
|
+
|
1428
|
+
// To allow NumberFormatterImpl to access isBogus() and perform other operations:
|
1429
|
+
friend class impl::NumberFormatterImpl;
|
1430
|
+
};
|
1431
|
+
|
1432
|
+
// Do not enclose entire MacroProps with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
|
1433
|
+
/** @internal */
|
1434
|
+
struct U_I18N_API MacroProps : public UMemory {
|
1435
|
+
/** @internal */
|
1436
|
+
Notation notation;
|
1437
|
+
|
1438
|
+
/** @internal */
|
1439
|
+
MeasureUnit unit; // = NoUnit::base();
|
1440
|
+
|
1441
|
+
/** @internal */
|
1442
|
+
MeasureUnit perUnit; // = NoUnit::base();
|
1443
|
+
|
1444
|
+
/** @internal */
|
1445
|
+
Rounder rounder; // = Rounder(); (bogus)
|
1446
|
+
|
1447
|
+
/** @internal */
|
1448
|
+
Grouper grouper; // = Grouper(); (bogus)
|
1449
|
+
|
1450
|
+
/** @internal */
|
1451
|
+
Padder padder; // = Padder(); (bogus)
|
1452
|
+
|
1453
|
+
/** @internal */
|
1454
|
+
IntegerWidth integerWidth; // = IntegerWidth(); (bogus)
|
1455
|
+
|
1456
|
+
/** @internal */
|
1457
|
+
SymbolsWrapper symbols;
|
1458
|
+
|
1459
|
+
// UNUM_XYZ_COUNT denotes null (bogus) values.
|
1460
|
+
|
1461
|
+
/** @internal */
|
1462
|
+
UNumberUnitWidth unitWidth = UNUM_UNIT_WIDTH_COUNT;
|
1463
|
+
|
1464
|
+
/** @internal */
|
1465
|
+
UNumberSignDisplay sign = UNUM_SIGN_COUNT;
|
1466
|
+
|
1467
|
+
/** @internal */
|
1468
|
+
UNumberDecimalSeparatorDisplay decimal = UNUM_DECIMAL_SEPARATOR_COUNT;
|
1469
|
+
|
1470
|
+
/** @internal */
|
1471
|
+
PluralRules *rules = nullptr; // no ownership
|
1472
|
+
|
1473
|
+
/** @internal */
|
1474
|
+
int32_t threshold = DEFAULT_THRESHOLD;
|
1475
|
+
Locale locale;
|
1476
|
+
|
1477
|
+
/**
|
1478
|
+
* Check all members for errors.
|
1479
|
+
* @internal
|
1480
|
+
*/
|
1481
|
+
bool copyErrorTo(UErrorCode &status) const {
|
1482
|
+
return notation.copyErrorTo(status) || rounder.copyErrorTo(status) ||
|
1483
|
+
padder.copyErrorTo(status) || integerWidth.copyErrorTo(status) ||
|
1484
|
+
symbols.copyErrorTo(status);
|
1485
|
+
}
|
1486
|
+
};
|
1487
|
+
|
1488
|
+
} // namespace impl
|
1489
|
+
|
1490
|
+
/**
|
1491
|
+
* An abstract base class for specifying settings related to number formatting. This class is implemented by
|
1492
|
+
* {@link UnlocalizedNumberFormatter} and {@link LocalizedNumberFormatter}.
|
1493
|
+
*/
|
1494
|
+
template<typename Derived>
|
1495
|
+
class U_I18N_API NumberFormatterSettings {
|
1496
|
+
public:
|
1497
|
+
/**
|
1498
|
+
* Specifies the notation style (simple, scientific, or compact) for rendering numbers.
|
1499
|
+
*
|
1500
|
+
* <ul>
|
1501
|
+
* <li>Simple notation: "12,300"
|
1502
|
+
* <li>Scientific notation: "1.23E4"
|
1503
|
+
* <li>Compact notation: "12K"
|
1504
|
+
* </ul>
|
1505
|
+
*
|
1506
|
+
* <p>
|
1507
|
+
* All notation styles will be properly localized with locale data, and all notation styles are compatible with
|
1508
|
+
* units, rounding strategies, and other number formatter settings.
|
1509
|
+
*
|
1510
|
+
* <p>
|
1511
|
+
* Pass this method the return value of a {@link Notation} factory method. For example:
|
1512
|
+
*
|
1513
|
+
* <pre>
|
1514
|
+
* NumberFormatter::with().notation(Notation::compactShort())
|
1515
|
+
* </pre>
|
1516
|
+
*
|
1517
|
+
* The default is to use simple notation.
|
1518
|
+
*
|
1519
|
+
* @param notation
|
1520
|
+
* The notation strategy to use.
|
1521
|
+
* @return The fluent chain.
|
1522
|
+
* @see Notation
|
1523
|
+
* @draft ICU 60
|
1524
|
+
*/
|
1525
|
+
Derived notation(const Notation ¬ation) const;
|
1526
|
+
|
1527
|
+
/**
|
1528
|
+
* Specifies the unit (unit of measure, currency, or percent) to associate with rendered numbers.
|
1529
|
+
*
|
1530
|
+
* <ul>
|
1531
|
+
* <li>Unit of measure: "12.3 meters"
|
1532
|
+
* <li>Currency: "$12.30"
|
1533
|
+
* <li>Percent: "12.3%"
|
1534
|
+
* </ul>
|
1535
|
+
*
|
1536
|
+
* All units will be properly localized with locale data, and all units are compatible with notation styles,
|
1537
|
+
* rounding strategies, and other number formatter settings.
|
1538
|
+
*
|
1539
|
+
* Pass this method any instance of {@link MeasureUnit}. For units of measure (which often involve the
|
1540
|
+
* factory methods that return a pointer):
|
1541
|
+
*
|
1542
|
+
* <pre>
|
1543
|
+
* NumberFormatter::with().adoptUnit(MeasureUnit::createMeter(status))
|
1544
|
+
* </pre>
|
1545
|
+
*
|
1546
|
+
* Currency:
|
1547
|
+
*
|
1548
|
+
* <pre>
|
1549
|
+
* NumberFormatter::with().unit(CurrencyUnit(u"USD", status))
|
1550
|
+
* </pre>
|
1551
|
+
*
|
1552
|
+
* Percent:
|
1553
|
+
*
|
1554
|
+
* <pre>
|
1555
|
+
* NumberFormatter::with().unit(NoUnit.percent())
|
1556
|
+
* </pre>
|
1557
|
+
*
|
1558
|
+
* See {@link #perUnit} for information on how to format strings like "5 meters per second".
|
1559
|
+
*
|
1560
|
+
* The default is to render without units (equivalent to NoUnit.base()).
|
1561
|
+
*
|
1562
|
+
* @param unit
|
1563
|
+
* The unit to render.
|
1564
|
+
* @return The fluent chain.
|
1565
|
+
* @see MeasureUnit
|
1566
|
+
* @see Currency
|
1567
|
+
* @see NoUnit
|
1568
|
+
* @see #perUnit
|
1569
|
+
* @draft ICU 60
|
1570
|
+
*/
|
1571
|
+
Derived unit(const icu::MeasureUnit &unit) const;
|
1572
|
+
|
1573
|
+
/**
|
1574
|
+
* Like unit(), but takes ownership of a pointer. Convenient for use with the MeasureFormat factory
|
1575
|
+
* methods, which return pointers that need ownership. Example:
|
1576
|
+
*
|
1577
|
+
* <pre>
|
1578
|
+
* NumberFormatter::with().adoptUnit(MeasureUnit::createMeter(status))
|
1579
|
+
* </pre>
|
1580
|
+
*
|
1581
|
+
* @param unit
|
1582
|
+
* The unit to render.
|
1583
|
+
* @return The fluent chain.
|
1584
|
+
* @see #unit
|
1585
|
+
* @see MeasureUnit
|
1586
|
+
* @draft ICU 60
|
1587
|
+
*/
|
1588
|
+
Derived adoptUnit(icu::MeasureUnit *unit) const;
|
1589
|
+
|
1590
|
+
/**
|
1591
|
+
* Sets a unit to be used in the denominator. For example, to format "3 m/s", pass METER to the unit and SECOND to
|
1592
|
+
* the perUnit.
|
1593
|
+
*
|
1594
|
+
* Pass this method any instance of {@link MeasureUnit}. Since MeasureUnit factory methods return pointers, the
|
1595
|
+
* {@link #adoptPerUnit} version of this method is often more useful.
|
1596
|
+
*
|
1597
|
+
* The default is not to display any unit in the denominator.
|
1598
|
+
*
|
1599
|
+
* If a per-unit is specified without a primary unit via {@link #unit}, the behavior is undefined.
|
1600
|
+
*
|
1601
|
+
* @param perUnit
|
1602
|
+
* The unit to render in the denominator.
|
1603
|
+
* @return The fluent chain
|
1604
|
+
* @see #unit
|
1605
|
+
* @draft ICU 61
|
1606
|
+
*/
|
1607
|
+
Derived perUnit(const icu::MeasureUnit &perUnit) const;
|
1608
|
+
|
1609
|
+
/**
|
1610
|
+
* Like perUnit(), but takes ownership of a pointer. Convenient for use with the MeasureFormat factory
|
1611
|
+
* methods, which return pointers that need ownership. Example:
|
1612
|
+
*
|
1613
|
+
* <pre>
|
1614
|
+
* NumberFormatter::with()
|
1615
|
+
* .adoptUnit(MeasureUnit::createMeter(status))
|
1616
|
+
* .adoptPerUnit(MeasureUnit::createSecond(status))
|
1617
|
+
* </pre>
|
1618
|
+
*
|
1619
|
+
* @param perUnit
|
1620
|
+
* The unit to render in the denominator.
|
1621
|
+
* @return The fluent chain.
|
1622
|
+
* @see #perUnit
|
1623
|
+
* @see MeasureUnit
|
1624
|
+
* @draft ICU 61
|
1625
|
+
*/
|
1626
|
+
Derived adoptPerUnit(icu::MeasureUnit *perUnit) const;
|
1627
|
+
|
1628
|
+
/**
|
1629
|
+
* Specifies the rounding strategy to use when formatting numbers.
|
1630
|
+
*
|
1631
|
+
* <ul>
|
1632
|
+
* <li>Round to 3 decimal places: "3.142"
|
1633
|
+
* <li>Round to 3 significant figures: "3.14"
|
1634
|
+
* <li>Round to the closest nickel: "3.15"
|
1635
|
+
* <li>Do not perform rounding: "3.1415926..."
|
1636
|
+
* </ul>
|
1637
|
+
*
|
1638
|
+
* <p>
|
1639
|
+
* Pass this method the return value of one of the factory methods on {@link Rounder}. For example:
|
1640
|
+
*
|
1641
|
+
* <pre>
|
1642
|
+
* NumberFormatter::with().rounding(Rounder::fixedFraction(2))
|
1643
|
+
* </pre>
|
1644
|
+
*
|
1645
|
+
* <p>
|
1646
|
+
* In most cases, the default rounding strategy is to round to 6 fraction places; i.e.,
|
1647
|
+
* <code>Rounder.maxFraction(6)</code>. The exceptions are if compact notation is being used, then the compact
|
1648
|
+
* notation rounding strategy is used (see {@link Notation#compactShort} for details), or if the unit is a currency,
|
1649
|
+
* then standard currency rounding is used, which varies from currency to currency (see {@link Rounder#currency} for
|
1650
|
+
* details).
|
1651
|
+
*
|
1652
|
+
* @param rounder
|
1653
|
+
* The rounding strategy to use.
|
1654
|
+
* @return The fluent chain.
|
1655
|
+
* @see Rounder
|
1656
|
+
* @provisional This API might change or be removed in a future release.
|
1657
|
+
* @draft ICU 60
|
1658
|
+
*/
|
1659
|
+
Derived rounding(const Rounder &rounder) const;
|
1660
|
+
|
1661
|
+
/**
|
1662
|
+
* Specifies the grouping strategy to use when formatting numbers.
|
1663
|
+
*
|
1664
|
+
* <ul>
|
1665
|
+
* <li>Default grouping: "12,300" and "1,230"
|
1666
|
+
* <li>Grouping with at least 2 digits: "12,300" and "1230"
|
1667
|
+
* <li>No grouping: "12300" and "1230"
|
1668
|
+
* </ul>
|
1669
|
+
*
|
1670
|
+
* <p>
|
1671
|
+
* The exact grouping widths will be chosen based on the locale.
|
1672
|
+
*
|
1673
|
+
* <p>
|
1674
|
+
* Pass this method an element from the {@link UGroupingStrategy} enum. For example:
|
1675
|
+
*
|
1676
|
+
* <pre>
|
1677
|
+
* NumberFormatter::with().grouping(UNUM_GROUPING_MIN2)
|
1678
|
+
* </pre>
|
1679
|
+
*
|
1680
|
+
* The default is to perform grouping according to locale data; most locales, but not all locales,
|
1681
|
+
* enable it by default.
|
1682
|
+
*
|
1683
|
+
* @param strategy
|
1684
|
+
* The grouping strategy to use.
|
1685
|
+
* @return The fluent chain.
|
1686
|
+
* @draft ICU 61
|
1687
|
+
*/
|
1688
|
+
Derived grouping(const UGroupingStrategy &strategy) const;
|
1689
|
+
|
1690
|
+
/**
|
1691
|
+
* Specifies the minimum and maximum number of digits to render before the decimal mark.
|
1692
|
+
*
|
1693
|
+
* <ul>
|
1694
|
+
* <li>Zero minimum integer digits: ".08"
|
1695
|
+
* <li>One minimum integer digit: "0.08"
|
1696
|
+
* <li>Two minimum integer digits: "00.08"
|
1697
|
+
* </ul>
|
1698
|
+
*
|
1699
|
+
* <p>
|
1700
|
+
* Pass this method the return value of {@link IntegerWidth#zeroFillTo(int)}. For example:
|
1701
|
+
*
|
1702
|
+
* <pre>
|
1703
|
+
* NumberFormatter::with().integerWidth(IntegerWidth::zeroFillTo(2))
|
1704
|
+
* </pre>
|
1705
|
+
*
|
1706
|
+
* The default is to have one minimum integer digit.
|
1707
|
+
*
|
1708
|
+
* @param style
|
1709
|
+
* The integer width to use.
|
1710
|
+
* @return The fluent chain.
|
1711
|
+
* @see IntegerWidth
|
1712
|
+
* @draft ICU 60
|
1713
|
+
*/
|
1714
|
+
Derived integerWidth(const IntegerWidth &style) const;
|
1715
|
+
|
1716
|
+
/**
|
1717
|
+
* Specifies the symbols (decimal separator, grouping separator, percent sign, numerals, etc.) to use when rendering
|
1718
|
+
* numbers.
|
1719
|
+
*
|
1720
|
+
* <ul>
|
1721
|
+
* <li><em>en_US</em> symbols: "12,345.67"
|
1722
|
+
* <li><em>fr_FR</em> symbols: "12 345,67"
|
1723
|
+
* <li><em>de_CH</em> symbols: "12’345.67"
|
1724
|
+
* <li><em>my_MY</em> symbols: "၁၂,၃၄၅.၆၇"
|
1725
|
+
* </ul>
|
1726
|
+
*
|
1727
|
+
* <p>
|
1728
|
+
* Pass this method an instance of {@link DecimalFormatSymbols}. For example:
|
1729
|
+
*
|
1730
|
+
* <pre>
|
1731
|
+
* NumberFormatter::with().symbols(DecimalFormatSymbols(Locale("de_CH"), status))
|
1732
|
+
* </pre>
|
1733
|
+
*
|
1734
|
+
* <p>
|
1735
|
+
* <strong>Note:</strong> DecimalFormatSymbols automatically chooses the best numbering system based on the locale.
|
1736
|
+
* In the examples above, the first three are using the Latin numbering system, and the fourth is using the Myanmar
|
1737
|
+
* numbering system.
|
1738
|
+
*
|
1739
|
+
* <p>
|
1740
|
+
* <strong>Note:</strong> The instance of DecimalFormatSymbols will be copied: changes made to the symbols object
|
1741
|
+
* after passing it into the fluent chain will not be seen.
|
1742
|
+
*
|
1743
|
+
* <p>
|
1744
|
+
* <strong>Note:</strong> Calling this method will override the NumberingSystem previously specified in
|
1745
|
+
* {@link #symbols(NumberingSystem)}.
|
1746
|
+
*
|
1747
|
+
* <p>
|
1748
|
+
* The default is to choose the symbols based on the locale specified in the fluent chain.
|
1749
|
+
*
|
1750
|
+
* @param symbols
|
1751
|
+
* The DecimalFormatSymbols to use.
|
1752
|
+
* @return The fluent chain.
|
1753
|
+
* @see DecimalFormatSymbols
|
1754
|
+
* @draft ICU 60
|
1755
|
+
*/
|
1756
|
+
Derived symbols(const DecimalFormatSymbols &symbols) const;
|
1757
|
+
|
1758
|
+
/**
|
1759
|
+
* Specifies that the given numbering system should be used when fetching symbols.
|
1760
|
+
*
|
1761
|
+
* <ul>
|
1762
|
+
* <li>Latin numbering system: "12,345"
|
1763
|
+
* <li>Myanmar numbering system: "၁၂,၃၄၅"
|
1764
|
+
* <li>Math Sans Bold numbering system: "𝟭𝟮,𝟯𝟰𝟱"
|
1765
|
+
* </ul>
|
1766
|
+
*
|
1767
|
+
* <p>
|
1768
|
+
* Pass this method an instance of {@link NumberingSystem}. For example, to force the locale to always use the Latin
|
1769
|
+
* alphabet numbering system (ASCII digits):
|
1770
|
+
*
|
1771
|
+
* <pre>
|
1772
|
+
* NumberFormatter::with().adoptSymbols(NumberingSystem::createInstanceByName("latn", status))
|
1773
|
+
* </pre>
|
1774
|
+
*
|
1775
|
+
* <p>
|
1776
|
+
* <strong>Note:</strong> Calling this method will override the DecimalFormatSymbols previously specified in
|
1777
|
+
* {@link #symbols(DecimalFormatSymbols)}.
|
1778
|
+
*
|
1779
|
+
* <p>
|
1780
|
+
* The default is to choose the best numbering system for the locale.
|
1781
|
+
*
|
1782
|
+
* <p>
|
1783
|
+
* This method takes ownership of a pointer in order to work nicely with the NumberingSystem factory methods.
|
1784
|
+
*
|
1785
|
+
* @param symbols
|
1786
|
+
* The NumberingSystem to use.
|
1787
|
+
* @return The fluent chain.
|
1788
|
+
* @see NumberingSystem
|
1789
|
+
* @draft ICU 60
|
1790
|
+
*/
|
1791
|
+
Derived adoptSymbols(NumberingSystem *symbols) const;
|
1792
|
+
|
1793
|
+
/**
|
1794
|
+
* Sets the width of the unit (measure unit or currency). Most common values:
|
1795
|
+
*
|
1796
|
+
* <ul>
|
1797
|
+
* <li>Short: "$12.00", "12 m"
|
1798
|
+
* <li>ISO Code: "USD 12.00"
|
1799
|
+
* <li>Full name: "12.00 US dollars", "12 meters"
|
1800
|
+
* </ul>
|
1801
|
+
*
|
1802
|
+
* <p>
|
1803
|
+
* Pass an element from the {@link UNumberUnitWidth} enum to this setter. For example:
|
1804
|
+
*
|
1805
|
+
* <pre>
|
1806
|
+
* NumberFormatter::with().unitWidth(UNumberUnitWidth::UNUM_UNIT_WIDTH_FULL_NAME)
|
1807
|
+
* </pre>
|
1808
|
+
*
|
1809
|
+
* <p>
|
1810
|
+
* The default is the SHORT width.
|
1811
|
+
*
|
1812
|
+
* @param width
|
1813
|
+
* The width to use when rendering numbers.
|
1814
|
+
* @return The fluent chain
|
1815
|
+
* @see UNumberUnitWidth
|
1816
|
+
* @draft ICU 60
|
1817
|
+
*/
|
1818
|
+
Derived unitWidth(const UNumberUnitWidth &width) const;
|
1819
|
+
|
1820
|
+
/**
|
1821
|
+
* Sets the plus/minus sign display strategy. Most common values:
|
1822
|
+
*
|
1823
|
+
* <ul>
|
1824
|
+
* <li>Auto: "123", "-123"
|
1825
|
+
* <li>Always: "+123", "-123"
|
1826
|
+
* <li>Accounting: "$123", "($123)"
|
1827
|
+
* </ul>
|
1828
|
+
*
|
1829
|
+
* <p>
|
1830
|
+
* Pass an element from the {@link UNumberSignDisplay} enum to this setter. For example:
|
1831
|
+
*
|
1832
|
+
* <pre>
|
1833
|
+
* NumberFormatter::with().sign(UNumberSignDisplay::UNUM_SIGN_ALWAYS)
|
1834
|
+
* </pre>
|
1835
|
+
*
|
1836
|
+
* <p>
|
1837
|
+
* The default is AUTO sign display.
|
1838
|
+
*
|
1839
|
+
* @param width
|
1840
|
+
* The sign display strategy to use when rendering numbers.
|
1841
|
+
* @return The fluent chain
|
1842
|
+
* @see UNumberSignDisplay
|
1843
|
+
* @provisional This API might change or be removed in a future release.
|
1844
|
+
* @draft ICU 60
|
1845
|
+
*/
|
1846
|
+
Derived sign(const UNumberSignDisplay &width) const;
|
1847
|
+
|
1848
|
+
/**
|
1849
|
+
* Sets the decimal separator display strategy. This affects integer numbers with no fraction part. Most common
|
1850
|
+
* values:
|
1851
|
+
*
|
1852
|
+
* <ul>
|
1853
|
+
* <li>Auto: "1"
|
1854
|
+
* <li>Always: "1."
|
1855
|
+
* </ul>
|
1856
|
+
*
|
1857
|
+
* <p>
|
1858
|
+
* Pass an element from the {@link UNumberDecimalSeparatorDisplay} enum to this setter. For example:
|
1859
|
+
*
|
1860
|
+
* <pre>
|
1861
|
+
* NumberFormatter::with().decimal(UNumberDecimalSeparatorDisplay::UNUM_DECIMAL_SEPARATOR_ALWAYS)
|
1862
|
+
* </pre>
|
1863
|
+
*
|
1864
|
+
* <p>
|
1865
|
+
* The default is AUTO decimal separator display.
|
1866
|
+
*
|
1867
|
+
* @param width
|
1868
|
+
* The decimal separator display strategy to use when rendering numbers.
|
1869
|
+
* @return The fluent chain
|
1870
|
+
* @see UNumberDecimalSeparatorDisplay
|
1871
|
+
* @provisional This API might change or be removed in a future release.
|
1872
|
+
* @draft ICU 60
|
1873
|
+
*/
|
1874
|
+
Derived decimal(const UNumberDecimalSeparatorDisplay &width) const;
|
1875
|
+
|
1876
|
+
#ifndef U_HIDE_INTERNAL_API
|
1877
|
+
|
1878
|
+
/**
|
1879
|
+
* Set the padding strategy. May be added to ICU 61; see #13338.
|
1880
|
+
*
|
1881
|
+
* @internal ICU 60: This API is ICU internal only.
|
1882
|
+
*/
|
1883
|
+
Derived padding(const impl::Padder &padder) const;
|
1884
|
+
|
1885
|
+
/**
|
1886
|
+
* Internal fluent setter to support a custom regulation threshold. A threshold of 1 causes the data structures to
|
1887
|
+
* be built right away. A threshold of 0 prevents the data structures from being built.
|
1888
|
+
*
|
1889
|
+
* @internal ICU 60: This API is ICU internal only.
|
1890
|
+
*/
|
1891
|
+
Derived threshold(int32_t threshold) const;
|
1892
|
+
|
1893
|
+
#endif /* U_HIDE_INTERNAL_API */
|
1894
|
+
|
1895
|
+
/**
|
1896
|
+
* Sets the UErrorCode if an error occurred in the fluent chain.
|
1897
|
+
* Preserves older error codes in the outErrorCode.
|
1898
|
+
* @return TRUE if U_FAILURE(outErrorCode)
|
1899
|
+
* @draft ICU 60
|
1900
|
+
*/
|
1901
|
+
UBool copyErrorTo(UErrorCode &outErrorCode) const {
|
1902
|
+
if (U_FAILURE(outErrorCode)) {
|
1903
|
+
// Do not overwrite the older error code
|
1904
|
+
return TRUE;
|
1905
|
+
}
|
1906
|
+
fMacros.copyErrorTo(outErrorCode);
|
1907
|
+
return U_FAILURE(outErrorCode);
|
1908
|
+
}
|
1909
|
+
|
1910
|
+
protected:
|
1911
|
+
impl::MacroProps fMacros;
|
1912
|
+
|
1913
|
+
private:
|
1914
|
+
// Don't construct me directly! Use (Un)LocalizedNumberFormatter.
|
1915
|
+
NumberFormatterSettings() = default;
|
1916
|
+
|
1917
|
+
friend class LocalizedNumberFormatter;
|
1918
|
+
friend class UnlocalizedNumberFormatter;
|
1919
|
+
};
|
1920
|
+
|
1921
|
+
/**
|
1922
|
+
* A NumberFormatter that does not yet have a locale. In order to format numbers, a locale must be specified.
|
1923
|
+
*
|
1924
|
+
* @see NumberFormatter
|
1925
|
+
* @draft ICU 60
|
1926
|
+
*/
|
1927
|
+
class U_I18N_API UnlocalizedNumberFormatter
|
1928
|
+
: public NumberFormatterSettings<UnlocalizedNumberFormatter>, public UMemory {
|
1929
|
+
|
1930
|
+
public:
|
1931
|
+
/**
|
1932
|
+
* Associate the given locale with the number formatter. The locale is used for picking the appropriate symbols,
|
1933
|
+
* formats, and other data for number display.
|
1934
|
+
*
|
1935
|
+
* <p>
|
1936
|
+
* To use the Java default locale, call Locale::getDefault():
|
1937
|
+
*
|
1938
|
+
* <pre>
|
1939
|
+
* NumberFormatter::with(). ... .locale(Locale::getDefault())
|
1940
|
+
* </pre>
|
1941
|
+
*
|
1942
|
+
* @param locale
|
1943
|
+
* The locale to use when loading data for number formatting.
|
1944
|
+
* @return The fluent chain.
|
1945
|
+
* @draft ICU 60
|
1946
|
+
*/
|
1947
|
+
LocalizedNumberFormatter locale(const icu::Locale &locale) const;
|
1948
|
+
|
1949
|
+
// Make default copy constructor call the NumberFormatterSettings copy constructor.
|
1950
|
+
/**
|
1951
|
+
* Returns a copy of this UnlocalizedNumberFormatter.
|
1952
|
+
* @draft ICU 60
|
1953
|
+
*/
|
1954
|
+
UnlocalizedNumberFormatter(const UnlocalizedNumberFormatter &other) : UnlocalizedNumberFormatter(
|
1955
|
+
static_cast<const NumberFormatterSettings<UnlocalizedNumberFormatter> &>(other)) {}
|
1956
|
+
|
1957
|
+
private:
|
1958
|
+
UnlocalizedNumberFormatter() = default;
|
1959
|
+
|
1960
|
+
explicit UnlocalizedNumberFormatter(
|
1961
|
+
const NumberFormatterSettings<UnlocalizedNumberFormatter> &other);
|
1962
|
+
|
1963
|
+
// To give the fluent setters access to this class's constructor:
|
1964
|
+
friend class NumberFormatterSettings<UnlocalizedNumberFormatter>;
|
1965
|
+
|
1966
|
+
// To give NumberFormatter::with() access to this class's constructor:
|
1967
|
+
friend class NumberFormatter;
|
1968
|
+
};
|
1969
|
+
|
1970
|
+
/**
|
1971
|
+
* A NumberFormatter that has a locale associated with it; this means .format() methods are available.
|
1972
|
+
*
|
1973
|
+
* @see NumberFormatter
|
1974
|
+
* @draft ICU 60
|
1975
|
+
*/
|
1976
|
+
class U_I18N_API LocalizedNumberFormatter
|
1977
|
+
: public NumberFormatterSettings<LocalizedNumberFormatter>, public UMemory {
|
1978
|
+
public:
|
1979
|
+
/**
|
1980
|
+
* Format the given integer number to a string using the settings specified in the NumberFormatter fluent
|
1981
|
+
* setting chain.
|
1982
|
+
*
|
1983
|
+
* @param value
|
1984
|
+
* The number to format.
|
1985
|
+
* @param status
|
1986
|
+
* Set to an ErrorCode if one occurred in the setter chain or during formatting.
|
1987
|
+
* @return A FormattedNumber object; call .toString() to get the string.
|
1988
|
+
* @draft ICU 60
|
1989
|
+
*/
|
1990
|
+
FormattedNumber formatInt(int64_t value, UErrorCode &status) const;
|
1991
|
+
|
1992
|
+
/**
|
1993
|
+
* Format the given float or double to a string using the settings specified in the NumberFormatter fluent setting
|
1994
|
+
* chain.
|
1995
|
+
*
|
1996
|
+
* @param value
|
1997
|
+
* The number to format.
|
1998
|
+
* @param status
|
1999
|
+
* Set to an ErrorCode if one occurred in the setter chain or during formatting.
|
2000
|
+
* @return A FormattedNumber object; call .toString() to get the string.
|
2001
|
+
* @draft ICU 60
|
2002
|
+
*/
|
2003
|
+
FormattedNumber formatDouble(double value, UErrorCode &status) const;
|
2004
|
+
|
2005
|
+
/**
|
2006
|
+
* Format the given decimal number to a string using the settings
|
2007
|
+
* specified in the NumberFormatter fluent setting chain.
|
2008
|
+
* The syntax of the unformatted number is a "numeric string"
|
2009
|
+
* as defined in the Decimal Arithmetic Specification, available at
|
2010
|
+
* http://speleotrove.com/decimal
|
2011
|
+
*
|
2012
|
+
* @param value
|
2013
|
+
* The number to format.
|
2014
|
+
* @param status
|
2015
|
+
* Set to an ErrorCode if one occurred in the setter chain or during formatting.
|
2016
|
+
* @return A FormattedNumber object; call .toString() to get the string.
|
2017
|
+
* @draft ICU 60
|
2018
|
+
*/
|
2019
|
+
FormattedNumber formatDecimal(StringPiece value, UErrorCode &status) const;
|
2020
|
+
|
2021
|
+
// Make default copy constructor call the NumberFormatterSettings copy constructor.
|
2022
|
+
/**
|
2023
|
+
* Returns a copy of this LocalizedNumberFormatter.
|
2024
|
+
* @draft ICU 60
|
2025
|
+
*/
|
2026
|
+
LocalizedNumberFormatter(const LocalizedNumberFormatter &other) : LocalizedNumberFormatter(
|
2027
|
+
static_cast<const NumberFormatterSettings<LocalizedNumberFormatter> &>(other)) {}
|
2028
|
+
|
2029
|
+
/**
|
2030
|
+
* Destruct this LocalizedNumberFormatter, cleaning up any memory it might own.
|
2031
|
+
* @draft ICU 60
|
2032
|
+
*/
|
2033
|
+
~LocalizedNumberFormatter();
|
2034
|
+
|
2035
|
+
private:
|
2036
|
+
const impl::NumberFormatterImpl* fCompiled {nullptr};
|
2037
|
+
char fUnsafeCallCount[8] {}; // internally cast to u_atomic_int32_t
|
2038
|
+
|
2039
|
+
LocalizedNumberFormatter() = default;
|
2040
|
+
|
2041
|
+
explicit LocalizedNumberFormatter(const NumberFormatterSettings<LocalizedNumberFormatter> &other);
|
2042
|
+
|
2043
|
+
LocalizedNumberFormatter(const impl::MacroProps ¯os, const Locale &locale);
|
2044
|
+
|
2045
|
+
/**
|
2046
|
+
* This is the core entrypoint to the number formatting pipeline. It performs self-regulation: a static code path
|
2047
|
+
* for the first few calls, and compiling a more efficient data structure if called repeatedly.
|
2048
|
+
*
|
2049
|
+
* <p>
|
2050
|
+
* This function is very hot, being called in every call to the number formatting pipeline.
|
2051
|
+
*
|
2052
|
+
* @param results
|
2053
|
+
* The results object. This method takes ownership.
|
2054
|
+
* @return The formatted number result.
|
2055
|
+
*/
|
2056
|
+
FormattedNumber formatImpl(impl::NumberFormatterResults *results, UErrorCode &status) const;
|
2057
|
+
|
2058
|
+
// To give the fluent setters access to this class's constructor:
|
2059
|
+
friend class NumberFormatterSettings<UnlocalizedNumberFormatter>;
|
2060
|
+
friend class NumberFormatterSettings<LocalizedNumberFormatter>;
|
2061
|
+
|
2062
|
+
// To give UnlocalizedNumberFormatter::locale() access to this class's constructor:
|
2063
|
+
friend class UnlocalizedNumberFormatter;
|
2064
|
+
};
|
2065
|
+
|
2066
|
+
/**
|
2067
|
+
* The result of a number formatting operation. This class allows the result to be exported in several data types,
|
2068
|
+
* including a UnicodeString and a FieldPositionIterator.
|
2069
|
+
*
|
2070
|
+
* @draft ICU 60
|
2071
|
+
*/
|
2072
|
+
class U_I18N_API FormattedNumber : public UMemory {
|
2073
|
+
public:
|
2074
|
+
/**
|
2075
|
+
* Returns a UnicodeString representation of the formatted number.
|
2076
|
+
*
|
2077
|
+
* @return a UnicodeString containing the localized number.
|
2078
|
+
* @draft ICU 60
|
2079
|
+
*/
|
2080
|
+
UnicodeString toString() const;
|
2081
|
+
|
2082
|
+
/**
|
2083
|
+
* Appends the formatted number to an Appendable.
|
2084
|
+
*
|
2085
|
+
* @param appendable
|
2086
|
+
* The Appendable to which to append the formatted number string.
|
2087
|
+
* @return The same Appendable, for chaining.
|
2088
|
+
* @draft ICU 60
|
2089
|
+
* @see Appendable
|
2090
|
+
*/
|
2091
|
+
Appendable &appendTo(Appendable &appendable);
|
2092
|
+
|
2093
|
+
/**
|
2094
|
+
* Determine the start and end indices of the first occurrence of the given <em>field</em> in the output string.
|
2095
|
+
* This allows you to determine the locations of the integer part, fraction part, and sign.
|
2096
|
+
*
|
2097
|
+
* <p>
|
2098
|
+
* If multiple different field attributes are needed, this method can be called repeatedly, or if <em>all</em> field
|
2099
|
+
* attributes are needed, consider using populateFieldPositionIterator().
|
2100
|
+
*
|
2101
|
+
* <p>
|
2102
|
+
* If a field occurs multiple times in an output string, such as a grouping separator, this method will only ever
|
2103
|
+
* return the first occurrence. Use populateFieldPositionIterator() to access all occurrences of an attribute.
|
2104
|
+
*
|
2105
|
+
* @param fieldPosition
|
2106
|
+
* The FieldPosition to populate with the start and end indices of the desired field.
|
2107
|
+
* @param status
|
2108
|
+
* Set if an error occurs while populating the FieldPosition.
|
2109
|
+
* @draft ICU 60
|
2110
|
+
* @see UNumberFormatFields
|
2111
|
+
*/
|
2112
|
+
void populateFieldPosition(FieldPosition &fieldPosition, UErrorCode &status);
|
2113
|
+
|
2114
|
+
/**
|
2115
|
+
* Export the formatted number to a FieldPositionIterator. This allows you to determine which characters in
|
2116
|
+
* the output string correspond to which <em>fields</em>, such as the integer part, fraction part, and sign.
|
2117
|
+
*
|
2118
|
+
* <p>
|
2119
|
+
* If information on only one field is needed, consider using populateFieldPosition() instead.
|
2120
|
+
*
|
2121
|
+
* @param iterator
|
2122
|
+
* The FieldPositionIterator to populate with all of the fields present in the formatted number.
|
2123
|
+
* @param status
|
2124
|
+
* Set if an error occurs while populating the FieldPositionIterator.
|
2125
|
+
* @draft ICU 60
|
2126
|
+
* @see UNumberFormatFields
|
2127
|
+
*/
|
2128
|
+
void populateFieldPositionIterator(FieldPositionIterator &iterator, UErrorCode &status);
|
2129
|
+
|
2130
|
+
/**
|
2131
|
+
* Destruct an instance of FormattedNumber, cleaning up any memory it might own.
|
2132
|
+
* @draft ICU 60
|
2133
|
+
*/
|
2134
|
+
~FormattedNumber();
|
2135
|
+
|
2136
|
+
private:
|
2137
|
+
// Can't use LocalPointer because NumberFormatterResults is forward-declared
|
2138
|
+
const impl::NumberFormatterResults *fResults;
|
2139
|
+
|
2140
|
+
// Error code for the terminal methods
|
2141
|
+
UErrorCode fErrorCode;
|
2142
|
+
|
2143
|
+
explicit FormattedNumber(impl::NumberFormatterResults *results)
|
2144
|
+
: fResults(results), fErrorCode(U_ZERO_ERROR) {};
|
2145
|
+
|
2146
|
+
explicit FormattedNumber(UErrorCode errorCode)
|
2147
|
+
: fResults(nullptr), fErrorCode(errorCode) {};
|
2148
|
+
|
2149
|
+
// To give LocalizedNumberFormatter format methods access to this class's constructor:
|
2150
|
+
friend class LocalizedNumberFormatter;
|
2151
|
+
};
|
2152
|
+
|
2153
|
+
/**
|
2154
|
+
* See the main description in numberformatter.h for documentation and examples.
|
2155
|
+
*
|
2156
|
+
* @draft ICU 60
|
2157
|
+
*/
|
2158
|
+
class U_I18N_API NumberFormatter final {
|
2159
|
+
public:
|
2160
|
+
/**
|
2161
|
+
* Call this method at the beginning of a NumberFormatter fluent chain in which the locale is not currently known at
|
2162
|
+
* the call site.
|
2163
|
+
*
|
2164
|
+
* @return An {@link UnlocalizedNumberFormatter}, to be used for chaining.
|
2165
|
+
* @draft ICU 60
|
2166
|
+
*/
|
2167
|
+
static UnlocalizedNumberFormatter with();
|
2168
|
+
|
2169
|
+
/**
|
2170
|
+
* Call this method at the beginning of a NumberFormatter fluent chain in which the locale is known at the call
|
2171
|
+
* site.
|
2172
|
+
*
|
2173
|
+
* @param locale
|
2174
|
+
* The locale from which to load formats and symbols for number formatting.
|
2175
|
+
* @return A {@link LocalizedNumberFormatter}, to be used for chaining.
|
2176
|
+
* @draft ICU 60
|
2177
|
+
*/
|
2178
|
+
static LocalizedNumberFormatter withLocale(const Locale &locale);
|
2179
|
+
|
2180
|
+
/**
|
2181
|
+
* Use factory methods instead of the constructor to create a NumberFormatter.
|
2182
|
+
* @draft ICU 60
|
2183
|
+
*/
|
2184
|
+
NumberFormatter() = delete;
|
2185
|
+
};
|
2186
|
+
|
2187
|
+
} // namespace number
|
2188
|
+
U_NAMESPACE_END
|
2189
|
+
|
2190
|
+
#endif // U_HIDE_DRAFT_API
|
2191
|
+
|
2192
|
+
#endif // __NUMBERFORMATTER_H__
|
2193
|
+
|
2194
|
+
#endif /* #if !UCONFIG_NO_FORMATTING */
|