- cout << "ICU Break Iterator Sample Program\n\n";
- cout << "C++ Break Iteration\n\n";
- BreakIterator* boundary;
- UnicodeString stringToExamine("Aaa bbb ccc. Ddd eee fff.");
- cout << "Examining: ";
- printUnicodeString(stringToExamine);
- cout << endl;
-
- //print each sentence in forward and reverse order
- UErrorCode status = U_ZERO_ERROR;
- boundary = BreakIterator::createSentenceInstance(
- Locale::getUS(), status );
- if (U_FAILURE(status)) {
- cout <<
- "failed to create sentence break iterator. status = "
- << u_errorName(status);
- exit(1);
- }
-
- boundary->setText(stringToExamine);
- cout << "\n Sentence Boundaries... \n";
- cout << "----- forward: -----------" << '\n';
- printEachForward(*boundary);
- cout << "----- backward: ----------" << '\n';
- printEachBackward(*boundary);
- delete boundary;
-
- //print each word in order
- cout << "\n Word Boundaries... \n";
- boundary = BreakIterator::createWordInstance(
- Locale::getUS(), status);
- boundary->setText(stringToExamine);
- cout << "----- forward: -----------" << '\n';
- printEachForward(*boundary);
- //print first element
- cout << "----- first: -------------" << '\n';
- printFirst(*boundary);
- //print last element
- cout << "----- last: --------------" << '\n';
- printLast(*boundary);
- //print word at charpos 10
- cout << "----- at pos 10: ---------" << '\n';
- printAt(*boundary, 10 );
-
- delete boundary;
- cout.flush();
-
- // Call the C version
- return c_main();
+ puts("ICU Break Iterator Sample Program\n");
+ puts("C++ Break Iteration\n");
+ BreakIterator* boundary;
+ UnicodeString stringToExamine("Aaa bbb ccc. Ddd eee fff.");
+ printf("Examining: ");
+ printUnicodeString(stringToExamine);
+ puts("");
+
+ //print each sentence in forward and reverse order
+ UErrorCode status = U_ZERO_ERROR;
+ boundary = BreakIterator::createSentenceInstance(
+ Locale::getUS(), status );
+ if (U_FAILURE(status)) {
+ printf("failed to create sentence break iterator. status = %s",
+ u_errorName(status));
+ exit(1);
+ }
+
+ boundary->setText(stringToExamine);
+ puts("\n Sentence Boundaries... ");
+ puts("----- forward: -----------");
+ printEachForward(*boundary);
+ puts("----- backward: ----------");
+ printEachBackward(*boundary);
+ delete boundary;
+
+ //print each word in order
+ printf("\n Word Boundaries... \n");
+ boundary = BreakIterator::createWordInstance(
+ Locale::getUS(), status);
+ boundary->setText(stringToExamine);
+ puts("----- forward: -----------");
+ printEachForward(*boundary);
+ //print first element
+ puts("----- first: -------------");
+ printFirst(*boundary);
+ //print last element
+ puts("----- last: --------------");
+ printLast(*boundary);
+ //print word at charpos 10
+ puts("----- at pos 10: ---------");
+ printAt(*boundary, 10 );
+
+ delete boundary;
+
+ puts("\nEnd C++ Break Iteration");
+
+ // Call the C version
+ return c_main();