ICU-4466 update samples for ICU 3.3

X-SVN-Rev: 17432
This commit is contained in:
Eric Mader 2005-03-31 19:19:21 +00:00
parent d0f1a428a7
commit 5997f5c628
7 changed files with 310 additions and 152 deletions

View File

@ -83,6 +83,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "writer", "..\udata\writer.v
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "citer", "..\citer\citer.vcproj", "{247E2681-6C84-408B-B40C-5DB50BC5E18F}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global Global
GlobalSection(SolutionConfiguration) = preSolution GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug Debug = Debug
@ -173,6 +177,10 @@ Global
{45D0BE49-661A-41A5-AD81-986655688801}.Debug.Build.0 = Debug|Win32 {45D0BE49-661A-41A5-AD81-986655688801}.Debug.Build.0 = Debug|Win32
{45D0BE49-661A-41A5-AD81-986655688801}.Release.ActiveCfg = Release|Win32 {45D0BE49-661A-41A5-AD81-986655688801}.Release.ActiveCfg = Release|Win32
{45D0BE49-661A-41A5-AD81-986655688801}.Release.Build.0 = Release|Win32 {45D0BE49-661A-41A5-AD81-986655688801}.Release.Build.0 = Release|Win32
{247E2681-6C84-408B-B40C-5DB50BC5E18F}.Debug.ActiveCfg = Debug|Win32
{247E2681-6C84-408B-B40C-5DB50BC5E18F}.Debug.Build.0 = Debug|Win32
{247E2681-6C84-408B-B40C-5DB50BC5E18F}.Release.ActiveCfg = Release|Win32
{247E2681-6C84-408B-B40C-5DB50BC5E18F}.Release.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection EndGlobalSection

View File

@ -1,7 +1,7 @@
/* /*
******************************************************************************* *******************************************************************************
* *
* Copyright (C) 2002-2003, International Business Machines * Copyright (C) 2002-2005, International Business Machines
* Corporation and others. All Rights Reserved. * Corporation and others. All Rights Reserved.
* *
******************************************************************************* *******************************************************************************
@ -11,26 +11,25 @@
#include "unicode/schriter.h" #include "unicode/schriter.h"
#include "unicode/ustring.h" #include "unicode/ustring.h"
#include <stdio.h> #include <stdio.h>
#include <iostream.h>
#include <unicode/brkiter.h> #include <unicode/brkiter.h>
#include <unicode/ustdio.h>
#include <stdlib.h> #include <stdlib.h>
void printUnicodeString(const UnicodeString &s) { static UFILE *out;
char charBuf[1000];
s.extract(0, s.length(), charBuf, sizeof(charBuf)-1, 0); void printUnicodeString(const UnicodeString &s)
charBuf[sizeof(charBuf)-1] = 0; {
cout << charBuf; u_fprintf(out, "%S", s);
} }
void printUChar(UChar32 ch) { void printUChar(UChar32 ch)
char charBuf[1000]; {
charBuf[sizeof(charBuf)-1] = 0;
if(ch < 127) { if(ch < 127) {
cout << (char) ch; u_fprintf(out, "%C", (UChar) ch);
} else if (ch == CharacterIterator::DONE) { } else if (ch == CharacterIterator::DONE) {
cout << "[CharacterIterator::DONE = 0xFFFF]"; u_fprintf(out, "[CharacterIterator::DONE = 0xFFFF]");
} else { } else {
cout << "[" << ch << "]"; u_fprintf(out, "[%X]", ch);
} }
} }
@ -51,7 +50,7 @@ void Test::TestUChariter() {
UCharCharacterIterator iter(testText, u_strlen(testText)); UCharCharacterIterator iter(testText, u_strlen(testText));
UCharCharacterIterator* test2 = (UCharCharacterIterator*)iter.clone(); UCharCharacterIterator* test2 = (UCharCharacterIterator*)iter.clone();
cout << "testText = " << testChars; u_fprintf(out, "testText = %s", testChars);
if (iter != *test2 ) { if (iter != *test2 ) {
printf("clone() or equals() failed: Two clones tested unequal\n"); printf("clone() or equals() failed: Two clones tested unequal\n");
@ -65,9 +64,10 @@ void Test::TestUChariter() {
printf("iter.getText() != clone.getText()\n"); printf("iter.getText() != clone.getText()\n");
} }
cout << endl; u_fprintf(out, "\n");
// Demonstrates seeking forward using the iterator. // Demonstrates seeking forward using the iterator.
cout << "Forward = "; u_fprintf(out, "Forward = ");
UChar c = iter.first(); UChar c = iter.first();
printUChar(c); // The first char printUChar(c); // The first char
@ -97,13 +97,13 @@ void Test::TestUChariter() {
i++; i++;
} }
cout << "|"; u_fprintf(out, "|");
printUChar(c); printUChar(c);
} while (c != CharacterIterator::DONE); } while (c != CharacterIterator::DONE);
delete test2; delete test2;
cout << endl; u_fprintf(out, "\n");
} }
@ -129,11 +129,14 @@ void Test::TestStringiter() {
printf("getText() failed\n"); printf("getText() failed\n");
} }
cout << "Backwards: "; u_fprintf(out, "Backwards: ");
UChar c = iter.last(); UChar c = iter.last();
printUChar(c);
int32_t i = iter.endIndex(); int32_t i = iter.endIndex();
printUChar(c);
i--; // already printed out the last char i--; // already printed out the last char
if (iter.startIndex() != 0 || iter.endIndex() != u_strlen(testText)) { if (iter.startIndex() != 0 || iter.endIndex() != u_strlen(testText)) {
printf("startIndex() or endIndex() failed\n"); printf("startIndex() or endIndex() failed\n");
} }
@ -156,28 +159,37 @@ void Test::TestStringiter() {
c = iter.previous(); c = iter.previous();
i--; i--;
} }
cout << "|";
u_fprintf(out, "|");
printUChar(c); printUChar(c);
} while (c != CharacterIterator::DONE); } while (c != CharacterIterator::DONE);
cout << endl; u_fprintf(out, "\n");
delete test2; delete test2;
} }
/* Creating and using text boundaries */ /* Creating and using text boundaries */
int main( void ) int main( void )
{ {
cout << "ICU Iterator Sample Program (C++)\n\n"; UErrorCode status = U_ZERO_ERROR;
out = u_finit(stdout, NULL, NULL);
u_fprintf(out, "ICU Iteration Sample Program (C++)\n\n");
Test t; Test t;
cout << endl; u_fprintf(out, "\n");
cout << "Test::TestUCharIter()" << endl; u_fprintf(out, "Test::TestUCharIter()\n");
t.TestUChariter(); t.TestUChariter();
cout << "-----" << endl;
cout << "Test::TestStringchariter()" << endl; u_fprintf(out, "-----\n");
u_fprintf(out, "Test::TestStringchariter()\n");
t.TestStringiter(); t.TestStringiter();
cout << "-----" << endl;
u_fprintf(out, "-----\n");
return 0; return 0;
} }

