summaryrefslogtreecommitdiff
path: root/Build/source/libs/icu/icu-xetex/samples/break
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/icu/icu-xetex/samples/break')
-rw-r--r--Build/source/libs/icu/icu-xetex/samples/break/Makefile22
-rw-r--r--Build/source/libs/icu/icu-xetex/samples/break/break.cpp143
-rw-r--r--Build/source/libs/icu/icu-xetex/samples/break/break.sln19
-rw-r--r--Build/source/libs/icu/icu-xetex/samples/break/break.vcproj235
-rw-r--r--Build/source/libs/icu/icu-xetex/samples/break/readme.txt60
-rw-r--r--Build/source/libs/icu/icu-xetex/samples/break/ubreak.c128
6 files changed, 607 insertions, 0 deletions
diff --git a/Build/source/libs/icu/icu-xetex/samples/break/Makefile b/Build/source/libs/icu/icu-xetex/samples/break/Makefile
new file mode 100644
index 00000000000..3afd0c517bc
--- /dev/null
+++ b/Build/source/libs/icu/icu-xetex/samples/break/Makefile
@@ -0,0 +1,22 @@
+# Copyright (c) 2000-2002 IBM, Inc. and others
+# sample code makefile
+
+# Usage:
+# - configure, build, install ICU (make install)
+# - make sure "icu-config" (in the ICU installed bin directory) is on
+# the path
+# - do 'make' in this directory
+
+#### definitions
+# Name of your target
+TARGET=break
+
+# All object files (C or C++)
+OBJECTS=break.o ubreak.o
+
+#### rules
+# Load in standard makefile definitions
+include ../defs.mk
+
+# the actual rules (this is a simple sample)
+include ../rules.mk
diff --git a/Build/source/libs/icu/icu-xetex/samples/break/break.cpp b/Build/source/libs/icu/icu-xetex/samples/break/break.cpp
new file mode 100644
index 00000000000..90d77efad42
--- /dev/null
+++ b/Build/source/libs/icu/icu-xetex/samples/break/break.cpp
@@ -0,0 +1,143 @@
+/*
+*******************************************************************************
+*
+* Copyright (C) 2002-2003, International Business Machines
+* Corporation and others. All Rights Reserved.
+*
+*******************************************************************************
+*/
+
+#include <stdio.h>
+#include <unicode/brkiter.h>
+#include <stdlib.h>
+
+U_CFUNC int c_main(void);
+
+
+void printUnicodeString(const UnicodeString &s) {
+ char charBuf[1000];
+ s.extract(0, s.length(), charBuf, sizeof(charBuf)-1, 0);
+ charBuf[sizeof(charBuf)-1] = 0;
+ printf("%s", charBuf);
+}
+
+
+void printTextRange( BreakIterator& iterator,
+ int32_t start, int32_t end )
+{
+ CharacterIterator *strIter = iterator.getText().clone();
+ UnicodeString s;
+ strIter->getText(s);
+
+ printf(" %ld %ld\t", (long)start, (long)end);
+ printUnicodeString(UnicodeString(s, 0, start));
+ printf("|");
+ printUnicodeString(UnicodeString(s, start, end-start));
+ printf("|");
+ printUnicodeString(UnicodeString(s, end));
+ puts("");
+ delete strIter;
+}
+
+
+/* Print each element in order: */
+void printEachForward( BreakIterator& boundary)
+{
+ int32_t start = boundary.first();
+ for (int32_t end = boundary.next();
+ end != BreakIterator::DONE;
+ start = end, end = boundary.next())
+ {
+ printTextRange( boundary, start, end );
+ }
+}
+
+/* Print each element in reverse order: */
+void printEachBackward( BreakIterator& boundary)
+{
+ int32_t end = boundary.last();
+ for (int32_t start = boundary.previous();
+ start != BreakIterator::DONE;
+ end = start, start = boundary.previous())
+ {
+ printTextRange( boundary, start, end );
+ }
+}
+
+/* Print the first element */
+void printFirst(BreakIterator& boundary)
+{
+ int32_t start = boundary.first();
+ int32_t end = boundary.next();
+ printTextRange( boundary, start, end );
+}
+
+/* Print the last element */
+void printLast(BreakIterator& boundary)
+{
+ int32_t end = boundary.last();
+ int32_t start = boundary.previous();
+ printTextRange( boundary, start, end );
+}
+
+/* Print the element at a specified position */
+void printAt(BreakIterator &boundary, int32_t pos )
+{
+ int32_t end = boundary.following(pos);
+ int32_t start = boundary.previous();
+ printTextRange( boundary, start, end );
+}
+
+/* Creating and using text boundaries */
+int main( void )
+{
+ 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();
+}
diff --git a/Build/source/libs/icu/icu-xetex/samples/break/break.sln b/Build/source/libs/icu/icu-xetex/samples/break/break.sln
new file mode 100644
index 00000000000..879ec15b2da
--- /dev/null
+++ b/Build/source/libs/icu/icu-xetex/samples/break/break.sln
@@ -0,0 +1,19 @@
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "break", "break.vcproj", "{DEEADF02-9C14-4854-A395-E505D2904D65}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {DEEADF02-9C14-4854-A395-E505D2904D65}.Debug|Win32.ActiveCfg = Debug|Win32
+ {DEEADF02-9C14-4854-A395-E505D2904D65}.Debug|Win32.Build.0 = Debug|Win32
+ {DEEADF02-9C14-4854-A395-E505D2904D65}.Release|Win32.ActiveCfg = Release|Win32
+ {DEEADF02-9C14-4854-A395-E505D2904D65}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Build/source/libs/icu/icu-xetex/samples/break/break.vcproj b/Build/source/libs/icu/icu-xetex/samples/break/break.vcproj
new file mode 100644
index 00000000000..097a79359a4
--- /dev/null
+++ b/Build/source/libs/icu/icu-xetex/samples/break/break.vcproj
@@ -0,0 +1,235 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="break"
+ ProjectGUID="{DEEADF02-9C14-4854-A395-E505D2904D65}"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release/break.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="..\..\..\include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ TreatWChar_tAsBuiltInType="true"
+ UsePrecompiledHeader="0"
+ PrecompiledHeaderFile=".\Release/break.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ CompileAs="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="icuuc.lib icuin.lib"
+ OutputFile=".\Release/break.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ AdditionalLibraryDirectories="..\..\..\lib"
+ ProgramDatabaseFile=".\Release/break.pdb"
+ SubSystem="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Debug/break.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\..\include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ TreatWChar_tAsBuiltInType="true"
+ UsePrecompiledHeader="0"
+ PrecompiledHeaderFile=".\Debug/break.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ CompileAs="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="icuucd.lib icuind.lib"
+ OutputFile=".\Debug/break.exe"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ AdditionalLibraryDirectories="..\..\..\lib"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile=".\Debug/break.pdb"
+ SubSystem="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+ >
+ <File
+ RelativePath=".\break.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\ubreak.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl"
+ >
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Build/source/libs/icu/icu-xetex/samples/break/readme.txt b/Build/source/libs/icu/icu-xetex/samples/break/readme.txt
new file mode 100644
index 00000000000..dbb69a5ada6
--- /dev/null
+++ b/Build/source/libs/icu/icu-xetex/samples/break/readme.txt
@@ -0,0 +1,60 @@
+Copyright (c) 2002-2005, International Business Machines Corporation and others. All Rights Reserved.
+break: Boundary Analysis
+
+This sample demonstrates
+ Using ICU to determine the linguistic boundaries within text
+
+
+Files:
+ break.cpp Main source file in C++
+ ubreak.c Main source file in C
+ break.sln Windows MSVC workspace. Double-click this to get started.
+ break.vcproj Windows MSVC project file
+
+To Build break on Windows
+ 1. Install and build ICU
+ 2. In MSVC, open the workspace file icu\samples\break\break.sln
+ 3. Choose a Debug or Release build.
+ 4. Build.
+
+To Run on Windows
+ 1. Start a command shell window
+ 2. Add ICU's bin directory to the path, e.g.
+ set PATH=c:\icu\bin;%PATH%
+ (Use the path to where ever ICU is on your system.)
+ 3. cd into the break directory, e.g.
+ cd c:\icu\source\samples\break\debug
+ 4. Run it
+ break
+
+To Build on Unixes
+ 1. Build ICU.
+ Specify an ICU install directory when running configure,
+ using the --prefix option. The steps to build ICU will look something
+ like this:
+ cd <icu directory>/source
+ runConfigureICU <platform-name> --prefix <icu install directory> [other options]
+ gmake all
+
+ 2. Install ICU,
+ gmake install
+
+ 3. Compile
+ cd <icu directory>/source/samples/break
+ gmake ICU_PREFIX=<icu install directory)
+
+ To Run on Unixes
+ cd <icu directory>/source/samples/break
+
+ gmake ICU_PREFIX=<icu install directory> check
+ -or-
+
+ export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
+ break
+
+
+ Note: The name of the LD_LIBRARY_PATH variable is different on some systems.
+ If in doubt, run the sample using "gmake check", and note the name of
+ the variable that is used there. LD_LIBRARY_PATH is the correct name
+ for Linux and Solaris.
+
diff --git a/Build/source/libs/icu/icu-xetex/samples/break/ubreak.c b/Build/source/libs/icu/icu-xetex/samples/break/ubreak.c
new file mode 100644
index 00000000000..e70d877b303
--- /dev/null
+++ b/Build/source/libs/icu/icu-xetex/samples/break/ubreak.c
@@ -0,0 +1,128 @@
+/*
+*******************************************************************************
+*
+* Copyright (C) 2002, International Business Machines
+* Corporation and others. All Rights Reserved.
+*
+*******************************************************************************
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unicode/ustring.h>
+#include <unicode/ubrk.h>
+
+U_CFUNC int c_main(void);
+
+void printTextRange(UChar* str, int32_t start, int32_t end)
+{
+ char charBuf[1000];
+ UChar savedEndChar;
+
+ savedEndChar = str[end];
+ str[end] = 0;
+ u_austrncpy(charBuf, str+start, sizeof(charBuf)-1);
+ charBuf[sizeof(charBuf)-1]=0;
+ printf("string[%2d..%2d] \"%s\"\n", start, end-1, charBuf);
+ str[end] = savedEndChar;
+}
+
+
+
+/* Print each element in order: */
+void printEachForward( UBreakIterator* boundary, UChar* str) {
+ int32_t end;
+ int32_t start = ubrk_first(boundary);
+ for (end = ubrk_next(boundary); end != UBRK_DONE; start = end, end =
+ ubrk_next(boundary)) {
+ printTextRange(str, start, end );
+ }
+}
+
+
+/* Print each element in reverse order: */
+void printEachBackward( UBreakIterator* boundary, UChar* str) {
+ int32_t start;
+ int32_t end = ubrk_last(boundary);
+ for (start = ubrk_previous(boundary); start != UBRK_DONE; end = start,
+ start =ubrk_previous(boundary)) {
+ printTextRange( str, start, end );
+ }
+}
+
+/* Print first element */
+void printFirst(UBreakIterator* boundary, UChar* str) {
+ int32_t end;
+ int32_t start = ubrk_first(boundary);
+ end = ubrk_next(boundary);
+ printTextRange( str, start, end );
+}
+
+/* Print last element */
+void printLast(UBreakIterator* boundary, UChar* str) {
+ int32_t start;
+ int32_t end = ubrk_last(boundary);
+ start = ubrk_previous(boundary);
+ printTextRange(str, start, end );
+}
+
+/* Print the element at a specified position */
+
+void printAt(UBreakIterator* boundary, int32_t pos , UChar* str) {
+ int32_t start;
+ int32_t end = ubrk_following(boundary, pos);
+ start = ubrk_previous(boundary);
+ printTextRange(str, start, end );
+}
+
+/* Creating and using text boundaries*/
+
+int c_main( void ) {
+ UBreakIterator *boundary;
+ char cStringToExamine[] = "Aaa bbb ccc. Ddd eee fff.";
+ UChar stringToExamine[sizeof(cStringToExamine)+1];
+ UErrorCode status = U_ZERO_ERROR;
+
+ printf("\n\n"
+ "C Boundary Analysis\n"
+ "-------------------\n\n");
+
+ printf("Examining: %s\n", cStringToExamine);
+ u_uastrcpy(stringToExamine, cStringToExamine);
+
+ /*print each sentence in forward and reverse order*/
+ boundary = ubrk_open(UBRK_SENTENCE, "en_us", stringToExamine,
+ -1, &status);
+ if (U_FAILURE(status)) {
+ printf("ubrk_open error: %s\n", u_errorName(status));
+ exit(1);
+ }
+
+ printf("\n----- Sentence Boundaries, forward: -----------\n");
+ printEachForward(boundary, stringToExamine);
+ printf("\n----- Sentence Boundaries, 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("\n----- Word Boundaries, forward: -----------\n");
+ printEachForward(boundary, stringToExamine);
+ printf("\n----- Word Boundaries, backward: ----------\n");
+ printEachBackward(boundary, stringToExamine);
+ /*print first element*/
+ printf("\n----- first: -------------\n");
+ printFirst(boundary, stringToExamine);
+ /*print last element*/
+ printf("\n----- last: --------------\n");
+ printLast(boundary, stringToExamine);
+ /*print word at charpos 10 */
+ printf("\n----- at pos 10: ---------\n");
+ printAt(boundary, 10 , stringToExamine);
+
+ ubrk_close(boundary);
+
+ printf("\nEnd of C boundary analysis\n");
+ return 0;
+}