30 * // Setup: 31 * UErrorCode ec = U_ZERO_ERROR; 32 * UNumberRangeFormatter* uformatter = unumrf_openForSkeletonCollapseIdentityFallbackAndLocaleWithError( 33 * u"currency/USD precision-integer", 34 * -1, 35 * UNUM_RANGE_COLLAPSE_AUTO, 36 * UNUM_IDENTITY_FALLBACK_APPROXIMATELY, 37 * "en-US", 38 * NULL, 39 * &ec); 40 * UFormattedNumberRange* uresult = unumrf_openResult(&ec); 41 * if (U_FAILURE(ec)) { return; } 42 * 43 * // Format a double range: 44 * unumrf_formatDoubleRange(uformatter, 3.0, 5.0, uresult, &ec); 45 * if (U_FAILURE(ec)) { return; } 46 * 47 * // Get the result string: 48 * int32_t len; 49 * const UChar* str = ufmtval_getString(unumrf_resultAsValue(uresult, &ec), &len, &ec); 50 * if (U_FAILURE(ec)) { return; } 51 * // str should equal "$3 – $5" 52 * 53 * // Cleanup: 54 * unumf_close(uformatter); 55 * unumf_closeResult(uresult); 56 *
62 * // Setup: 63 * LocalUNumberRangeFormatterPointer uformatter( 64 * unumrf_openForSkeletonCollapseIdentityFallbackAndLocaleWithError(...)); 65 * LocalUFormattedNumberRangePointer uresult(unumrf_openResult(&ec)); 66 * if (U_FAILURE(ec)) { return; } 67 * 68 * // Format a double number range: 69 * unumrf_formatDoubleRange(uformatter.getAlias(), 3.0, 5.0, uresult.getAlias(), &ec); 70 * if (U_FAILURE(ec)) { return; } 71 * 72 * // No need to do any cleanup since we are using LocalPointer. 73 *
439 * LocalUNumberRangeFormatterPointer uformatter( 440 * unumrf_openForSkeletonCollapseIdentityFallbackAndLocaleWithError(...)); 441 * // no need to explicitly call unumrf_close() 442 *
457 * LocalUFormattedNumberRangePointer uresult(unumrf_openResult(...)); 458 * // no need to explicitly call unumrf_closeResult() 459 *