summaryrefslogtreecommitdiff
path: root/Build/source/libs/icu/icu-xetex/samples/citer
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/icu/icu-xetex/samples/citer')
-rw-r--r--Build/source/libs/icu/icu-xetex/samples/citer/Makefile22
-rw-r--r--Build/source/libs/icu/icu-xetex/samples/citer/citer.cpp195
-rw-r--r--Build/source/libs/icu/icu-xetex/samples/citer/citer.vcproj208
-rw-r--r--Build/source/libs/icu/icu-xetex/samples/citer/readme.txt59
4 files changed, 484 insertions, 0 deletions
diff --git a/Build/source/libs/icu/icu-xetex/samples/citer/Makefile b/Build/source/libs/icu/icu-xetex/samples/citer/Makefile
new file mode 100644
index 00000000000..712272a131f
--- /dev/null
+++ b/Build/source/libs/icu/icu-xetex/samples/citer/Makefile
@@ -0,0 +1,22 @@
+# Copyright (c) 2003-2005 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
+
+# Name of your target
+TARGET=citer
+
+# All object files (C or C++)
+OBJECTS=citer.o
+
+# Load in standard makefile definitions
+include ../defs.mk
+
+LDFLAGS += $(LDFLAGS_USTDIO)
+
+# the actual rules (this is a simple sample)
+include ../rules.mk
diff --git a/Build/source/libs/icu/icu-xetex/samples/citer/citer.cpp b/Build/source/libs/icu/icu-xetex/samples/citer/citer.cpp
new file mode 100644
index 00000000000..c0be60c1bb2
--- /dev/null
+++ b/Build/source/libs/icu/icu-xetex/samples/citer/citer.cpp
@@ -0,0 +1,195 @@
+/*
+*******************************************************************************
+*
+* Copyright (C) 2002-2007, International Business Machines
+* Corporation and others. All Rights Reserved.
+*
+*******************************************************************************
+*/
+
+#include "unicode/uchriter.h"
+#include "unicode/schriter.h"
+#include "unicode/ustring.h"
+#include <stdio.h>
+#include <unicode/brkiter.h>
+#include <unicode/ustdio.h>
+#include <stdlib.h>
+
+static UFILE *out;
+
+void printUnicodeString(const UnicodeString &s)
+{
+ u_fprintf(out, "%S", s);
+}
+
+void printUChar(UChar32 ch)
+{
+ if(ch < 127) {
+ u_fprintf(out, "%C", (UChar) ch);
+ } else if (ch == CharacterIterator::DONE) {
+ u_fprintf(out, "[CharacterIterator::DONE = 0xFFFF]");
+ } else {
+ u_fprintf(out, "[%X]", ch);
+ }
+}
+
+class Test
+{
+public:
+ void TestUChariter();
+ void TestStringiter();
+};
+
+void Test::TestUChariter() {
+ const char testChars[] = "Now is the time for all good men to come "
+ "to the aid of their country.";
+
+ UnicodeString testString(testChars,"");
+ const UChar *testText = testString.getTerminatedBuffer();
+
+ UCharCharacterIterator iter(testText, u_strlen(testText));
+ UCharCharacterIterator* test2 = (UCharCharacterIterator*)iter.clone();
+
+ u_fprintf(out, "testText = %s", testChars);
+
+ if (iter != *test2 ) {
+ u_fprintf(out, "clone() or equals() failed: Two clones tested unequal\n");
+ }
+
+ UnicodeString result1, result2;
+ // getting and comparing the text within the iterators
+ iter.getText(result1);
+ test2->getText(result2);
+ if (result1 != result2) {
+ u_fprintf(out, "iter.getText() != clone.getText()\n");
+ }
+
+ u_fprintf(out, "\n");
+
+ // Demonstrates seeking forward using the iterator.
+ u_fprintf(out, "Forward = ");
+
+ UChar c = iter.first();
+ printUChar(c); // The first char
+ int32_t i = 0;
+
+ if (iter.startIndex() != 0 || iter.endIndex() != u_strlen(testText)) {
+ u_fprintf(out, "startIndex() or endIndex() failed\n");
+ }
+
+
+ // Testing forward iteration...
+ do {
+ if (c == CharacterIterator::DONE && i != u_strlen(testText)) {
+ u_fprintf(out, "Iterator reached end prematurely");
+ }
+ else if (c != testText[i]) {
+ u_fprintf(out, "Character mismatch at position %d\n" + i);
+ }
+ if (iter.current() != c) {
+ u_fprintf(out, "current() isn't working right");
+ }
+ if (iter.getIndex() != i) {
+ u_fprintf(out, "getIndex() isn't working right\n");
+ }
+ if (c != CharacterIterator::DONE) {
+ c = iter.next();
+ i++;
+ }
+
+ u_fprintf(out, "|");
+ printUChar(c);
+
+ } while (c != CharacterIterator::DONE);
+
+ delete test2;
+ u_fprintf(out, "\n");
+}
+
+
+void Test::TestStringiter() {
+ const char testChars[] = "Now is the time for all good men to come "
+ "to the aid of their country.";
+
+ UnicodeString testString(testChars,"");
+ const UChar *testText = testString.getTerminatedBuffer();
+
+ StringCharacterIterator iter(testText, u_strlen(testText));
+ StringCharacterIterator* test2 = (StringCharacterIterator*)iter.clone();
+
+ if (iter != *test2 ) {
+ u_fprintf(out, "clone() or equals() failed: Two clones tested unequal\n");
+ }
+
+ UnicodeString result1, result2;
+ // getting and comparing the text within the iterators
+ iter.getText(result1);
+ test2->getText(result2);
+ if (result1 != result2) {
+ u_fprintf(out, "getText() failed\n");
+ }
+
+ u_fprintf(out, "Backwards: ");
+
+ UChar c = iter.last();
+ int32_t i = iter.endIndex();
+
+ printUChar(c);
+ i--; // already printed out the last char
+
+ if (iter.startIndex() != 0 || iter.endIndex() != u_strlen(testText)) {
+ u_fprintf(out, "startIndex() or endIndex() failed\n");
+ }
+
+ // Testing backward iteration over a range...
+ do {
+ if (c == CharacterIterator::DONE) {
+ u_fprintf(out, "Iterator reached end prematurely\n");
+ }
+ else if (c != testText[i]) {
+ u_fprintf(out, "Character mismatch at position %d\n", i);
+ }
+ if (iter.current() != c) {
+ u_fprintf(out, "current() isn't working right\n");
+ }
+ if (iter.getIndex() != i) {
+ u_fprintf(out, "getIndex() isn't working right [%d should be %d]\n", iter.getIndex(), i);
+ }
+ if (c != CharacterIterator::DONE) {
+ c = iter.previous();
+ i--;
+ }
+
+ u_fprintf(out, "|");
+ printUChar(c);
+ } while (c != CharacterIterator::DONE);
+
+ u_fprintf(out, "\n");
+ delete test2;
+}
+
+/* Creating and using text boundaries */
+int main( void )
+{
+ UErrorCode status = U_ZERO_ERROR;
+
+ out = u_finit(stdout, NULL, NULL);
+
+ u_fprintf(out, "ICU Iteration Sample Program (C++)\n\n");
+
+ Test t;
+
+ u_fprintf(out, "\n");
+ u_fprintf(out, "Test::TestUCharIter()\n");
+
+ t.TestUChariter();
+
+ u_fprintf(out, "-----\n");
+ u_fprintf(out, "Test::TestStringchariter()\n");
+
+ t.TestStringiter();
+
+ u_fprintf(out, "-----\n");
+
+ return 0;
+}
diff --git a/Build/source/libs/icu/icu-xetex/samples/citer/citer.vcproj b/Build/source/libs/icu/icu-xetex/samples/citer/citer.vcproj
new file mode 100644
index 00000000000..8eaf81e6818
--- /dev/null
+++ b/Build/source/libs/icu/icu-xetex/samples/citer/citer.vcproj
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="citer"
+ ProjectGUID="{247E2681-6C84-408B-B40C-5DB50BC5E18F}"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Debug"
+ IntermediateDirectory="Debug"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\..\include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ TreatWChar_tAsBuiltInType="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="icuucd.lib icuind.lib icuiod.lib"
+ OutputFile="./Debug/citer.exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="..\..\..\lib"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)/citer.pdb"
+ SubSystem="1"
+ TargetMachine="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="Release|Win32"
+ OutputDirectory="Release"
+ IntermediateDirectory="Release"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\..\include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE"
+ RuntimeLibrary="0"
+ TreatWChar_tAsBuiltInType="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="icuuc.lib icuin.lib icuio.lib"
+ OutputFile="./Release/citer.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="..\..\..\lib"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="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;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\citer.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Build/source/libs/icu/icu-xetex/samples/citer/readme.txt b/Build/source/libs/icu/icu-xetex/samples/citer/readme.txt
new file mode 100644
index 00000000000..6eb8cdb20aa
--- /dev/null
+++ b/Build/source/libs/icu/icu-xetex/samples/citer/readme.txt
@@ -0,0 +1,59 @@
+Copyright (c) 2003-2005, International Business Machines Corporation and others. All Rights Reserved.
+citer: Character Iteration
+
+This sample demonstrates
+ Using ICU to determine the linguistic boundaries within text
+
+
+Files:
+ citer.cpp Main source file in C++
+ citer.sln Windows MSVC workspace. Double-click this to get started.
+ citer.vcproj Windows MSVC project file
+
+To Build citer on Windows
+ 1. Install and build ICU
+ 2. In MSVC, open the workspace file icu\samples\citer\citer.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 citer directory, e.g.
+ cd c:\icu\source\samples\citer\debug
+ 4. Run it
+ citer
+
+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/citer
+ gmake ICU_PREFIX=<icu install directory)
+
+ To Run on Unixes
+ cd <icu directory>/source/samples/citer
+
+ gmake ICU_PREFIX=<icu install directory> check
+ -or-
+
+ export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
+ citer
+
+
+ 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.
+