ICU-647 Chaged documentation in header files for compliance with Doxygen

X-SVN-Rev: 3171
This commit is contained in:
Ram Viswanadha 2000-12-08 18:46:55 +00:00
parent 8c3169b6df
commit e2a99295e9
21 changed files with 1012 additions and 823 deletions

View file

@ -63,104 +63,118 @@
* <P>
* Helper function to output text
* <pre>
* . void printTextRange( BreakIterator& iterator, UTextOffset start, UTextOffset end )
* . {
* . UnicodeString textBuffer, temp;
* . CharacterIterator *strIter = iterator.createText();
* . strIter->getText(temp);
* . cout &lt;&lt; " " &lt;&lt; start &lt;&lt; " " &lt;&lt; end &lt;&lt; " |"
* . &lt;&lt; temp.extractBetween(start, end, textBuffer)
* . &lt;&lt; "|" &lt;&lt; endl;
* . delete strIter;
* . }
* \code
* void printTextRange( BreakIterator& iterator, UTextOffset start, UTextOffset end )
* {
* UnicodeString textBuffer, temp;
* CharacterIterator *strIter = iterator.createText();
* strIter->getText(temp);
* cout &lt;&lt; " " &lt;&lt; start &lt;&lt; " " &lt;&lt; end &lt;&lt; " |"
* &lt;&lt; temp.extractBetween(start, end, textBuffer)
* &lt;&lt; "|" &lt;&lt; endl;
* delete strIter;
* }
* \endcode
* </pre>
* Print each element in order:
* <pre>
* . void printEachForward( BreakIterator& boundary)
* . {
* . UTextOffset start = boundary.first();
* . for (UTextOffset end = boundary.next();
* . end != BreakIterator::DONE;
* . start = end, end = boundary.next())
* . {
* . printTextRange( boundary, start, end );
* . }
* . }
* \code
* void printEachForward( BreakIterator& boundary)
* {
* UTextOffset start = boundary.first();
* for (UTextOffset end = boundary.next();
* end != BreakIterator::DONE;
* start = end, end = boundary.next())
* {
* printTextRange( boundary, start, end );
* }
* }
* \code
* </pre>
* Print each element in reverse order:
* <pre>
* . void printEachBackward( BreakIterator& boundary)
* . {
* . UTextOffset end = boundary.last();
* . for (UTextOffset start = boundary.previous();
* . start != BreakIterator::DONE;
* . end = start, start = boundary.previous())
* . {
* . printTextRange( boundary, start, end );
* . }
* . }
* \code
* void printEachBackward( BreakIterator& boundary)
* {
* UTextOffset end = boundary.last();
* for (UTextOffset start = boundary.previous();
* start != BreakIterator::DONE;
* end = start, start = boundary.previous())
* {
* printTextRange( boundary, start, end );
* }
* }
* \endcode
* </pre>
* Print first element
* <pre>
* . void printFirst(BreakIterator& boundary)
* . {
* . UTextOffset start = boundary.first();
* . UTextOffset end = boundary.next();
* . printTextRange( boundary, start, end );
* . }
* \code
* void printFirst(BreakIterator& boundary)
* {
* UTextOffset start = boundary.first();
* UTextOffset end = boundary.next();
* printTextRange( boundary, start, end );
* }
* \endcode
* </pre>
* Print last element
* <pre>
* . void printLast(BreakIterator& boundary)
* . {
* . UTextOffset end = boundary.last();
* . UTextOffset start = boundary.previous();
* . printTextRange( boundary, start, end );
* . }
* \code
* void printLast(BreakIterator& boundary)
* {
* UTextOffset end = boundary.last();
* UTextOffset start = boundary.previous();
* printTextRange( boundary, start, end );
* }
* \endcode
* </pre>
* Print the element at a specified position
* <pre>
* . void printAt(BreakIterator &boundary, UTextOffset pos )
* . {
* . UTextOffset end = boundary.following(pos);
* . UTextOffset start = boundary.previous();
* . printTextRange( boundary, start, end );
* . }
* \code
* void printAt(BreakIterator &boundary, UTextOffset pos )
* {
* UTextOffset end = boundary.following(pos);
* UTextOffset start = boundary.previous();
* printTextRange( boundary, start, end );
* }
* \endcode
* </pre>
* Creating and using text boundaries
* <pre>
* . void BreakIterator_Example( void )
* . {
* . BreakIterator* boundary;
* . UnicodeString stringToExamine("Aaa bbb ccc. Ddd eee fff.");
* . cout &lt;&lt; "Examining: " &lt;&lt; stringToExamine &lt;&lt; endl;
* .
* . //print each sentence in forward and reverse order
* . boundary = BreakIterator::createSentenceInstance( Locale::US );
* . boundary->setText(stringToExamine);
* . cout &lt;&lt; "----- forward: -----------" &lt;&lt; endl;
* . printEachForward(*boundary);
* . cout &lt;&lt; "----- backward: ----------" &lt;&lt; endl;
* . printEachBackward(*boundary);
* . delete boundary;
* .
* . //print each word in order
* . boundary = BreakIterator::createWordInstance();
* . boundary->setText(stringToExamine);
* . cout &lt;&lt; "----- forward: -----------" &lt;&lt; endl;
* . printEachForward(*boundary);
* . //print first element
* . cout &lt;&lt; "----- first: -------------" &lt;&lt; endl;
* . printFirst(*boundary);
* . //print last element
* . cout &lt;&lt; "----- last: --------------" &lt;&lt; endl;
* . printLast(*boundary);
* . //print word at charpos 10
* . cout &lt;&lt; "----- at pos 10: ---------" &lt;&lt; endl;
* . printAt(*boundary, 10 );
* .
* . delete boundary;
* . }
* \code
* void BreakIterator_Example( void )
* {
* BreakIterator* boundary;
* UnicodeString stringToExamine("Aaa bbb ccc. Ddd eee fff.");
* cout &lt;&lt; "Examining: " &lt;&lt; stringToExamine &lt;&lt; endl;
*
* //print each sentence in forward and reverse order
* boundary = BreakIterator::createSentenceInstance( Locale::US );
* boundary->setText(stringToExamine);
* cout &lt;&lt; "----- forward: -----------" &lt;&lt; endl;
* printEachForward(*boundary);
* cout &lt;&lt; "----- backward: ----------" &lt;&lt; endl;
* printEachBackward(*boundary);
* delete boundary;
*
* //print each word in order
* boundary = BreakIterator::createWordInstance();
* boundary->setText(stringToExamine);
* cout &lt;&lt; "----- forward: -----------" &lt;&lt; endl;
* printEachForward(*boundary);
* //print first element
* cout &lt;&lt; "----- first: -------------" &lt;&lt; endl;
* printFirst(*boundary);
* //print last element
* cout &lt;&lt; "----- last: --------------" &lt;&lt; endl;
* printLast(*boundary);
* //print word at charpos 10
* cout &lt;&lt; "----- at pos 10: ---------" &lt;&lt; endl;
* printAt(*boundary, 10 );
*
* delete boundary;
* }
* \endcode
* </pre>
*/
class U_I18N_API BreakIterator {

View file

@ -36,68 +36,76 @@
* The choice is specified with an ascending list of doubles, where each item
* specifies a half-open interval up to the next item:
* <pre>
* . X matches j if and only if limit[j] &lt;= X &lt; limit[j+1]
* \code
* X matches j if and only if limit[j] &lt;= X &lt; limit[j+1]
* \endcode
* </pre>
* If there is no match, then either the first or last index is used, depending
* on whether the number is too low or too high. The length of the array of
* formats must be the same as the length of the array of limits.
* For example,
* <pre>
* . {1,2,3,4,5,6,7},
* . {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"}
* . {0, 1, ChoiceFormat::nextDouble(1)},
* . {"no files", "one file", "many files"}
* \code
* {1,2,3,4,5,6,7},
* {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"}
* {0, 1, ChoiceFormat::nextDouble(1)},
* {"no files", "one file", "many files"}
* \endcode
* </pre>
* (nextDouble can be used to get the next higher double, to make the half-open
* interval.)
* <P>
* Here is a simple example that shows formatting and parsing:
* <pre>
* . void SimpleChoiceExample( void )
* . {
* . double limits[] = {1,2,3,4,5,6,7};
* . UnicodeString monthNames[] = {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"};
* . ChoiceFormat* form = new ChoiceFormat(limits, monthNames, 7 );
* . ParsePosition* status = new ParsePosition(0);
* . UnicodeString str;
* . FieldPosition f1(0), f2(0);
* . for (double i = 0.0; i &lt;= 8.0; ++i) {
* . status->setIndex(0);
* . Formattable parseResult;
* . str.remove();
* . cout &lt;&lt; i &lt;&lt; " -> " &lt;&lt; form->format(i,str, f1)
* . &lt;&lt; " -> " &lt;&lt; parseResult &lt;&lt; endl;
* . }
* . delete form;
* . delete status;
* . cout &lt;&lt; endl;
* . }
* \code
* void SimpleChoiceExample( void )
* {
* double limits[] = {1,2,3,4,5,6,7};
* UnicodeString monthNames[] = {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"};
* ChoiceFormat* form = new ChoiceFormat(limits, monthNames, 7 );
* ParsePosition* status = new ParsePosition(0);
* UnicodeString str;
* FieldPosition f1(0), f2(0);
* for (double i = 0.0; i &lt;= 8.0; ++i) {
* status->setIndex(0);
* Formattable parseResult;
* str.remove();
* cout &lt;&lt; i &lt;&lt; " -> " &lt;&lt; form->format(i,str, f1)
* &lt;&lt; " -> " &lt;&lt; parseResult &lt;&lt; endl;
* }
* delete form;
* delete status;
* cout &lt;&lt; endl;
* }
* \endcode
* </pre>
* Here is a more complex example, with a pattern format.
* <pre>
* . void ComplexChoiceExample( void )
* . {
* . double filelimits[] = {0,1,2};
* . UnicodeString filepart[] = {"are no files","is one file","are {2} files"};
* . ChoiceFormat* fileform = new ChoiceFormat(filelimits, filepart, 3 );
* . UErrorCode success = U_ZERO_ERROR;
* . const Format* testFormats[] = { fileform, NULL, NumberFormat::createInstance(success) };
* . MessageFormat* pattform = new MessageFormat("There {0} on {1}", success );
* . pattform->setFormats( testFormats, 3 );
* . Formattable testArgs[] = {0L, "Disk_A", 0L};
* . FieldPosition fp(0);
* . UnicodeString str;
* . for (int32_t i = 0; i &lt; 4; ++i) {
* . Formattable fInt(i);
* . testArgs[0] = fInt;
* . testArgs[2] = testArgs[0];
* . str.remove();
* . pattform->format(testArgs, 3, str, fp, success );
* . cout &lt;&lt; "Output for i=" &lt;&lt; i &lt;&lt; " : " &lt;&lt; str &lt;&lt; endl;
* . }
* . delete pattform;
* . cout &lt;&lt; endl;
* . }
* \code
* void ComplexChoiceExample( void )
* {
* double filelimits[] = {0,1,2};
* UnicodeString filepart[] = {"are no files","is one file","are {2} files"};
* ChoiceFormat* fileform = new ChoiceFormat(filelimits, filepart, 3 );
* UErrorCode success = U_ZERO_ERROR;
* const Format* testFormats[] = { fileform, NULL, NumberFormat::createInstance(success) };
* MessageFormat* pattform = new MessageFormat("There {0} on {1}", success );
* pattform->setFormats( testFormats, 3 );
* Formattable testArgs[] = {0L, "Disk_A", 0L};
* FieldPosition fp(0);
* UnicodeString str;
* for (int32_t i = 0; i &lt; 4; ++i) {
* Formattable fInt(i);
* testArgs[0] = fInt;
* testArgs[2] = testArgs[0];
* str.remove();
* pattform->format(testArgs, 3, str, fp, success );
* cout &lt;&lt; "Output for i=" &lt;&lt; i &lt;&lt; " : " &lt;&lt; str &lt;&lt; endl;
* }
* delete pattform;
* cout &lt;&lt; endl;
* }
* \endcode
* </pre>
* ChoiceFormat objects may be converted to and from patterns. The
* syntax of these patterns is [TODO fill in this section with detail].
@ -106,13 +114,17 @@
* You can either do this programmatically, as in the above example,
* or by using a pattern (see ChoiceFormat for more information) as in:
* <pre>
* . "0#are no files|1#is one file|1&lt;are many files"
* \code
* "0#are no files|1#is one file|1&lt;are many files"
* \endcode
* </pre>
* Here the notation is:
* <pre>
* . &lt;number> "#" Specifies a limit value.
* . &lt;number> "&lt;" Specifies a limit of nextDouble(&lt;number>).
* . &lt;number> ">" Specifies a limit of previousDouble(&lt;number>).
* \code
* <number> "#" Specifies a limit value.
* <number> "&lt;" Specifies a limit of nextDouble(&lt;number>).
* <number> ">" Specifies a limit of previousDouble(&lt;number>).
* \endcode
* </pre>
* Each limit value is followed by a string, which is terminated by
* a vertical bar character ("|"), except for the last string, which

View file

@ -45,13 +45,17 @@ typedef void * UCollator;
* collated in the given collation object.
* For example, consider the following in Spanish:
* <pre>
* . "ca" -> the first key is key('c') and second key is key('a').
* . "cha" -> the first key is key('ch') and second key is key('a').
* \code
* "ca" -> the first key is key('c') and second key is key('a').
* "cha" -> the first key is key('ch') and second key is key('a').
* \endcode
* </pre>
* And in German,
* <pre>
* . "æb"-> the first key is key('a'), the second key is key('e'), and
* . the third key is key('b').
* \code
* "æb"-> the first key is key('a'), the second key is key('e'), and
* the third key is key('b').
* \endcode
* </pre>
* The key of a character, is an integer composed of primary order(short),
* secondary order(char), and tertiary order(char). Java strictly defines
@ -60,19 +64,21 @@ typedef void * UCollator;
* to ensure the correctness of the key value.
* <p>Example of the iterator usage: (without error checking)
* <pre>
* . void CollationElementIterator_Example()
* . {
* . UnicodeString str = "This is a test";
* . UErrorCode success = U_ZERO_ERROR;
* . RuleBasedCollator* rbc =
* . (RuleBasedCollator*) RuleBasedCollator::createInstance(success);
* . CollationElementIterator* c =
* . rbc->createCollationElementIterator( str );
* . int32_t order = c->next(success);
* . int32_t primaryOrder = CollationElementIterator::primaryOrder( order );
* . delete c;
* . delete rbc;
* . }
* \code
* void CollationElementIterator_Example()
* {
* UnicodeString str = "This is a test";
* UErrorCode success = U_ZERO_ERROR;
* RuleBasedCollator* rbc =
* (RuleBasedCollator*) RuleBasedCollator::createInstance(success);
* CollationElementIterator* c =
* rbc->createCollationElementIterator( str );
* int32_t order = c->next(success);
* int32_t primaryOrder = CollationElementIterator::primaryOrder( order );
* delete c;
* delete rbc;
* }
* \endcode
* </pre>
* <p>
* CollationElementIterator::next returns the collation order of the next

View file

@ -79,6 +79,7 @@ class CollationKey;
* the <code>Collator</code> for the default locale.
* <blockquote>
* <pre>
* \code
* // Compare two strings in the default locale
* UErrorCode success = U_ZERO_ERROR;
* Collator* myCollator = Collator::createInstance(success);
@ -87,6 +88,7 @@ class CollationKey;
* }else{
* cout &lt;&lt; "abc is greater than or equal to ABC" &lt;&lt; endl;
* }
* \endcode
* </pre>
* </blockquote>
*
@ -103,6 +105,7 @@ class CollationKey;
* US English.
* <blockquote>
* <pre>
* \code
* //Get the Collator for US English and set its strength to PRIMARY
* UErrorCode success = U_ZERO_ERROR;
* Collator* usCollator = Collator::createInstance(Locale::US, success);
@ -110,6 +113,7 @@ class CollationKey;
* if( usCollator->compare("abc", "ABC") == 0 ) {
* cout &lt;&lt; "'abc' and 'ABC' strings are equivalent with strength PRIMARY" &lt;&lt; endl;
* }
* \endcode
* </pre>
* </blockquote>
* <p>

View file

@ -42,32 +42,40 @@ class TimeZone;
* To format a date for the current Locale, use one of the static factory
* methods:
* <pre>
* . DateFormat* dfmt = DateFormat::createDateInstance();
* . UnicodeString myString;
* . myString = dfmt->format( myDate, myString );
* \code
* DateFormat* dfmt = DateFormat::createDateInstance();
* UnicodeString myString;
* myString = dfmt->format( myDate, myString );
* \endcode
* </pre>
* If you are formatting multiple numbers, it is more efficient to get the
* format and use it multiple times so that the system doesn't have to fetch the
* information about the local language and country conventions multiple times.
* <pre>
* . DateFormat* df = DateFormat::createDateInstance();
* . UnicodeString myString;
* . UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values
* . for (int32_t i = 0; i < 3; ++i) {
* . myString.remove();
* . cout &lt;&lt; df->format( myDateArr[i], myString ) &lt;&lt; endl;
* . }
* \code
* DateFormat* df = DateFormat::createDateInstance();
* UnicodeString myString;
* UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values
* for (int32_t i = 0; i < 3; ++i) {
* myString.remove();
* cout &lt;&lt; df->format( myDateArr[i], myString ) &lt;&lt; endl;
* }
* \endcode
* </pre>
* To format a date for a different Locale, specify it in the call to
* getDateInstance().
* <pre>
* . DateFormat* df =
* . DateFormat::createDateInstance( DateFormat::SHORT, Locale::FRANCE);
* \code
* DateFormat* df =
* DateFormat::createDateInstance( DateFormat::SHORT, Locale::FRANCE);
* \endcode
* </pre>
* You can use a DateFormat to parse also.
* <pre>
* . UErrorCode status = U_ZERO_ERROR;
* . UDate myDate = df->parse(myString, status);
* \code
* UErrorCode status = U_ZERO_ERROR;
* UDate myDate = df->parse(myString, status);
* \endcode
* </pre>
* Use createDateInstance() to produce the normal date format for that country.
* There are other static factory methods available. Use createTimeInstance()

View file

@ -38,16 +38,18 @@
* Here are the special characters used in the parts of the
* subpattern, with notes on their usage.
* <pre>
* . Symbol Meaning
* . 0 a digit
* . # a digit, zero shows as absent
* . . placeholder for decimal separator
* . , placeholder for grouping separator.
* . ; separates formats.
* . - default negative prefix.
* . % divide by 100 and show as percentage
* . X any other characters can be used in the prefix or suffix
* . ' used to quote special characters in a prefix or suffix.
* \code
* Symbol Meaning
* 0 a digit
* # a digit, zero shows as absent
* . placeholder for decimal separator
* , placeholder for grouping separator.
* ; separates formats.
* - default negative prefix.
* % divide by 100 and show as percentage
* X any other characters can be used in the prefix or suffix
* ' used to quote special characters in a prefix or suffix.
* \endcode
* </pre>
* [Notes]
* <P>

View file

@ -56,65 +56,69 @@ class DigitList;
* <P>
* [Example:]
* <pre>
* . // normally we would have a GUI with a menu for this
* . int32_t locCount;
* . const Locale* locales = NumberFormat::getAvailableLocales(locCount);
* . if (locCount > 12) locCount = 12; //limit output
* .
* . double myNumber = -1234.56;
* . UErrorCode success = U_ZERO_ERROR;
* . NumberFormat* form; //= NumberFormat::createInstance(success);
* .
* . // just for fun, we print out a number with the locale number, currency
* . // and percent format for each locale we can.
* . UnicodeString countryName;
* . UnicodeString displayName;
* . UnicodeString str;
* . UnicodeString pattern;
* . Formattable fmtable;
* . for (int32_t j = 0; j < 3; ++j) {
* . cout << endl << "FORMAT " << j << endl;
* . for (int32_t i = 0; i < locCount; ++i) {
* . if (locales[i].getCountry(countryName).size() == 0) {
* . // skip language-only
* . continue;
* . }
* . switch (j) {
* . default:
* . form = NumberFormat::createInstance(locales[i], success ); break;
* . case 1:
* . form = NumberFormat::createCurrencyInstance(locales[i], success ); break;
* . case 0:
* . form = NumberFormat::createPercentInstance(locales[i], success ); break;
* . }
* . if (form) {
* . str.remove();
* . pattern = ((DecimalFormat*)form)->toPattern(pattern);
* . cout << locales[i].getDisplayName(displayName) << ": " << pattern;
* . cout << " -> " << form->format(myNumber,str) << endl;
* . form->parse(form->format(myNumber,str), fmtable, success);
* . //cout << " parsed: " << fmtable << endl;
* . delete form;
* . }
* . }
* . }
* \code
* // normally we would have a GUI with a menu for this
* int32_t locCount;
* const Locale* locales = NumberFormat::getAvailableLocales(locCount);
* if (locCount > 12) locCount = 12; //limit output
*
* double myNumber = -1234.56;
* UErrorCode success = U_ZERO_ERROR;
* NumberFormat* form; //= NumberFormat::createInstance(success);
*
* // just for fun, we print out a number with the locale number, currency
* // and percent format for each locale we can.
* UnicodeString countryName;
* UnicodeString displayName;
* UnicodeString str;
* UnicodeString pattern;
* Formattable fmtable;
* for (int32_t j = 0; j < 3; ++j) {
* cout << endl << "FORMAT " << j << endl;
* for (int32_t i = 0; i < locCount; ++i) {
* if (locales[i].getCountry(countryName).size() == 0) {
* // skip language-only
* continue;
* }
* switch (j) {
* default:
* form = NumberFormat::createInstance(locales[i], success ); break;
* case 1:
* form = NumberFormat::createCurrencyInstance(locales[i], success ); break;
* case 0:
* form = NumberFormat::createPercentInstance(locales[i], success ); break;
* }
* if (form) {
* str.remove();
* pattern = ((DecimalFormat*)form)->toPattern(pattern);
* cout << locales[i].getDisplayName(displayName) << ": " << pattern;
* cout << " -> " << form->format(myNumber,str) << endl;
* form->parse(form->format(myNumber,str), fmtable, success);
* //cout << " parsed: " << fmtable << endl;
* delete form;
* }
* }
* }
* \endcode
* </pre>
* [The following shows the structure of the pattern.]
* <pre>
* . pattern := subpattern{;subpattern}
* . subpattern := {prefix}integer{.fraction}{suffix}
* .
* . prefix := '\\u0000'..'\\uFFFD' - specialCharacters
* . suffix := '\\u0000'..'\\uFFFD' - specialCharacters
* . integer := '#'* '0'* '0'
* . fraction := '0'* '#'*
*
* \code
* pattern := subpattern{;subpattern}
* subpattern := {prefix}integer{.fraction}{suffix}
*
* prefix := '\\u0000'..'\\uFFFD' - specialCharacters
* suffix := '\\u0000'..'\\uFFFD' - specialCharacters
* integer := '#'* '0'* '0'
* fraction := '0'* '#'*
*
* Notation:
* . X* 0 or more instances of X
* . (X | Y) either X or Y.
* . X..Y any character from X up to Y, inclusive.
* . S - T characters in S, except those in T
* </pre>
* X* 0 or more instances of X
* (X | Y) either X or Y.
* X..Y any character from X up to Y, inclusive.
* S - T characters in S, except those in T
* \code
* /pre>
* The first subpattern is for positive numbers. The second (optional)
* subpattern is used for negative numbers. (In both cases, ',' can
* occur inside the integer portion--it is just too messy to indicate
@ -124,22 +128,24 @@ class DigitList;
* Here are the special characters used in the parts of the
* subpattern, with notes on their usage.
* <pre>
* . Symbol Meaning
* . 0 a digit, showing up a zero if it is zero
* . # a digit, supressed if zero
* . . placeholder for decimal separator
* . , placeholder for grouping separator.
* . E separates mantissa and exponent for exponential formats.
* . ; separates formats.
* . - default negative prefix.
* . % multiply by 100 and show as percentage
* . \u2030 multiply by 1000 and show as per mille
* . \u00A4 currency sign; replaced by currency symbol; if
* . doubled, replaced by international currency symbol.
* . If present in a pattern, the monetary decimal separator
* . is used instead of the decimal separator.
* . X any other characters can be used in the prefix or suffix
* . ' used to quote special characters in a prefix or suffix.
* \code
* Symbol Meaning
* 0 a digit, showing up a zero if it is zero
* # a digit, supressed if zero
* . placeholder for decimal separator
* , placeholder for grouping separator.
* E separates mantissa and exponent for exponential formats.
* ; separates formats.
* - default negative prefix.
* % multiply by 100 and show as percentage
* \u2030 multiply by 1000 and show as per mille
* \u00A4 currency sign; replaced by currency symbol; if
* doubled, replaced by international currency symbol.
* If present in a pattern, the monetary decimal separator
* is used instead of the decimal separator.
* X any other characters can be used in the prefix or suffix
* ' used to quote special characters in a prefix or suffix.
* \endcode
* </pre>
* [Notes]
* <P>

View file

@ -49,40 +49,44 @@
* alignment of an array of formatted floating-point numbers on
* their decimal points:
* <pre>
* . double doubleNum[] = {123456789.0, -12345678.9, 1234567.89, -123456.789,
* . 12345.6789, -1234.56789, 123.456789, -12.3456789, 1.23456789};
* . int dNumSize = (int)(sizeof(doubleNum)/sizeof(double));
* .
* . UErrorCode status = U_ZERO_ERROR;
* . DecimalFormat* fmt = (DecimalFormat*) NumberFormat::createInstance(status);
* . fmt->setDecimalSeparatorAlwaysShown(true);
* .
* . const int tempLen = 20;
* . char temp[tempLen];
* .
* . for (int i=0; i&lt;dNumSize; i++) {
* . FieldPosition pos(NumberFormat::INTEGER_FIELD);
* . UnicodeString buf;
* . char fmtText[tempLen];
* . ToCharString(fmt->format(doubleNum[i], buf, pos), fmtText);
* . for (int j=0; j&lt;tempLen; j++) temp[j] = ' '; // clear with spaces
* . temp[__min(tempLen, tempLen-pos.getEndIndex())] = '\0';
* . cout &lt;&lt; temp &lt;&lt; fmtText &lt;&lt; endl;
* . }
* . delete fmt;
* \code
* double doubleNum[] = {123456789.0, -12345678.9, 1234567.89, -123456.789,
* 12345.6789, -1234.56789, 123.456789, -12.3456789, 1.23456789};
* int dNumSize = (int)(sizeof(doubleNum)/sizeof(double));
*
* UErrorCode status = U_ZERO_ERROR;
* DecimalFormat* fmt = (DecimalFormat*) NumberFormat::createInstance(status);
* fmt->setDecimalSeparatorAlwaysShown(true);
*
* const int tempLen = 20;
* char temp[tempLen];
*
* for (int i=0; i&lt;dNumSize; i++) {
* FieldPosition pos(NumberFormat::INTEGER_FIELD);
* UnicodeString buf;
* char fmtText[tempLen];
* ToCharString(fmt->format(doubleNum[i], buf, pos), fmtText);
* for (int j=0; j&lt;tempLen; j++) temp[j] = ' '; // clear with spaces
* temp[__min(tempLen, tempLen-pos.getEndIndex())] = '\0';
* cout &lt;&lt; temp &lt;&lt; fmtText &lt;&lt; endl;
* }
* delete fmt;
* \endcode
* </pre>
* <p>
* The code will generate the following output:
* <pre>
* . 123,456,789.000
* . -12,345,678.900
* . 1,234,567.880
* . -123,456.789
* . 12,345.678
* . -1,234.567
* . 123.456
* . -12.345
* . 1.234
* \code
* 123,456,789.000
* -12,345,678.900
* 1,234,567.880
* -123,456.789
* 12,345.678
* -1,234.567
* 123.456
* -12.345
* 1.234
* \endcode
* </pre>
*/
class U_I18N_API FieldPosition {

View file

@ -76,7 +76,9 @@
* [Subclassing.] All base classes that provide static functions that
* create objects for Locales must implement the following static:
* <pre>
* . public static const Locale* getAvailableLocales(long&)
* \code
* public static const Locale* getAvailableLocales(long&)
* \endcode
* </pre>
*/
class U_I18N_API Format {

View file

@ -59,74 +59,75 @@
*
* <p>Example for using GregorianCalendar:
* <pre>
* . // get the supported ids for GMT-08:00 (Pacific Standard Time)
* . int32_t idsCount;
* . const UnicodeString** ids = TimeZone::createAvailableIDs(-8 * 60 * 60 * 1000, idsCount);
* . // if no ids were returned, something is wrong. get out.
* . if (idsCount == 0) {
* . return;
* . }
* .
* . // begin output
* . cout << "Current Time" << endl;
* .
* . // create a Pacific Standard Time time zone
* . SimpleTimeZone* pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, *(ids[0]));
* .
* . // set up rules for daylight savings time
* . pdt->setStartRule(Calendar::APRIL, 1, Calendar::SUNDAY, 2 * 60 * 60 * 1000);
* . pdt->setEndRule(Calendar::OCTOBER, -1, Calendar::SUNDAY, 2 * 60 * 60 * 1000);
* .
* . // create a GregorianCalendar with the Pacific Daylight time zone
* . // and the current date and time
* . UErrorCode success = U_ZERO_ERROR;
* . Calendar* calendar = new GregorianCalendar( pdt, success );
* .
* . // print out a bunch of interesting things
* . cout << "ERA: " << calendar->get( Calendar::ERA, success ) << endl;
* . cout << "YEAR: " << calendar->get( Calendar::YEAR, success ) << endl;
* . cout << "MONTH: " << calendar->get( Calendar::MONTH, success ) << endl;
* . cout << "WEEK_OF_YEAR: " << calendar->get( Calendar::WEEK_OF_YEAR, success ) << endl;
* . cout << "WEEK_OF_MONTH: " << calendar->get( Calendar::WEEK_OF_MONTH, success ) << endl;
* . cout << "DATE: " << calendar->get( Calendar::DATE, success ) << endl;
* . cout << "DAY_OF_MONTH: " << calendar->get( Calendar::DAY_OF_MONTH, success ) << endl;
* . cout << "DAY_OF_YEAR: " << calendar->get( Calendar::DAY_OF_YEAR, success ) << endl;
* . cout << "DAY_OF_WEEK: " << calendar->get( Calendar::DAY_OF_WEEK, success ) << endl;
* . cout << "DAY_OF_WEEK_IN_MONTH: " << calendar->get( Calendar::DAY_OF_WEEK_IN_MONTH, success ) << endl;
* . cout << "AM_PM: " << calendar->get( Calendar::AM_PM, success ) << endl;
* . cout << "HOUR: " << calendar->get( Calendar::HOUR, success ) << endl;
* . cout << "HOUR_OF_DAY: " << calendar->get( Calendar::HOUR_OF_DAY, success ) << endl;
* . cout << "MINUTE: " << calendar->get( Calendar::MINUTE, success ) << endl;
* . cout << "SECOND: " << calendar->get( Calendar::SECOND, success ) << endl;
* . cout << "MILLISECOND: " << calendar->get( Calendar::MILLISECOND, success ) << endl;
* . cout << "ZONE_OFFSET: " << (calendar->get( Calendar::ZONE_OFFSET, success )/(60*60*1000)) << endl;
* . cout << "DST_OFFSET: " << (calendar->get( Calendar::DST_OFFSET, success )/(60*60*1000)) << endl;
* .
* . cout << "Current Time, with hour reset to 3" << endl;
* . calendar->clear(Calendar::HOUR_OF_DAY); // so doesn't override
* . calendar->set(Calendar::HOUR, 3);
* . cout << "ERA: " << calendar->get( Calendar::ERA, success ) << endl;
* . cout << "YEAR: " << calendar->get( Calendar::YEAR, success ) << endl;
* . cout << "MONTH: " << calendar->get( Calendar::MONTH, success ) << endl;
* . cout << "WEEK_OF_YEAR: " << calendar->get( Calendar::WEEK_OF_YEAR, success ) << endl;
* . cout << "WEEK_OF_MONTH: " << calendar->get( Calendar::WEEK_OF_MONTH, success ) << endl;
* . cout << "DATE: " << calendar->get( Calendar::DATE, success ) << endl;
* . cout << "DAY_OF_MONTH: " << calendar->get( Calendar::DAY_OF_MONTH, success ) << endl;
* . cout << "DAY_OF_YEAR: " << calendar->get( Calendar::DAY_OF_YEAR, success ) << endl;
* . cout << "DAY_OF_WEEK: " << calendar->get( Calendar::DAY_OF_WEEK, success ) << endl;
* . cout << "DAY_OF_WEEK_IN_MONTH: " << calendar->get( Calendar::DAY_OF_WEEK_IN_MONTH, success ) << endl;
* . cout << "AM_PM: " << calendar->get( Calendar::AM_PM, success ) << endl;
* . cout << "HOUR: " << calendar->get( Calendar::HOUR, success ) << endl;
* . cout << "HOUR_OF_DAY: " << calendar->get( Calendar::HOUR_OF_DAY, success ) << endl;
* . cout << "MINUTE: " << calendar->get( Calendar::MINUTE, success ) << endl;
* . cout << "SECOND: " << calendar->get( Calendar::SECOND, success ) << endl;
* . cout << "MILLISECOND: " << calendar->get( Calendar::MILLISECOND, success ) << endl;
* . cout << "ZONE_OFFSET: " << (calendar->get( Calendar::ZONE_OFFSET, success )/(60*60*1000)) << endl; // in hours
* . cout << "DST_OFFSET: " << (calendar->get( Calendar::DST_OFFSET, success )/(60*60*1000)) << endl; // in hours
* .
* . delete[] ids;
* . delete calendar; // also deletes pdt
* .
* \code
* // get the supported ids for GMT-08:00 (Pacific Standard Time)
* int32_t idsCount;
* const UnicodeString** ids = TimeZone::createAvailableIDs(-8 * 60 * 60 * 1000, idsCount);
* // if no ids were returned, something is wrong. get out.
* if (idsCount == 0) {
* return;
* }
*
* // begin output
* cout << "Current Time" << endl;
*
* // create a Pacific Standard Time time zone
* SimpleTimeZone* pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, *(ids[0]));
*
* // set up rules for daylight savings time
* pdt->setStartRule(Calendar::APRIL, 1, Calendar::SUNDAY, 2 * 60 * 60 * 1000);
* pdt->setEndRule(Calendar::OCTOBER, -1, Calendar::SUNDAY, 2 * 60 * 60 * 1000);
*
* // create a GregorianCalendar with the Pacific Daylight time zone
* // and the current date and time
* UErrorCode success = U_ZERO_ERROR;
* Calendar* calendar = new GregorianCalendar( pdt, success );
*
* // print out a bunch of interesting things
* cout << "ERA: " << calendar->get( Calendar::ERA, success ) << endl;
* cout << "YEAR: " << calendar->get( Calendar::YEAR, success ) << endl;
* cout << "MONTH: " << calendar->get( Calendar::MONTH, success ) << endl;
* cout << "WEEK_OF_YEAR: " << calendar->get( Calendar::WEEK_OF_YEAR, success ) << endl;
* cout << "WEEK_OF_MONTH: " << calendar->get( Calendar::WEEK_OF_MONTH, success ) << endl;
* cout << "DATE: " << calendar->get( Calendar::DATE, success ) << endl;
* cout << "DAY_OF_MONTH: " << calendar->get( Calendar::DAY_OF_MONTH, success ) << endl;
* cout << "DAY_OF_YEAR: " << calendar->get( Calendar::DAY_OF_YEAR, success ) << endl;
* cout << "DAY_OF_WEEK: " << calendar->get( Calendar::DAY_OF_WEEK, success ) << endl;
* cout << "DAY_OF_WEEK_IN_MONTH: " << calendar->get( Calendar::DAY_OF_WEEK_IN_MONTH, success ) << endl;
* cout << "AM_PM: " << calendar->get( Calendar::AM_PM, success ) << endl;
* cout << "HOUR: " << calendar->get( Calendar::HOUR, success ) << endl;
* cout << "HOUR_OF_DAY: " << calendar->get( Calendar::HOUR_OF_DAY, success ) << endl;
* cout << "MINUTE: " << calendar->get( Calendar::MINUTE, success ) << endl;
* cout << "SECOND: " << calendar->get( Calendar::SECOND, success ) << endl;
* cout << "MILLISECOND: " << calendar->get( Calendar::MILLISECOND, success ) << endl;
* cout << "ZONE_OFFSET: " << (calendar->get( Calendar::ZONE_OFFSET, success )/(60*60*1000)) << endl;
* cout << "DST_OFFSET: " << (calendar->get( Calendar::DST_OFFSET, success )/(60*60*1000)) << endl;
*
* cout << "Current Time, with hour reset to 3" << endl;
* calendar->clear(Calendar::HOUR_OF_DAY); // so doesn't override
* calendar->set(Calendar::HOUR, 3);
* cout << "ERA: " << calendar->get( Calendar::ERA, success ) << endl;
* cout << "YEAR: " << calendar->get( Calendar::YEAR, success ) << endl;
* cout << "MONTH: " << calendar->get( Calendar::MONTH, success ) << endl;
* cout << "WEEK_OF_YEAR: " << calendar->get( Calendar::WEEK_OF_YEAR, success ) << endl;
* cout << "WEEK_OF_MONTH: " << calendar->get( Calendar::WEEK_OF_MONTH, success ) << endl;
* cout << "DATE: " << calendar->get( Calendar::DATE, success ) << endl;
* cout << "DAY_OF_MONTH: " << calendar->get( Calendar::DAY_OF_MONTH, success ) << endl;
* cout << "DAY_OF_YEAR: " << calendar->get( Calendar::DAY_OF_YEAR, success ) << endl;
* cout << "DAY_OF_WEEK: " << calendar->get( Calendar::DAY_OF_WEEK, success ) << endl;
* cout << "DAY_OF_WEEK_IN_MONTH: " << calendar->get( Calendar::DAY_OF_WEEK_IN_MONTH, success ) << endl;
* cout << "AM_PM: " << calendar->get( Calendar::AM_PM, success ) << endl;
* cout << "HOUR: " << calendar->get( Calendar::HOUR, success ) << endl;
* cout << "HOUR_OF_DAY: " << calendar->get( Calendar::HOUR_OF_DAY, success ) << endl;
* cout << "MINUTE: " << calendar->get( Calendar::MINUTE, success ) << endl;
* cout << "SECOND: " << calendar->get( Calendar::SECOND, success ) << endl;
* cout << "MILLISECOND: " << calendar->get( Calendar::MILLISECOND, success ) << endl;
* cout << "ZONE_OFFSET: " << (calendar->get( Calendar::ZONE_OFFSET, success )/(60*60*1000)) << endl; // in hours
* cout << "DST_OFFSET: " << (calendar->get( Calendar::DST_OFFSET, success )/(60*60*1000)) << endl; // in hours
*
* delete[] ids;
* delete calendar; // also deletes pdt
* \endcode
* </pre>
*/
class U_I18N_API GregorianCalendar: public Calendar {

View file

@ -34,74 +34,82 @@ class NumberFormat;
* Here are some examples of usage:
* Example 1:
* <pre>
* . UErrorCode success = U_ZERO_ERROR;
* . GregorianCalendar cal(success);
* . Formattable arguments[] = {
* . 7L,
* . Formattable( (Date) cal.getTime(success), Formattable::kIsDate),
* . "a disturbance in the Force"
* . };
* .
* . UnicodeString result;
* . MessageFormat::format(
* . "At {1,time} on {1,date}, there was {2} on planet {0,number}.",
* . arguments, 3, result, success );
* .
* . cout &lt;&lt; "result: " &lt;&lt; result &lt;&lt; endl;
* . //&lt;output>: At 4:34:20 PM on 23-Mar-98, there was a disturbance
* . // in the Force on planet 7.
* \code
* UErrorCode success = U_ZERO_ERROR;
* GregorianCalendar cal(success);
* Formattable arguments[] = {
* 7L,
* Formattable( (Date) cal.getTime(success), Formattable::kIsDate),
* "a disturbance in the Force"
* };
*
* UnicodeString result;
* MessageFormat::format(
* "At {1,time} on {1,date}, there was {2} on planet {0,number}.",
* arguments, 3, result, success );
*
* cout &lt;&lt; "result: " &lt;&lt; result &lt;&lt; endl;
* //&lt;output>: At 4:34:20 PM on 23-Mar-98, there was a disturbance
* // in the Force on planet 7.
* \endcode
* </pre>
* Typically, the message format will come from resources, and the
* arguments will be dynamically set at runtime.
* <P>
* Example 2:
* <pre>
* . success = U_ZERO_ERROR;
* . Formattable testArgs[] = {3L, "MyDisk"};
* .
* . MessageFormat* form = new MessageFormat(
* . "The disk \"{1}\" contains {0} file(s).", success );
* .
* . UnicodeString string;
* . FieldPosition fpos = 0;
* . cout &lt;&lt; "format: " &lt;&lt; form->format(testArgs, 2, string, fpos, success ) &lt;&lt; endl;
* .
* . // output, with different testArgs:
* . // output: The disk "MyDisk" contains 0 file(s).
* . // output: The disk "MyDisk" contains 1 file(s).
* . // output: The disk "MyDisk" contains 1,273 file(s).
* . de lete form;
* \code
* success = U_ZERO_ERROR;
* Formattable testArgs[] = {3L, "MyDisk"};
*
* MessageFormat* form = new MessageFormat(
* "The disk \"{1}\" contains {0} file(s).", success );
*
* UnicodeString string;
* FieldPosition fpos = 0;
* cout &lt;&lt; "format: " &lt;&lt; form->format(testArgs, 2, string, fpos, success ) &lt;&lt; endl;
*
* // output, with different testArgs:
* // output: The disk "MyDisk" contains 0 file(s).
* // output: The disk "MyDisk" contains 1 file(s).
* // output: The disk "MyDisk" contains 1,273 file(s).
* delete form;
* \endcode
* </pre>
*
* The pattern is of the following form. Legend:
* <pre>
* . {optional item}
* . (group that may be repeated)*
* \code
* {optional item}
* (group that may be repeated)*
* \endcode
* </pre>
* Do not confuse optional items with items inside quotes braces, such
* as this: "{". Quoted braces are literals.
* <pre>
* . messageFormatPattern := string ( "{" messageFormatElement "}" string )*
* .
* . messageFormatElement := argument { "," elementFormat }
* .
* . elementFormat := "time" { "," datetimeStyle }
* . | "date" { "," datetimeStyle }
* . | "number" { "," numberStyle }
* . | "choice" "," choiceStyle
* .
* . datetimeStyle := "short"
* . | "medium"
* . | "long"
* . | "full"
* . | dateFormatPattern
* .
* . numberStyle := "currency"
* . | "percent"
* . | "integer"
* . | numberFormatPattern
* .
* . choiceStyle := choiceFormatPattern
* \code
* messageFormatPattern := string ( "{" messageFormatElement "}" string )*
*
* messageFormatElement := argument { "," elementFormat }
*
* elementFormat := "time" { "," datetimeStyle }
* | "date" { "," datetimeStyle }
* | "number" { "," numberStyle }
* | "choice" "," choiceStyle
*
* datetimeStyle := "short"
* | "medium"
* | "long"
* | "full"
* | dateFormatPattern
*
* numberStyle := "currency"
* | "percent"
* | "integer"
* | numberFormatPattern
*
* choiceStyle := choiceFormatPattern
* \endcode
* </pre>
* If there is no elementFormat, then the argument must be a string,
* which is substituted. If there is no dateTimeStyle or numberStyle,
@ -130,29 +138,33 @@ class NumberFormat;
* For more sophisticated patterns, you can use a ChoiceFormat to get
* output such as:
* <pre>
* . UErrorCode success = U_ZERO_ERROR;
* . MessageFormat* form = new MessageFormat("The disk \"{1}\" contains {0}.", success);
* . double filelimits[] = {0,1,2};
* . UnicodeString filepart[] = {"no files","one file","{0,number} files"};
* . ChoiceFormat* fileform = new ChoiceFormat(filelimits, filepart, 3);
* . form->setFormat(1, *fileform); // NOT zero, see below
* .
* . Formattable testArgs[] = {1273L, "MyDisk"};
* .
* . UnicodeString string;
* . FieldPosition fpos = 0;
* . cout &lt;&lt; form->format(testArgs, 2, string, fpos, success) &lt;&lt; endl;
* .
* . // output, with different testArgs
* . // output: The disk "MyDisk" contains no files.
* . // output: The disk "MyDisk" contains one file.
* . // output: The disk "MyDisk" contains 1,273 files.
* \code
* UErrorCode success = U_ZERO_ERROR;
* MessageFormat* form = new MessageFormat("The disk \"{1}\" contains {0}.", success);
* double filelimits[] = {0,1,2};
* UnicodeString filepart[] = {"no files","one file","{0,number} files"};
* ChoiceFormat* fileform = new ChoiceFormat(filelimits, filepart, 3);
* form->setFormat(1, *fileform); // NOT zero, see below
*
* Formattable testArgs[] = {1273L, "MyDisk"};
*
* UnicodeString string;
* FieldPosition fpos = 0;
* cout &lt;&lt; form->format(testArgs, 2, string, fpos, success) &lt;&lt; endl;
*
* // output, with different testArgs
* // output: The disk "MyDisk" contains no files.
* // output: The disk "MyDisk" contains one file.
* // output: The disk "MyDisk" contains 1,273 files.
* \endcode
* </pre>
* You can either do this programmatically, as in the above example,
* or by using a pattern (see ChoiceFormat for more information) as in:
* <pre>
* . form->applyPattern(
* . "There {0,choice,0#are no files|1#is one file|1&lt;are {0,number,integer} files}.");
* \code
* form->applyPattern(
* "There {0,choice,0#are no files|1#is one file|1&lt;are {0,number,integer} files}.");
* \endcode
* </pre>
* <P>
* [Note:] As we see above, the string produced by a ChoiceFormat in
@ -165,11 +177,13 @@ class NumberFormat;
* [Note:] Formats are numbered by order of variable in the string.
* This is [not] the same as the argument numbering!
* <pre>
* . For example: with "abc{2}def{3}ghi{0}...",
* .
* . format0 affects the first variable {2}
* . format1 affects the second variable {3}
* . format2 affects the second variable {0}
* \code
* For example: with "abc{2}def{3}ghi{0}...",
*
* format0 affects the first variable {2}
* format1 affects the second variable {3}
* format2 affects the second variable {0}
* \endcode
* </pre>
* and so on.
*/

View file

@ -40,40 +40,48 @@ class Locale;
* To format a number for the current Locale, use one of the static
* factory methods:
* <pre>
* . double myNumber = 7.0;
* . UnicodeString myString;
* . UErrorCode success = U_ZERO_ERROR;
* . NumberFormat* nf = NumberFormat::createInstance(success)
* . nf->format(myNumber, myString);
* . cout &lt;&lt; " Example 1: " &lt;&lt; myString &lt;&lt; endl;
* \code
* double myNumber = 7.0;
* UnicodeString myString;
* UErrorCode success = U_ZERO_ERROR;
* NumberFormat* nf = NumberFormat::createInstance(success)
* nf->format(myNumber, myString);
* cout &lt;&lt; " Example 1: " &lt;&lt; myString &lt;&lt; endl;
* \endcode
* </pre>
* If you are formatting multiple numbers, it is more efficient to get
* the format and use it multiple times so that the system doesn't
* have to fetch the information about the local language and country
* conventions multiple times.
* <pre>
* . UnicodeString myString;
* . UErrorCode success = U_ZERO_ERROR;
* . nf = NumberFormat::createInstance( success );
* . int32_t a[] = { 123, 3333, -1234567 };
* . const int32_t a_len = sizeof(a) / sizeof(a[0]);
* . myString.remove();
* . for (int32_t i = 0; i < a_len; i++) {
* . nf->format(a[i], myString);
* . myString += " ; ";
* . }
* . cout &lt;&lt; " Example 2: " &lt;&lt; myString &lt;&lt; endl;
* \code
* UnicodeString myString;
* UErrorCode success = U_ZERO_ERROR;
* nf = NumberFormat::createInstance( success );
* int32_t a[] = { 123, 3333, -1234567 };
* const int32_t a_len = sizeof(a) / sizeof(a[0]);
* myString.remove();
* for (int32_t i = 0; i < a_len; i++) {
* nf->format(a[i], myString);
* myString += " ; ";
* }
* cout &lt;&lt; " Example 2: " &lt;&lt; myString &lt;&lt; endl;
* \endcide
* </pre>
* To format a number for a different Locale, specify it in the
* call to createInstance().
* <pre>
* . nf = NumberFormat::createInstance( Locale::FRENCH, success );
* \code
* nf = NumberFormat::createInstance( Locale::FRENCH, success );
* \endcode
* </pre>
* You can use a NumberFormat to parse also.
* <pre>
* . UErrorCode success;
* . Formattable result(-999); // initialized with error code
* . nf->parse(myString, result, success);
* \code
* UErrorCode success;
* Formattable result(-999); // initialized with error code
* nf->parse(myString, result, success);
* \endcode
* </pre>
* Use createInstance to get the normal number format for that country.
* There are other static factory methods available. Use getCurrency

View file

@ -49,30 +49,32 @@ class DateFormat;
* pattern, all ASCII letters are reserved as pattern letters, which are defined
* as the following:
* <pre>
* . Symbol Meaning Presentation Example
* . ------ ------- ------------ -------
* . G era designator (Text) AD
* . y year (Number) 1996
* . Y year/week of year (Number) 1996
* . M month in year (Text & Number) July & 07
* . d day in month (Number) 10
* . h hour in am/pm (1~12) (Number) 12
* . H hour in day (0~23) (Number) 0
* . m minute in hour (Number) 30
* . s second in minute (Number) 55
* . S millisecond (Number) 978
* . E day of week (Text) Tuesday
* . e day of week/local (1~7) (Number) 2
* . D day of year (Number) 189
* . F day of week in month (Number) 2 (2nd Wed in July)
* . w week in year (Number) 27
* . W week in month (Number) 2
* . a am/pm marker (Text) PM
* . k hour in day (1~24) (Number) 24
* . K hour in am/pm (0~11) (Number) 0
* . z time zone (Text) Pacific Standard Time
* . ' escape for text
* . '' single quote '
* \code
* Symbol Meaning Presentation Example
* ------ ------- ------------ -------
* G era designator (Text) AD
* y year (Number) 1996
* Y year/week of year (Number) 1996
* M month in year (Text & Number) July & 07
* d day in month (Number) 10
* h hour in am/pm (1~12) (Number) 12
* H hour in day (0~23) (Number) 0
* m minute in hour (Number) 30
* s second in minute (Number) 55
* S millisecond (Number) 978
* E day of week (Text) Tuesday
* e day of week/local (1~7) (Number) 2
* D day of year (Number) 189
* F day of week in month (Number) 2 (2nd Wed in July)
* w week in year (Number) 27
* W week in month (Number) 2
* a am/pm marker (Text) PM
* k hour in day (1~24) (Number) 24
* K hour in am/pm (0~11) (Number) 0
* z time zone (Text) Pacific Standard Time
* ' escape for text
* '' single quote '
* \endcode
* </pre>
* The count of pattern letters determine the format.
* <P>
@ -97,35 +99,39 @@ class DateFormat;
* <P>
* Examples using the US locale:
* <pre>
* . Format Pattern Result
* . -------------- -------
* . "yyyy.MM.dd G 'at' HH:mm:ss z" ->> 1996.07.10 AD at 15:08:56 PDT
* . "EEE, MMM d, ''yy" ->> Wed, July 10, '96
* . "h:mm a" ->> 12:08 PM
* . "hh 'o''clock' a, zzzz" ->> 12 o'clock PM, Pacific Daylight Time
* . "K:mm a, z" ->> 0:00 PM, PST
* . "yyyyy.MMMMM.dd GGG hh:mm aaa" ->> 1996.July.10 AD 12:08 PM
* \code
* Format Pattern Result
* -------------- -------
* "yyyy.MM.dd G 'at' HH:mm:ss z" ->> 1996.07.10 AD at 15:08:56 PDT
* "EEE, MMM d, ''yy" ->> Wed, July 10, '96
* "h:mm a" ->> 12:08 PM
* "hh 'o''clock' a, zzzz" ->> 12 o'clock PM, Pacific Daylight Time
* "K:mm a, z" ->> 0:00 PM, PST
* "yyyyy.MMMMM.dd GGG hh:mm aaa" ->> 1996.July.10 AD 12:08 PM
* \endcode
* </pre>
* Code Sample:
* <pre>
* . UErrorCode success = U_ZERO_ERROR;
* . SimpleTimeZone* pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, "PST");
* . pdt->setStartRule( Calendar::APRIL, 1, Calendar::SUNDAY, 2*60*60*1000);
* . pdt->setEndRule( Calendar::OCTOBER, -1, Calendar::SUNDAY, 2*60*60*1000);
* .
* . // Format the current time.
* . SimpleDateFormat* formatter
* . = new SimpleDateFormat ("yyyy.MM.dd G 'at' hh:mm:ss a zzz", success );
* . GregorianCalendar cal(success);
* . UDate currentTime_1 = cal.getTime(success);
* . FieldPosition fp(0);
* . UnicodeString dateString;
* . formatter->format( currentTime_1, dateString, fp );
* . cout &lt;&lt; "result: " &lt;&lt; dateString &lt;&lt; endl;
* .
* . // Parse the previous string back into a Date.
* . ParsePosition pp(0);
* . UDate currentTime_2 = formatter->parse(dateString, pp );
* \code
* UErrorCode success = U_ZERO_ERROR;
* SimpleTimeZone* pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, "PST");
* pdt->setStartRule( Calendar::APRIL, 1, Calendar::SUNDAY, 2*60*60*1000);
* pdt->setEndRule( Calendar::OCTOBER, -1, Calendar::SUNDAY, 2*60*60*1000);
*
* // Format the current time.
* SimpleDateFormat* formatter
* = new SimpleDateFormat ("yyyy.MM.dd G 'at' hh:mm:ss a zzz", success );
* GregorianCalendar cal(success);
* UDate currentTime_1 = cal.getTime(success);
* FieldPosition fp(0);
* UnicodeString dateString;
* formatter->format( currentTime_1, dateString, fp );
* cout &lt;&lt; "result: " &lt;&lt; dateString &lt;&lt; endl;
*
* // Parse the previous string back into a Date.
* ParsePosition pp(0);
* UDate currentTime_2 = formatter->parse(dateString, pp );
* \endcode
* </pre>
* In the above example, the time value "currentTime_2" obtained from parsing
* will be equal to currentTime_1. However, they may not be equal if the am/pm

View file

@ -49,19 +49,21 @@ class RuleBasedCollator;
*
* <p>Example of use:
* <pre>
* . UErrorCode success = U_ZERO_ERROR;
* . Collator* myCollator = Collator::createInstance(success);
* . CollationKey* keys = new CollationKey [3];
* . myCollator->getCollationKey("Tom", keys[0], success );
* . myCollator->getCollationKey("Dick", keys[1], success );
* . myCollator->getCollationKey("Harry", keys[2], success );
* .
* . // Inside body of sort routine, compare keys this way:
* . CollationKey tmp;
* . if(keys[0].compareTo( keys[1] ) > 0 ) {
* . tmp = keys[0]; keys[0] = keys[1]; keys[1] = tmp;
* . }
* . //...
* \code
* UErrorCode success = U_ZERO_ERROR;
* Collator* myCollator = Collator::createInstance(success);
* CollationKey* keys = new CollationKey [3];
* myCollator->getCollationKey("Tom", keys[0], success );
* myCollator->getCollationKey("Dick", keys[1], success );
* myCollator->getCollationKey("Harry", keys[2], success );
*
* // Inside body of sort routine, compare keys this way:
* CollationKey tmp;
* if(keys[0].compareTo( keys[1] ) > 0 ) {
* tmp = keys[0]; keys[0] = keys[1]; keys[1] = tmp;
* }
* //...
* \endcode
* </pre>
* <p>Because Collator::compare()'s algorithm is complex, it is faster to sort
* long lists of words by retrieving collation keys with Collator::getCollationKey().

View file

@ -92,9 +92,11 @@ typedef void * UCollator;
* <p>The collation table is composed of a list of collation rules, where each
* rule is of three forms:
* <pre>
* . &lt; modifier >
* . &lt; relation > &lt; text-argument >
* . &lt; reset > &lt; text-argument >
* \code
* <modifier >
* <relation > &lt; text-argument >
* <reset > &lt; text-argument >
* \endcode
* </pre>
* The following demonstrates how to create your own collation rules:
* <UL Type=round>
@ -120,20 +122,25 @@ typedef void * UCollator;
* can also be used to add a modification at the end of a set of rules.
* <p>'&' : Indicates that the next rule follows the position to where
* the reset text-argument would be sorted.
* </UL>
*
* <p>
* This sounds more complicated than it is in practice. For example, the
* following are equivalent ways of expressing the same thing:
* <pre>
* . a &lt; b &lt; c
* . a &lt; b & b &lt; c
* . a &lt; c & a &lt; b
* \code
* a < b < c
* a < b & b < c
* a < c & a < b
* \endcode
* </pre>
* Notice that the order is important, as the subsequent item goes immediately
* after the text-argument. The following are not equivalent:
* <pre>
* . a &lt; b & a &lt; c
* . a &lt; c & a &lt; b
* \code
* a < b & a < c
* a < c & a < b
* \endcode
* </pre>
* Either the text-argument must already be present in the sequence, or some
* initial substring of the text-argument must be present. (e.g. "a &lt; b & ae &lt;
@ -172,142 +179,167 @@ typedef void * UCollator;
* (e.g. "a &lt; b & e &lt; f")
* </UL>
* <pre>
* . Examples:
* . Simple: "&lt; a &lt; b &lt; c &lt; d"
* . Norwegian: "&lt; a,A&lt; b,B&lt; c,C&lt; d,D&lt; e,E&lt; f,F&lt; g,G&lt; h,H&lt; i,I&lt; j,J
* . &lt; k,K&lt; l,L&lt; m,M&lt; n,N&lt; o,O&lt; p,P&lt; q,Q&lt; r,R&lt; s,S&lt; t,T
* . &lt; u,U&lt; v,V&lt; w,W&lt; x,X&lt; y,Y&lt; z,Z
* . &lt; å=a°,Å=A°
* . ;aa,AA&lt; æ,Æ&lt; ø,Ø"
* \code
* Examples:
* Simple: "< a < b < c < d"
* Norwegian: "< a,A< b,B< c,C< d,D< e,E< f,F< g,G< h,H< i,I< j,J
* < k,K< l,L< m,M< n,N< o,O< p,P< q,Q< r,R< s,S< t,T
* < u,U< v,V< w,W< x,X< y,Y< z,Z
* < å=a°,Å=A°
* ;aa,AA< æ,Æ< ø,Ø"
* \endcode
* </pre>
* <p>To create a table-based collation object, simply supply the collation
* rules to the RuleBasedCollator contructor. For example:
* <pre>
* . UErrorCode status = U_ZERO_ERROR;
* . RuleBasedCollator *mySimple = new RuleBasedCollator(Simple, status);
* \code
* UErrorCode status = U_ZERO_ERROR;
* RuleBasedCollator *mySimple = new RuleBasedCollator(Simple, status);
* \endcode
* </pre>
* <p>Another example:
* <pre>
* . UErrorCode status = U_ZERO_ERROR;
* . RuleBasedCollator *myNorwegian = new RuleBasedCollator(Norwegian, status);
* \code
* UErrorCode status = U_ZERO_ERROR;
* RuleBasedCollator *myNorwegian = new RuleBasedCollator(Norwegian, status);
* \endcode
* </pre>
* To add rules on top of an existing table, simply supply the orginal rules
* and modifications to RuleBasedCollator constructor. For example,
* <pre>
* . Traditional Spanish (fragment): ... & C &lt; ch , cH , Ch , CH ...
* . German (fragment) : ...&lt; y , Y &lt; z , Z
* . & AE, Ä & AE, ä
* . & OE , Ö & OE, ö
* . & UE , Ü & UE, ü
* . Symbols (fragment): ...&lt; y, Y &lt; z , Z
* . & Question-mark ; '?'
* . & Ampersand ; '&'
* . & Dollar-sign ; '$'
* \code
* Traditional Spanish (fragment): ... & C < ch , cH , Ch , CH ...
* German (fragment) : ...< y , Y < z , Z
* & AE, Ä & AE, ä
* & OE , Ö & OE, ö
* & UE , Ü & UE, ü
* Symbols (fragment): ...< y, Y < z , Z
* & Question-mark ; '?'
* & Ampersand ; '&'
* & Dollar-sign ; '$'
* \endcode
* </pre>
* <p>To create a collation object for traditional Spanish, the user can take
* the English collation rules and add the additional rules to the table.
* For example:
* <pre>
* . UErrorCode status = U_ZERO_ERROR;
* . UnicodeString rules(DEFAULTRULES);
* . rules += "& C &lt; ch, cH, Ch, CH";
* . RuleBasedCollator *mySpanish = new RuleBasedCollator(rules, status);
* \code
* UErrorCode status = U_ZERO_ERROR;
* UnicodeString rules(DEFAULTRULES);
* rules += "& C &lt; ch, cH, Ch, CH";
* RuleBasedCollator *mySpanish = new RuleBasedCollator(rules, status);
* \endcode
* </pre>
* <p>In order to sort symbols in the similiar order of sorting their
* alphabetic equivalents, you can do the following,
* <pre>
* . UErrorCode status = U_ZERO_ERROR;
* . UnicodeString rules(DEFAULTRULES);
* . rules += "& Question-mark ; '?' & Ampersand ; '&' & Dollar-sign ; '$' ";
* . RuleBasedCollator *myTable = new RuleBasedCollator(rules, status);
* \code
* UErrorCode status = U_ZERO_ERROR;
* UnicodeString rules(DEFAULTRULES);
* rules += "& Question-mark ; '?' & Ampersand ; '&' & Dollar-sign ; '$' ";
* RuleBasedCollator *myTable = new RuleBasedCollator(rules, status);
* \endcode
* </pre>
* <p>Another way of creating the table-based collation object, mySimple,
* is:
* <pre>
* . UErrorCode status = U_ZERO_ERROR;
* . RuleBasedCollator *mySimple = new
* . RuleBasedCollator(" &lt; a &lt; b & b &lt; c & c &lt; d", status);
* \code
* UErrorCode status = U_ZERO_ERROR;
* RuleBasedCollator *mySimple = new
* RuleBasedCollator(" &lt; a &lt; b & b &lt; c & c &lt; d", status);
* \endcode
* </pre>
* Or,
* <pre>
* . UErrorCode status = U_ZERO_ERROR;
* . RuleBasedCollator *mySimple = new
* . RuleBasedCollator(" &lt; a &lt; b &lt; d & b &lt; c", status);
* \code
* UErrorCode status = U_ZERO_ERROR;
* RuleBasedCollator *mySimple = new
* RuleBasedCollator(" &lt; a &lt; b &lt; d & b &lt; c", status);
* \endcode
* </pre>
* Because " &lt; a &lt; b &lt; c &lt; d" is the same as "a &lt; b &lt; d & b &lt; c" or
* "&lt; a &lt; b & b &lt; c & c &lt; d".
*
* <p>To combine collations from two locales, (without error handling for clarity)
* <pre>
* . // Create an en_US Collator object
* . Locale locale_en_US("en", "US", "");
* . RuleBasedCollator* en_USCollator = (RuleBasedCollator*)
* . Collator::createInstance( locale_en_US, success );
* .
* . // Create a da_DK Collator object
* . Locale locale_da_DK("da", "DK", "");
* . RuleBasedCollator* da_DKCollator = (RuleBasedCollator*)
* . Collator::createInstance( locale_da_DK, success );
* .
* . // Combine the two
* . // First, get the collation rules from en_USCollator
* . UnicodeString rules = en_USCollator->getRules();
* . // Second, get the collation rules from da_DKCollator
* . rules += da_DKCollator->getRules();
* . RuleBasedCollator* newCollator = new RuleBasedCollator( rules, success );
* . // newCollator has the combined rules
* \code
* // Create an en_US Collator object
* Locale locale_en_US("en", "US", "");
* RuleBasedCollator* en_USCollator = (RuleBasedCollator*)
* Collator::createInstance( locale_en_US, success );
*
* // Create a da_DK Collator object
* Locale locale_da_DK("da", "DK", "");
* RuleBasedCollator* da_DKCollator = (RuleBasedCollator*)
* Collator::createInstance( locale_da_DK, success );
*
* // Combine the two
* // First, get the collation rules from en_USCollator
* UnicodeString rules = en_USCollator->getRules();
* // Second, get the collation rules from da_DKCollator
* rules += da_DKCollator->getRules();
* RuleBasedCollator* newCollator = new RuleBasedCollator( rules, success );
* // newCollator has the combined rules
* \endcode
* </pre>
* <p>Another more interesting example would be to make changes on an existing
* table to create a new collation object. For example, add
* "& C &lt; ch, cH, Ch, CH" to the en_USCollation object to create your own
* English collation object,
* <pre>
* . // Create a new Collator object with additional rules
* . rules = en_USCollator->getRules();
* . rules += "& C < ch, cH, Ch, CH";
* . RuleBasedCollator* myCollator = new RuleBasedCollator( rules, success );
* . // myCollator contains the new rules
* \code
* // Create a new Collator object with additional rules
* rules = en_USCollator->getRules();
* rules += "& C < ch, cH, Ch, CH";
* RuleBasedCollator* myCollator = new RuleBasedCollator( rules, success );
* // myCollator contains the new rules
* \endcode
* </pre>
*
* <p>The following example demonstrates how to change the order of
* non-spacing accents,
* <pre>
* . UChar contents[] = {
* . '=', 0x0301, ';', 0x0300, ';', 0x0302,
* . ';', 0x0308, ';', 0x0327, ',', 0x0303, // main accents
* . ';', 0x0304, ';', 0x0305, ';', 0x0306, // main accents
* . ';', 0x0307, ';', 0x0309, ';', 0x030A, // main accents
* . ';', 0x030B, ';', 0x030C, ';', 0x030D, // main accents
* . ';', 0x030E, ';', 0x030F, ';', 0x0310, // main accents
* . ';', 0x0311, ';', 0x0312, // main accents
* . '&lt;', 'a', ',', 'A', ';', 'a', 'e', ',', 'A', 'E',
* . ';', 0x00e6, ',', 0x00c6, '&lt;', 'b', ',', 'B',
* . '&lt;', 'c', ',', 'C', '&lt;', 'e', ',', 'E', '&',
* . 'C', '&lt;', 'd', ',', 'D', 0 };
* . UnicodeString oldRules(contents);
* . UErrorCode status = U_ZERO_ERROR;
* . // change the order of accent characters
* . UChar addOn[] = { '&', ',', 0x0300, ';', 0x0308, ';', 0x0302, 0 };
* . oldRules += addOn;
* . RuleBasedCollator *myCollation = new RuleBasedCollator(oldRules, status);
* \code
* UChar contents[] = {
* '=', 0x0301, ';', 0x0300, ';', 0x0302,
* ';', 0x0308, ';', 0x0327, ',', 0x0303, // main accents
* ';', 0x0304, ';', 0x0305, ';', 0x0306, // main accents
* ';', 0x0307, ';', 0x0309, ';', 0x030A, // main accents
* ';', 0x030B, ';', 0x030C, ';', 0x030D, // main accents
* ';', 0x030E, ';', 0x030F, ';', 0x0310, // main accents
* ';', 0x0311, ';', 0x0312, // main accents
* '<', 'a', ',', 'A', ';', 'a', 'e', ',', 'A', 'E',
* ';', 0x00e6, ',', 0x00c6, '<', 'b', ',', 'B',
* '<', 'c', ',', 'C', '<', 'e', ',', 'E', '&',
* 'C', '<', 'd', ',', 'D', 0 };
* UnicodeString oldRules(contents);
* UErrorCode status = U_ZERO_ERROR;
* // change the order of accent characters
* UChar addOn[] = { '&', ',', 0x0300, ';', 0x0308, ';', 0x0302, 0 };
* oldRules += addOn;
* RuleBasedCollator *myCollation = new RuleBasedCollator(oldRules, status);
* \endcode
* </pre>
*
* <p> The last example shows how to put new primary ordering in before the
* default setting. For example, in Japanese collation, you can either sort
* English characters before or after Japanese characters,
* <pre>
* . UErrorCode status = U_ZERO_ERROR;
* . // get en_US collation rules
* . RuleBasedCollator* en_USCollation =
* . (RuleBasedCollator*) Collator::createInstance(Locale::US, status);
* . // Always check the error code after each call.
* . if (U_FAILURE(status)) return;
* . // add a few Japanese character to sort before English characters
* . // suppose the last character before the first base letter 'a' in
* . // the English collation rule is 0x2212
* . UChar jaString[] = { '&', 0x2212, '&lt;', 0x3041, ',', 0x3042, '&lt;', 0x3043, ',', 0x3044, 0 };
* . UnicodeString rules( en_USCollation->getRules() );
* . rules += jaString;
* . RuleBasedCollator *myJapaneseCollation = new RuleBasedCollator(rules, status);
* \code
* UErrorCode status = U_ZERO_ERROR;
* // get en_US collation rules
* RuleBasedCollator* en_USCollation =
* (RuleBasedCollator*) Collator::createInstance(Locale::US, status);
* // Always check the error code after each call.
* if (U_FAILURE(status)) return;
* // add a few Japanese character to sort before English characters
* // suppose the last character before the first base letter 'a' in
* // the English collation rule is 0x2212
* UChar jaString[] = { '&', 0x2212, '&lt;', 0x3041, ',', 0x3042, '&lt;', 0x3043, ',', 0x3044, 0 };
* UnicodeString rules( en_USCollation->getRules() );
* rules += jaString;
* RuleBasedCollator *myJapaneseCollation = new RuleBasedCollator(rules, status);
* \endcode
* </pre>
* <p><strong>NOTE</strong>: Typically, a collation object is created with
* Collator::createInstance().

View file

@ -8,7 +8,10 @@
#include "unicode/utypes.h"
/**
* @name BreakIterator C API
* \file
* \brief Description of BreakIterator C API
*
* <h2> BreakIterator C API </h2>
*
* The BreakIterator C API defines methods for finding the location
* of boundaries in text. Pointer to a UBreakIterator maintain a
@ -44,101 +47,115 @@
* <P>
* Helper function to output text
* <pre>
* . void printTextRange(UChar* str, UTextOffset start, UTextOffset end ) {
* . UChar* result;
* . UChar* temp;
* . const char* res;
* . temp=(UChar*)malloc(sizeof(UChar) * ((u_strlen(str)-start)+1));
* . result=(UChar*)malloc(sizeof(UChar) * ((end-start)+1));
* . u_strcpy(temp, &str[start]);
* . u_strncpy(result, temp, end-start);
* . res=(char*)malloc(sizeof(char) * (u_strlen(result)+1));
* . u_austrcpy(res, result);
* . printf("%s\n", res);
* . }
* \code
* void printTextRange(UChar* str, UTextOffset start, UTextOffset end ) {
* UChar* result;
* UChar* temp;
* const char* res;
* temp=(UChar*)malloc(sizeof(UChar) * ((u_strlen(str)-start)+1));
* result=(UChar*)malloc(sizeof(UChar) * ((end-start)+1));
* u_strcpy(temp, &str[start]);
* u_strncpy(result, temp, end-start);
* res=(char*)malloc(sizeof(char) * (u_strlen(result)+1));
* u_austrcpy(res, result);
* printf("%s\n", res);
* }
* \endcode
* </pre>
* Print each element in order:
* <pre>
* . void printEachForward( UBreakIterator* boundary, UChar* str) {
* . UTextOffset end;
* . UTextOffset start = ubrk_first(boundary);
* . for (end = ubrk_next(boundary)); end != UBRK_DONE; start = end, end = ubrk_next(boundary)) {
* . printTextRange(str, start, end );
* . }
* . }
* \code
* void printEachForward( UBreakIterator* boundary, UChar* str) {
* UTextOffset end;
* UTextOffset start = ubrk_first(boundary);
* for (end = ubrk_next(boundary)); end != UBRK_DONE; start = end, end = ubrk_next(boundary)) {
* printTextRange(str, start, end );
* }
* }
* \endcode
* </pre>
* Print each element in reverse order:
* <pre>
* . void printEachBackward( UBreakIterator* boundary, UChar* str) {
* . UTextOffset start;
* . UTextOffset end = ubrk_last(boundary);
* . for (start = ubrk_previous(boundary); start != UBRK_DONE; end = start, start =ubrk_previous(boundary)) {
* . printTextRange( str, start, end );
* . }
* . }
* \code
* void printEachBackward( UBreakIterator* boundary, UChar* str) {
* UTextOffset start;
* UTextOffset end = ubrk_last(boundary);
* for (start = ubrk_previous(boundary); start != UBRK_DONE; end = start, start =ubrk_previous(boundary)) {
* printTextRange( str, start, end );
* }
* }
* \endcode
* </pre>
* Print first element
* <pre>
* . void printFirst(UBreakIterator* boundary, UChar* str) {
* . UTextOffset end;
* . UTextOffset start = ubrk_first(boundary);
* . end = ubrk_next(boundary);
* . printTextRange( str, start, end );
* . }
* \code
* void printFirst(UBreakIterator* boundary, UChar* str) {
* UTextOffset end;
* UTextOffset start = ubrk_first(boundary);
* end = ubrk_next(boundary);
* printTextRange( str, start, end );
* }
* \endcode
* </pre>
* Print last element
* <pre>
* . void printLast(UBreakIterator* boundary, UChar* str) {
* . UTextOffset start;
* . UTextOffset end = ubrk_last(boundary);
* . start = ubrk_previous(boundary);
* . printTextRange(str, start, end );
* . }
* \code
* void printLast(UBreakIterator* boundary, UChar* str) {
* UTextOffset start;
* UTextOffset end = ubrk_last(boundary);
* start = ubrk_previous(boundary);
* printTextRange(str, start, end );
* }
* \endcode
* </pre>
* Print the element at a specified position
* <pre>
* . void printAt(UBreakIterator* boundary, UTextOffset pos , UChar* str) {
* . UTextOffset start;
* . UTextOffset end = ubrk_following(boundary, pos);
* . start = ubrk_previous(boundary);
* . printTextRange(str, start, end );
* . }
* \code
* void printAt(UBreakIterator* boundary, UTextOffset pos , UChar* str) {
* UTextOffset start;
* UTextOffset end = ubrk_following(boundary, pos);
* start = ubrk_previous(boundary);
* printTextRange(str, start, end );
* }
* \endcode
* </pre>
* Creating and using text boundaries
* <pre>
* . void BreakIterator_Example( void ) {
* . UBreakIterator* boundary;
* . UChar *stringToExamine;
* . stringToExamine=(UChar*)malloc(sizeof(UChar) * (strlen("Aaa bbb ccc. Ddd eee fff.")+1) );
* . u_uastrcpy(stringToExamine, "Aaa bbb ccc. Ddd eee fff.");
* . printf("Examining: "Aaa bbb ccc. Ddd eee fff.");
* .
* . //print each sentence in forward and reverse order
* . boundary = ubrk_open(UBRK_SENTENCE, "en_us", stringToExamine, u_strlen(stringToExamine), &status);
* . printf("----- forward: -----------\n");
* . printEachForward(boundary, stringToExamine);
* . printf("----- backward: ----------\n");
* . printEachBackward(boundary, stringToExamine);
* . ubrk_close(boundary);
* .
* . //print each word in order
* . boundary = ubrk_open(UBRK_WORD, "en_us", stringToExamine, u_strlen(stringToExamine), &status);
* . printf("----- forward: -----------\n");
* . printEachForward(boundary, stringToExamine);
* . printf("----- backward: ----------\n");
* . printEachBackward(boundary, stringToExamine);
* . //print first element
* . printf("----- first: -------------\n");
* . printFirst(boundary, stringToExamine);
* . //print last element
* . printf("----- last: --------------\n");
* . printLast(boundary, stringToExamine);
* . //print word at charpos 10
* . printf("----- at pos 10: ---------\n");
* . printAt(boundary, 10 , stringToExamine);
* .
* . ubrk_close(boundary);
* . }
* \code
* void BreakIterator_Example( void ) {
* UBreakIterator* boundary;
* UChar *stringToExamine;
* stringToExamine=(UChar*)malloc(sizeof(UChar) * (strlen("Aaa bbb ccc. Ddd eee fff.")+1) );
* u_uastrcpy(stringToExamine, "Aaa bbb ccc. Ddd eee fff.");
* printf("Examining: "Aaa bbb ccc. Ddd eee fff.");
*
* //print each sentence in forward and reverse order
* boundary = ubrk_open(UBRK_SENTENCE, "en_us", stringToExamine, u_strlen(stringToExamine), &status);
* printf("----- forward: -----------\n");
* printEachForward(boundary, stringToExamine);
* printf("----- backward: ----------\n");
* printEachBackward(boundary, stringToExamine);
* ubrk_close(boundary);
*
* //print each word in order
* boundary = ubrk_open(UBRK_WORD, "en_us", stringToExamine, u_strlen(stringToExamine), &status);
* printf("----- forward: -----------\n");
* printEachForward(boundary, stringToExamine);
* printf("----- backward: ----------\n");
* printEachBackward(boundary, stringToExamine);
* //print first element
* printf("----- first: -------------\n");
* printFirst(boundary, stringToExamine);
* //print last element
* printf("----- last: --------------\n");
* printLast(boundary, stringToExamine);
* //print word at charpos 10
* printf("----- at pos 10: ---------\n");
* printAt(boundary, 10 , stringToExamine);
*
* ubrk_close(boundary);
* }
* \endcode
* </pre>
*/

View file

@ -8,7 +8,10 @@
#include "unicode/utypes.h"
/**
* @name Calendar C API
* \file
* \brief Description of Calendar C API
*
* <h2>Calendar C API</h2>
*
* UCalendar C API is used for converting between a <code>UDate</code> object
* and a set of integer fields such as <code>UCAL_YEAR</code>, <code>UCAL_MONTH</code>,
@ -31,12 +34,14 @@
* calendar to be opened and the timezoneId.
* <blockquote>
* <pre>
* \code
* UCalendar *caldef;
* UChar *tzId;
* UErrorCode status;
* tzId=(UChar*)malloc(sizeof(UChar) * (strlen("PST") +1) );
* u_uastrcpy(tzId, "PST");
* caldef=ucal_open(tzID, u_strlen(tzID), NULL, UCAL_TRADITIONAL, &status);
* \endcode
* </pre>
* </blockquote>
*
@ -67,11 +72,13 @@
*
* <blockquote>
* <pre>
* \code
* UCAL_MONTH + UCAL_DAY_OF_MONTH
* UCAL_MONTH + UCAL_WEEK_OF_MONTH + UCAL_DAY_OF_WEEK
* UCAL_MONTH + UCAL_DAY_OF_WEEK_IN_MONTH + UCAL_DAY_OF_WEEK
* UCAL_DAY_OF_YEAR
* UCAL_DAY_OF_WEEK + UCAL_WEEK_OF_YEAR
* \endcode
* </pre>
* </blockquote>
*
@ -79,8 +86,10 @@
*
* <blockquote>
* <pre>
* \code
* UCAL_HOUR_OF_DAY
* UCAL_AM_PM + UCAL_HOUR
* \endcode
* </pre>
* </blockquote>
*

View file

@ -10,7 +10,10 @@
#include "unicode/utypes.h"
#include "unicode/unorm.h"
/**
* @name Collator C API
* \file
* \brief Description of Collator C API
*
* <h2> Collator C API </h2>
*
* The C API for Collator performs locale-sensitive
* <code>String</code> comparison. You use this class to build
@ -29,6 +32,7 @@
* the <code>UCollator</code> for the default locale.
* <blockquote>
* <pre>
* \code
* // Compare two strings in the default locale
* UErrorCode success = U_ZERO_ERROR;
* UCollator* myCollator = ucol_open(NULL, &success);
@ -40,6 +44,7 @@
* }else{
* printf("abc is greater than or equal to ABC\n");
* }
* \endcode
* </pre>
* </blockquote>
*
@ -57,6 +62,7 @@
* US English.
* <blockquote>
* <pre>
* \code
* //Get the Collator for US English and set its strength to UCOL_PRIMARY
* UErrorCode success = U_ZERO_ERROR;
* UCollator* usCollator = ucol_open("en_US", &success);
@ -67,6 +73,7 @@
* if( u_strcoll(myCollator, source, u_strlen(source), target, u_strlen(target)) == UCOL_EQUAL) {
* printf("'abc' and 'ABC' strings are equivalent with strength UCOL_PRIMARY\n");
* }
* \endcode
* </pre>
* </blockquote>
* <p>

View file

@ -11,7 +11,10 @@
#include "unicode/ucal.h"
#include "unicode/unum.h"
/**
* @name Date Format C API
* \file
* \brief Description of DateFormat C API
*
* <h2> Date Format C API</h2>
*
* Date Format C API consists of functions that convert dates and
* times from their internal representations to textual form and back again in a
@ -28,52 +31,60 @@
* To format a date for the current Locale with default time and date style,
* use one of the static factory methods:
* <pre>
* . UErrorCode status;
* . UFieldPosition pos;
* . UChar *myString;
* . t_int32 myStrlen=0;
* . UDateFormat* dfmt = udat_open(UCAL_DEFAULT, UCAL_DEFAULT, NULL, "PST", &status);
* . myStrlen = udat_format(dfmt, myDate, NULL, myStrlen, &pos, &status);
* . if(status==U_BUFFER_OVERFLOW_ERROR){
* . status=U_ZERO_ERROR;
* . myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
* . udat_format(dfmt, myDate, myString, myStrlen+1, &pos, &status);
* . }
* \code
* UErrorCode status;
* UFieldPosition pos;
* UChar *myString;
* t_int32 myStrlen=0;
* UDateFormat* dfmt = udat_open(UCAL_DEFAULT, UCAL_DEFAULT, NULL, "PST", &status);
* myStrlen = udat_format(dfmt, myDate, NULL, myStrlen, &pos, &status);
* if(status==U_BUFFER_OVERFLOW_ERROR){
* status=U_ZERO_ERROR;
* myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
* udat_format(dfmt, myDate, myString, myStrlen+1, &pos, &status);
* }
* \endcode
* </pre>
* If you are formatting multiple numbers, it is more efficient to get the
* format and use it multiple times so that the system doesn't have to fetch the
* information about the local language and country conventions multiple times.
* <pre>
* . t_int32 i, myStrlen=0;
* . UChar* myString;
* . UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values
* . UDateFormat* df = udat_open(UCAL_DEFAULT, UCAL_DEFAULT, NULL, "GMT", &status);
* . for (i = 0; i < 3; ++i) {
* . myStrlen = udat_format(df, myDate, NULL, myStrlen, &pos, &status);
* . if(status==U_BUFFER_OVERFLOW_ERROR){
* . status=U_ZERO_ERROR;
* . myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
* . udat_format(df, myDate, myString, myStrlen+1, &pos, &status);
* . }
* . printf("%s \n", austrdup(myString) ); //austrdup( a function used to convert UChar* to char*)
* . free(myString);
* . }
* \code
* t_int32 i, myStrlen=0;
* UChar* myString;
* UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values
* UDateFormat* df = udat_open(UCAL_DEFAULT, UCAL_DEFAULT, NULL, "GMT", &status);
* for (i = 0; i < 3; ++i) {
* myStrlen = udat_format(df, myDate, NULL, myStrlen, &pos, &status);
* if(status==U_BUFFER_OVERFLOW_ERROR){
* status=U_ZERO_ERROR;
* myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
* udat_format(df, myDate, myString, myStrlen+1, &pos, &status);
* }
* printf("%s \n", austrdup(myString) ); //austrdup( a function used to convert UChar* to char*)
* free(myString);
* }
* \endcode
* </pre>
* To format a date for a different Locale, specify it in the call to
* udat_open()
* <pre>
* . UDateFormat* df = udat_open(UDAT_SHORT, UDAT_SHORT, "fr_FR", "GMT", &status);
* \code
* UDateFormat* df = udat_open(UDAT_SHORT, UDAT_SHORT, "fr_FR", "GMT", &status);
* \endcode
* </pre>
* You can use a DateFormat API udat_parse() to parse.
* <pre>
* . UErrorCode status = U_ZERO_ERROR;
* . t_int32 parsepos=0;
* . UDate myDate = udat_parse(df, myString, u_strlen(myString), &parsepos, &status);
* \code
* UErrorCode status = U_ZERO_ERROR;
* t_int32 parsepos=0;
* UDate myDate = udat_parse(df, myString, u_strlen(myString), &parsepos, &status);
* \endcode
* </pre>
* . You can pass in different options for the arguments for date and time style
* . to control the length of the result; from SHORT to MEDIUM to LONG to FULL.
* . The exact result depends on the locale, but generally:
* . see UDateFormatStyle for more details
* You can pass in different options for the arguments for date and time style
* to control the length of the result; from SHORT to MEDIUM to LONG to FULL.
* The exact result depends on the locale, but generally:
* see UDateFormatStyle for more details
* <ul type=round>
* <li> UDAT_SHORT is completely numeric, such as 12/13/52 or 3:30pm
* <li> UDAT_MEDIUM is longer, such as Jan 12, 1952

View file

@ -10,7 +10,10 @@
#include "unicode/utypes.h"
#include <stdarg.h>
/**
* @name Message Format C API
* \file
* \brief Description of MessageFormat C API`
*
* <h2>Message Format C API </h2>
*
* Provides means to produce concatenated messages in language-neutral way.
* Use this for all concatenations that show up to end users.
@ -21,93 +24,101 @@
* Here are some examples of usage:
* Example 1:
* <pre>
* . UChar *result, *tzID, *str;
* . UChar pattern[100];
* . t_int32 resultLengthOut, resultlength;
* . UCalendar *cal;
* . UDate d1;
* . UDateFormat *def1;
* . UErrorCode status = U_ZERO_ERROR;
* . str=(UChar*)malloc(sizeof(UChar) * (strlen("disturbance in force") +1));
* . u_uastrcpy(str, "disturbance in force");
* . tzID=(UChar*)malloc(sizeof(UChar) * 4);
* . u_uastrcpy(tzID, "PST");
* . cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);
* . ucal_setDateTime(cal, 1999, UCAL_MARCH, 18, 0, 0, 0, &status);
* . d1=ucal_getMillis(cal, &status);
* . u_uastrcpy(pattern, "On {0, date, long}, there was a {1} on planet {2,number,integer}");
* . resultlength=0;
* . resultLengthOut=u_formatMessage( "en_US", pattern, u_strlen(pattern), NULL, resultlength, &status, d1, str, 7);
* . if(status==U_BUFFER_OVERFLOW_ERROR){
* . status=U_ZERO_ERROR;
* . resultlength=resultLengthOut+1;
* . result=(UChar*)realloc(result, sizeof(UChar) * resultlength);
* . u_formatMessage( "en_US", pattern, u_strlen(pattern), result, resultlength, &status, d1, str, 7);
* . }
* . printf("%s\n", austrdup(result) );//austrdup( a function used to convert UChar* to char*)
* . //output>: "On March 18, 1999, there was a disturbance in force on planet 7
* \code
* UChar *result, *tzID, *str;
* UChar pattern[100];
* t_int32 resultLengthOut, resultlength;
* UCalendar *cal;
* UDate d1;
* UDateFormat *def1;
* UErrorCode status = U_ZERO_ERROR;
* str=(UChar*)malloc(sizeof(UChar) * (strlen("disturbance in force") +1));
* u_uastrcpy(str, "disturbance in force");
* tzID=(UChar*)malloc(sizeof(UChar) * 4);
* u_uastrcpy(tzID, "PST");
* cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);
* ucal_setDateTime(cal, 1999, UCAL_MARCH, 18, 0, 0, 0, &status);
* d1=ucal_getMillis(cal, &status);
* u_uastrcpy(pattern, "On {0, date, long}, there was a {1} on planet {2,number,integer}");
* resultlength=0;
* resultLengthOut=u_formatMessage( "en_US", pattern, u_strlen(pattern), NULL, resultlength, &status, d1, str, 7);
* if(status==U_BUFFER_OVERFLOW_ERROR){
* status=U_ZERO_ERROR;
* resultlength=resultLengthOut+1;
* result=(UChar*)realloc(result, sizeof(UChar) * resultlength);
* u_formatMessage( "en_US", pattern, u_strlen(pattern), result, resultlength, &status, d1, str, 7);
* }
* printf("%s\n", austrdup(result) );//austrdup( a function used to convert UChar* to char*)
* //output>: "On March 18, 1999, there was a disturbance in force on planet 7
* \endcode
* </pre>
* Typically, the message format will come from resources, and the
* arguments will be dynamically set at runtime.
* <P>
* Example 2:
* <pre>
* . UChar* str;
* . UErrorCode status = U_ZERO_ERROR;
* . UChar *result;
* . UChar pattern[100];
* . t_int32 resultlength,resultLengthOut, i;
* . double testArgs= { 100.0, 1.0, 0.0};
* . str=(UChar*)malloc(sizeof(UChar) * 10);
* . u_uastrcpy(str, "MyDisk");
* . u_uastrcpy(pattern, "The disk {1} contains {0,choice,0#no files|1#one file|1<{0,number,integer} files}");
* . for(i=0; i<3; i++){
* . resultlength=0;
* . resultLengthOut=u_formatMessage( "en_US", pattern, u_strlen(pattern), NULL, resultlength, &status, testArgs[i], str);
* . if(status==U_BUFFER_OVERFLOW_ERROR){
* . status=U_ZERO_ERROR;
* . resultlength=resultLengthOut+1;
* . result=(UChar*)malloc(sizeof(UChar) * resultlength);
* . u_formatMessage( "en_US", pattern, u_strlen(pattern), result, resultlength, &status, testArgs[i], str);
* . }
* . printf("%s\n", austrdup(result) ); //austrdup( a function used to convert UChar* to char*)
* . free(result);
* . }
* . // output, with different testArgs:
* . // output: The disk "MyDisk" contains 100 files.
* . // output: The disk "MyDisk" contains one file.
* . // output: The disk "MyDisk" contains no files.
* \code
* UChar* str;
* UErrorCode status = U_ZERO_ERROR;
* UChar *result;
* UChar pattern[100];
* t_int32 resultlength,resultLengthOut, i;
* double testArgs= { 100.0, 1.0, 0.0};
* str=(UChar*)malloc(sizeof(UChar) * 10);
* u_uastrcpy(str, "MyDisk");
* u_uastrcpy(pattern, "The disk {1} contains {0,choice,0#no files|1#one file|1<{0,number,integer} files}");
* for(i=0; i<3; i++){
* resultlength=0;
* resultLengthOut=u_formatMessage( "en_US", pattern, u_strlen(pattern), NULL, resultlength, &status, testArgs[i], str);
* if(status==U_BUFFER_OVERFLOW_ERROR){
* status=U_ZERO_ERROR;
* resultlength=resultLengthOut+1;
* result=(UChar*)malloc(sizeof(UChar) * resultlength);
* u_formatMessage( "en_US", pattern, u_strlen(pattern), result, resultlength, &status, testArgs[i], str);
* }
* printf("%s\n", austrdup(result) ); //austrdup( a function used to convert UChar* to char*)
* free(result);
* }
* // output, with different testArgs:
* // output: The disk "MyDisk" contains 100 files.
* // output: The disk "MyDisk" contains one file.
* // output: The disk "MyDisk" contains no files.
* \endcode
* </pre>
*
* The pattern is of the following form. Legend:
* <pre>
* . {optional item}
* . (group that may be repeated)*
* \code
* {optional item}
* (group that may be repeated)*
* \endcode
* </pre>
* Do not confuse optional items with items inside quotes braces, such
* as this: "{". Quoted braces are literals.
* <pre>
* . messageFormatPattern := string ( "{" messageFormatElement "}" string )*
* .
* . messageFormatElement := argument { "," elementFormat }
* .
* . elementFormat := "time" { "," datetimeStyle }
* . | "date" { "," datetimeStyle }
* . | "number" { "," numberStyle }
* . | "choice" "," choiceStyle
* .
* . datetimeStyle := "short"
* . | "medium"
* . | "long"
* . | "full"
* . | dateFormatPattern
* .
* . numberStyle := "currency"
* . | "percent"
* . | "integer"
* . | numberFormatPattern
* .
* . choiceStyle := choiceFormatPattern
* \code
* messageFormatPattern := string ( "{" messageFormatElement "}" string )*
*
* messageFormatElement := argument { "," elementFormat }
*
* elementFormat := "time" { "," datetimeStyle }
* | "date" { "," datetimeStyle }
* | "number" { "," numberStyle }
* | "choice" "," choiceStyle
*
* datetimeStyle := "short"
* | "medium"
* | "long"
* | "full"
* | dateFormatPattern
*
* numberStyle := "currency"
* | "percent"
* | "integer"
* | numberFormatPattern
*
* choiceStyle := choiceFormatPattern
* \endcode
* </pre>
* If there is no elementFormat, then the argument must be a string,
* which is substituted. If there is no dateTimeStyle or numberStyle,
@ -142,11 +153,13 @@
* [Note:] Formats are numbered by order of variable in the string.
* This is [not] the same as the argument numbering!
* <pre>
* . For example: with "abc{2}def{3}ghi{0}...",
* .
* . format0 affects the first variable {2}
* . format1 affects the second variable {3}
* . format2 affects the second variable {0}
* \code
* For example: with "abc{2}def{3}ghi{0}...",
*
* format0 affects the first variable {2}
* format1 affects the second variable {3}
* format2 affects the second variable {0}
* \endcode
* </pre>
* and so on.
*/

View file

@ -15,7 +15,10 @@
#include "unicode/umisc.h"
/**
* @name Number Format C API
* \file
* \brief Description of NumberFormat C API
*
* <h2> Number Format C API </h2>
*
* Number Format C API Provides functions for
* formatting and parsing a number. Also provides methods for
@ -32,49 +35,57 @@
* To format a number for the current Locale, use one of the static
* factory methods:
* <pre>
* . UChar myString[20];
* . UFieldPosition pos=0;
* . double myNumber = 7.0;
* . UErrorCode success = U_ZERO_ERROR;
* . UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, &success)
* . unum_formatDouble(nf, myNumber, myString, u_strlen(myString), &pos, &status);
* . printf(" Example 1: %s\n", austrdup(myString) ); //austrdup( a function used to convert UChar* to char*)
* \code
* UChar myString[20];
* UFieldPosition pos=0;
* double myNumber = 7.0;
* UErrorCode success = U_ZERO_ERROR;
* UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, &success)
* unum_formatDouble(nf, myNumber, myString, u_strlen(myString), &pos, &status);
* printf(" Example 1: %s\n", austrdup(myString) ); //austrdup( a function used to convert UChar* to char*)
* \endcode
* </pre>
* If you are formatting multiple numbers, it is more efficient to get
* the format and use it multiple times so that the system doesn't
* have to fetch the information about the local language and country
* conventions multiple times.
* <pre>
* . UChar* myString;
* . t_int32 i, resultlength, reslenneeded;
* . UErrorCode success = U_ZERO_ERROR;
* . UFieldPosition pos=0;
* . t_int32 a[] = { 123, 3333, -1234567 };
* . const t_int32 a_len = sizeof(a) / sizeof(a[0]);
* . UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, &success)
* . for (i = 0; i < a_len; i++) {
* . resultlength=0;
* . reslenneeded=unum_format(nf, a[i], NULL, resultlength, &pos, &status);
* . if(status==U_BUFFER_OVERFLOW_ERROR){
* . status=U_ZERO_ERROR;
* . resultlength=resultlengthneeded+1;
* . result=(UChar*)malloc(sizeof(UChar) * resultlength);
* . unum_format(nf, a[i], result, resultlength, &pos, &status);
* . }
* . printf(" Example 2: %s\n", austrdup(result) );
* . free(result);
* . }
* \code
* UChar* myString;
* t_int32 i, resultlength, reslenneeded;
* UErrorCode success = U_ZERO_ERROR;
* UFieldPosition pos=0;
* t_int32 a[] = { 123, 3333, -1234567 };
* const t_int32 a_len = sizeof(a) / sizeof(a[0]);
* UNumberFormat* nf = unum_open(UNUM_DEFAULT, NULL, &success)
* for (i = 0; i < a_len; i++) {
* resultlength=0;
* reslenneeded=unum_format(nf, a[i], NULL, resultlength, &pos, &status);
* if(status==U_BUFFER_OVERFLOW_ERROR){
* status=U_ZERO_ERROR;
* resultlength=resultlengthneeded+1;
* result=(UChar*)malloc(sizeof(UChar) * resultlength);
* unum_format(nf, a[i], result, resultlength, &pos, &status);
* }
* printf(" Example 2: %s\n", austrdup(result) );
* free(result);
* }
* \endcode
* </pre>
* To format a number for a different Locale, specify it in the
* call to unum_open().
* <pre>
* . UNumberFormat* nf = unum_open(UNUM_DEFAULT, "fr_FR", &success)
* \code
* UNumberFormat* nf = unum_open(UNUM_DEFAULT, "fr_FR", &success)
* \endcode
* </pre>
* You can use a NumberFormat API unum_parse() to parse.
* <pre>
* . UErrorCode success;
* . t_int32 pos=0;
* . unum_parse(nf, result, u_strlen(result), &pos, &success);
* \code
* UErrorCode success;
* t_int32 pos=0;
* unum_parse(nf, result, u_strlen(result), &pos, &success);
* \endcode
* </pre>
* Use UCAL_DECIMAL to get the normal number format for that country.
* There are other static options available. Use UCAL_CURRENCY