HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Pie
|
9.0.0_r8
下载
查看原文件
收藏
根目录
external
icu
icu4c
source
i18n
scientificnumberformatter.cpp
// © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /* ********************************************************************** * Copyright (c) 2014, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** */ #include "unicode/utypes.h" #if !UCONFIG_NO_FORMATTING #include "unicode/scientificnumberformatter.h" #include "unicode/dcfmtsym.h" #include "unicode/fpositer.h" #include "unicode/utf16.h" #include "unicode/uniset.h" #include "decfmtst.h" #include "unicode/decimfmt.h" U_NAMESPACE_BEGIN static const UChar kSuperscriptDigits[] = { 0x2070, 0xB9, 0xB2, 0xB3, 0x2074, 0x2075, 0x2076, 0x2077, 0x2078, 0x2079}; static const UChar kSuperscriptPlusSign = 0x207A; static const UChar kSuperscriptMinusSign = 0x207B; static UBool copyAsSuperscript( const UnicodeString &s, int32_t beginIndex, int32_t endIndex, UnicodeString &result, UErrorCode &status) { if (U_FAILURE(status)) { return FALSE; } for (int32_t i = beginIndex; i < endIndex;) { UChar32 c = s.char32At(i); int32_t digit = u_charDigitValue(c); if (digit < 0) { status = U_INVALID_CHAR_FOUND; return FALSE; } result.append(kSuperscriptDigits[digit]); i += U16_LENGTH(c); } return TRUE; } ScientificNumberFormatter *ScientificNumberFormatter::createSuperscriptInstance( DecimalFormat *fmtToAdopt, UErrorCode &status) { return createInstance(fmtToAdopt, new SuperscriptStyle(), status); } ScientificNumberFormatter *ScientificNumberFormatter::createSuperscriptInstance( const Locale &locale, UErrorCode &status) { return createInstance( static_cast
( DecimalFormat::createScientificInstance(locale, status)), new SuperscriptStyle(), status); } ScientificNumberFormatter *ScientificNumberFormatter::createMarkupInstance( DecimalFormat *fmtToAdopt, const UnicodeString &beginMarkup, const UnicodeString &endMarkup, UErrorCode &status) { return createInstance( fmtToAdopt, new MarkupStyle(beginMarkup, endMarkup), status); } ScientificNumberFormatter *ScientificNumberFormatter::createMarkupInstance( const Locale &locale, const UnicodeString &beginMarkup, const UnicodeString &endMarkup, UErrorCode &status) { return createInstance( static_cast
( DecimalFormat::createScientificInstance(locale, status)), new MarkupStyle(beginMarkup, endMarkup), status); } ScientificNumberFormatter *ScientificNumberFormatter::createInstance( DecimalFormat *fmtToAdopt, Style *styleToAdopt, UErrorCode &status) { LocalPointer
fmt(fmtToAdopt); LocalPointer