[sword-cvs] icu-sword/source/samples/case Makefile,NONE,1.1 case.cpp,NONE,1.1 case.dsp,NONE,1.1 case.dsw,NONE,1.1 case.sln,NONE,1.1 case.vcproj,NONE,1.1 readme.txt,NONE,1.1 ucase.c,NONE,1.1
sword@www.crosswire.org
sword@www.crosswire.org
Tue, 9 Sep 2003 19:42:30 -0700
- Previous message: [sword-cvs] icu-sword/source/samples/break Makefile,NONE,1.1 break.cpp,NONE,1.1 break.dsp,NONE,1.1 break.dsw,NONE,1.1 break.sln,NONE,1.1 break.vcproj,NONE,1.1 readme.txt,NONE,1.1 ubreak.c,NONE,1.1
- Next message: [sword-cvs] icu-sword/source/samples/coll Makefile,NONE,1.1 coll.cpp,NONE,1.1 coll.dsp,NONE,1.1 coll.dsw,NONE,1.1 coll.sln,NONE,1.1 coll.vcproj,NONE,1.1 readme.txt,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /usr/local/cvsroot/icu-sword/source/samples/case
In directory www:/tmp/cvs-serv19862/source/samples/case
Added Files:
Makefile case.cpp case.dsp case.dsw case.sln case.vcproj
readme.txt ucase.c
Log Message:
ICU 2.6 commit
--- NEW FILE: Makefile ---
# Copyright (c) 2003 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=case
# All object files (C or C++)
OBJECTS=case.o ucase.o
#### rules
# Load in standard makefile definitions
include ../defs.mk
LDFLAGS += $(LDFLAGS_USTDIO)
# the actual rules (this is a simple sample)
include ../rules.mk
--- NEW FILE: case.cpp ---
/*
*******************************************************************************
*
* Copyright (C) 2003, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
*/
#include <unicode/unistr.h>
#include <unicode/ustdio.h>
#include <iostream.h>
#include <unicode/brkiter.h>
#include <stdlib.h>
U_CFUNC int c_main(UFILE *out);
void printUnicodeString(UFILE *out, const UnicodeString &s) {
UnicodeString other = s;
u_fprintf(out, "\"%U\"", other.getTerminatedBuffer());
}
int main( void )
{
UFILE *out;
UErrorCode status = U_ZERO_ERROR;
out = u_finit(stdout, NULL, NULL);
if(!out) {
fprintf(stderr, "Could not initialize (finit()) over stdout! \n");
return 1;
}
ucnv_setFromUCallBack(u_fgetConverter(out), UCNV_FROM_U_CALLBACK_ESCAPE,
NULL, NULL, NULL, &status);
if(U_FAILURE(status)) {
u_fprintf(out, "Warning- couldn't set the substitute callback - err %s\n", u_errorName(status));
}
/* End Demo boilerplate */
u_fprintf(out,"ICU Case Mapping Sample Program\n\n");
u_fprintf(out, "C++ Case Mapping\n\n");
UnicodeString string("This is a test");
/* lowercase = "istanbul" */
UChar lowercase[] = {0x69, 0x73, 0x74, 0x61, 0x6e, 0x62, 0x75, 0x6c, 0};
/* uppercase = "LATIN CAPITAL I WITH DOT ABOVE STANBUL" */
UChar uppercase[] = {0x0130, 0x53, 0x54, 0x41, 0x4e, 0x42, 0x55, 0x4C, 0};
UnicodeString upper(uppercase);
UnicodeString lower(lowercase);
u_fprintf(out, "\nstring: ");
printUnicodeString(out, string);
string.toUpper(); /* string = "THIS IS A TEST" */
u_fprintf(out, "\ntoUpper(): ");
printUnicodeString(out, string);
string.toLower(); /* string = "this is a test" */
u_fprintf(out, "\ntoLower(): ");
printUnicodeString(out, string);
u_fprintf(out, "\n\nlowercase=%U, uppercase=%U\n", lowercase, uppercase);
string = upper;
string.toLower(Locale("tr", "TR")); /* Turkish lower case map string =
lowercase */
u_fprintf(out, "\nupper.toLower: ");
printUnicodeString(out, string);
string = lower;
string.toUpper(Locale("tr", "TR")); /* Turkish upper case map string =
uppercase */
u_fprintf(out, "\nlower.toUpper: ");
printUnicodeString(out, string);
u_fprintf(out, "\nEnd C++ sample\n\n");
// Call the C version
int rc = c_main(out);
u_fclose(out);
return rc;
}
--- NEW FILE: case.dsp ---
# Microsoft Developer Studio Project File - Name="case" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
CFG=case - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "case.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "case.mak" CFG="case - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "case - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "case - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "case - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
# ADD LINK32 icuuc.lib icuin.lib icuio.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\lib"
!ELSEIF "$(CFG)" == "case - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I ".." /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 icuucd.lib icuind.lib icuiod.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\lib"
!ENDIF
# Begin Target
# Name "case - Win32 Release"
# Name "case - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\case.cpp
# End Source File
# Begin Source File
SOURCE=.\ucase.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project
--- NEW FILE: case.dsw ---
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "case"=.\case.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
--- NEW FILE: case.sln ---
Microsoft Visual Studio Solution File, Format Version 7.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "case", "case.vcproj", "{2316BE8C-189D-4C8B-B506-9D9EE25AC46D}"
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
ConfigName.0 = Debug
ConfigName.1 = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Debug.ActiveCfg = Debug|Win32
{2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Debug.Build.0 = Debug|Win32
{2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Release.ActiveCfg = Release|Win32
{2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal
--- NEW FILE: case.vcproj ---
<?xml version="1.0" encoding = "Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="case"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..,..\..\..\include"
PreprocessorDefinitions="WIN32,_DEBUG,_CONSOLE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Debug/case.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="icuucd.lib icuind.lib icuiod.lib"
OutputFile=".\Debug/case.exe"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Debug/case.pdb"
SubSystem="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Debug/case.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\..\include"
PreprocessorDefinitions="WIN32,NDEBUG,_CONSOLE"
StringPooling="TRUE"
RuntimeLibrary="4"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Release/case.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="icuuc.lib icuin.lib icuio.lib"
OutputFile=".\Release/case.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\..\lib"
ProgramDatabaseFile=".\Release/case.pdb"
SubSystem="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Release/case.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
</Configurations>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath=".\case.cpp">
</File>
<File
RelativePath=".\ucase.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>
--- NEW FILE: readme.txt ---
Copyright (c) 2003, International Business Machines Corporation and others. All Rights Reserved.
case: case mapping
This sample demonstrates
Using ICU to convert between different cases
Files:
case.cpp Main source file in C++
ucase.c Main source file in C
case.dsp Windows MSVC project file
To Build case on Windows
1. Install and build ICU
2. In MSVC, open the project file icu\samples\case\case.dsp
(or, use the workspace All, in icu\samples\all\all.dsw )
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 case directory, e.g.
cd c:\icu\source\samples\case\debug
4. Run it
case
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/case
gmake ICU_PREFIX=<icu install directory)
To Run on Unixes
cd <icu directory>/source/samples/case
gmake ICU_PREFIX=<icu install directory> check
-or-
export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
case
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.
--- NEW FILE: ucase.c ---
/*
*******************************************************************************
*
* Copyright (C) 2003, International Business Machines
* Corporation and others. All Rights Reserved.
*
****
*
* Case folding examples, in C
*
*******************************************************************************
*/
#include "unicode/uchar.h"
#include "unicode/ustring.h"
#include "unicode/utypes.h"
#include "unicode/ustdio.h"
/* Note: don't use 'k' or 'K' because we might be on EBCDIC */
int c_main(UFILE *out)
{
UChar32 ch;
UErrorCode errorCode = U_ZERO_ERROR;
static const UChar upper[] = {0x61, 0x42, 0x49, 0}; /* upper = "aBI" */
static const UChar lower[] = {0x61, 0x42, 0x69, 0}; /* lower = "abi" */
/* unfold = "aB LATIN SMALL LETTER DOTLESS I" */
static const UChar unfold[] = {0x61, 0x42, 0x131, 0} ;
UChar buffer[32];
const UChar char_k = 0x006b; /* 'k' */
const UChar char_K = 0x004b; /* 'K' */
int length;
printf("** C Case Mapping Sample\n");
/* uchar.h APIs, single character case mapping */
ch = u_toupper(char_k); /* ch = 'K' */
u_fprintf(out, "toupper(%K) = %K\n", char_k, ch);
ch = u_tolower(ch); /* ch = 'k' */
u_fprintf(out, "tolower() = %K\n", ch);
ch = u_totitle(char_k); /* ch = 'K' */
u_fprintf(out, "totitle(%K) = %K\n", char_k, ch);
ch = u_foldCase(char_K, U_FOLD_CASE_DEFAULT); /* ch = 'k' */
u_fprintf(out, "u_foldCase(%K, U_FOLD_CASE_DEFAULT) = %K\n", char_K, (UChar) ch);
/* ustring.h APIs, UChar * string case mapping with a Turkish locale */
/* result buffer = "ab?" latin small letter a, latin small letter b, latin
small letter dotless i */
length = u_strToLower(buffer, sizeof(buffer)/sizeof(buffer[0]), upper,
sizeof(upper)/sizeof(upper[0]), "tr", &errorCode);
if(U_FAILURE(errorCode) || buffer[length]!=0) {
u_fprintf(out, "error in u_strToLower(Turkish locale)=%ld error=%s\n", length,
u_errorName(errorCode));
}
u_fprintf(out, "u_strToLower(%U, turkish) -> %U\n", upper, buffer);
/* ustring.h APIs, UChar * string case mapping with a Engish locale */
/* result buffer = "ABI" latin CAPITAL letter A, latin capital letter B,
latin capital letter I */
length = u_strToUpper(buffer, sizeof(buffer)/sizeof(buffer[0]), upper,
sizeof(upper)/sizeof(upper[0]), "en", &errorCode);
if(U_FAILURE(errorCode) || buffer[length]!=0) {
u_fprintf(out, "error in u_strToLower(English locale)=%ld error=%s\n", length,
u_errorName(errorCode));
}
u_fprintf(out, "u_strToUpper(%U, english) -> %U\n", lower, buffer);
/* ustring.h APIs, UChar * string case folding */
/* result buffer = "abi" */
length = u_strFoldCase(buffer, sizeof(buffer)/sizeof(buffer[0]), unfold,
sizeof(unfold)/sizeof(unfold[0]), U_FOLD_CASE_DEFAULT,
&errorCode);
if(U_FAILURE(errorCode) || buffer[length]!=0) {
u_fprintf(out, "error in u_strFoldCase()=%ld error=%s\n", length,
u_errorName(errorCode));
}
u_fprintf(out, "u_strFoldCase(%U, U_FOLD_CASE_DEFAULT) -> %U\n", unfold, buffer);
u_fprintf(out, "\n** end of C sample\n");
return 0;
}
- Previous message: [sword-cvs] icu-sword/source/samples/break Makefile,NONE,1.1 break.cpp,NONE,1.1 break.dsp,NONE,1.1 break.dsw,NONE,1.1 break.sln,NONE,1.1 break.vcproj,NONE,1.1 readme.txt,NONE,1.1 ubreak.c,NONE,1.1
- Next message: [sword-cvs] icu-sword/source/samples/coll Makefile,NONE,1.1 coll.cpp,NONE,1.1 coll.dsp,NONE,1.1 coll.dsw,NONE,1.1 coll.sln,NONE,1.1 coll.vcproj,NONE,1.1 readme.txt,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]