View File

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="citer"
ProjectGUID="{247E2681-6C84-408B-B40C-5DB50BC5E18F}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\..\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<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="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="..\..\..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="4"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<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="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</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>

View File

@ -1,7 +1,7 @@
/* /*
******************************************************************************* *******************************************************************************
* *
* Copyright (C) 2001, International Business Machines * Copyright (C) 2001 - 2005, International Business Machines
* Corporation and others. All Rights Reserved. * Corporation and others. All Rights Reserved.
* *
******************************************************************************* *******************************************************************************
@ -22,8 +22,8 @@
#include "unicode/utypes.h" #include "unicode/utypes.h"
#include "unicode/ustring.h" #include "unicode/ustring.h"
void test_current(UChar data[][5], uint32_t size, uint32_t maxLen, uint8_t keys[][32]); extern "C" void test_current(UChar data[][5], uint32_t size, uint32_t maxLen, uint8_t keys[][32]);
void test_legacy(UChar data[][5], uint32_t size, uint32_t maxlen, uint8_t keys[][32]); extern "C" void test_legacy(UChar data[][5], uint32_t size, uint32_t maxlen, uint8_t keys[][32]);
void printZTUChar(const UChar *str) { void printZTUChar(const UChar *str) {
while(*str != 0) { while(*str != 0) {

View File

@ -1,12 +1,12 @@
Microsoft Visual Studio Solution File, Format Version 7.00 Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "legacy", "legacy.vcproj", "{57F56795-1802-4605-88A0-013AAE9998F6}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "legacy", "legacy.vcproj", "{57F56795-1802-4605-88A0-013AAE9998F6}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject EndProject
Global Global
GlobalSection(SolutionConfiguration) = preSolution GlobalSection(SolutionConfiguration) = preSolution
ConfigName.0 = Debug Debug = Debug
ConfigName.1 = Release Release = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution GlobalSection(ProjectConfiguration) = postSolution
{57F56795-1802-4605-88A0-013AAE9998F6}.Debug.ActiveCfg = Debug|Win32 {57F56795-1802-4605-88A0-013AAE9998F6}.Debug.ActiveCfg = Debug|Win32

View File

@ -1,7 +1,7 @@
/* /*
******************************************************************************* *******************************************************************************
* *
* Copyright (C) 2001, International Business Machines * Copyright (C) 2001 - 2005, International Business Machines
* Corporation and others. All Rights Reserved. * Corporation and others. All Rights Reserved.
* *
******************************************************************************* *******************************************************************************
@ -65,7 +65,7 @@ void closeCollator_current(void) {
} }
void test_current(UChar data[][5], uint32_t size, uint32_t maxlen, uint8_t keys[][32]) { extern "C" void test_current(UChar data[][5], uint32_t size, uint32_t maxlen, uint8_t keys[][32]) {
uint32_t i = 0; uint32_t i = 0;
int32_t keySize = 0; int32_t keySize = 0;
UVersionInfo uvi; UVersionInfo uvi;

View File

@ -1,7 +1,7 @@
/* /*
******************************************************************************* *******************************************************************************
* *
* Copyright (C) 2001-2004, International Business Machines * Copyright (C) 2001-2005, International Business Machines
* Corporation and others. All Rights Reserved. * Corporation and others. All Rights Reserved.
* *
******************************************************************************* *******************************************************************************
@ -81,7 +81,7 @@ void closeCollator_legacy(void) {
} }
void test_legacy(UChar data[][5], uint32_t size, uint32_t maxlen, uint8_t keys[4][32]) { extern "C" void test_legacy(UChar data[][5], uint32_t size, uint32_t maxlen, uint8_t keys[4][32]) {
uint32_t i = 0; uint32_t i = 0;
int32_t keySize = 0; int32_t keySize = 0;