ICU-1852 sample cleanup - wave #1

X-SVN-Rev: 8470
This commit is contained in:
Steven R. Loomis 2002-04-15 23:32:30 +00:00
parent 6de3b3b4c4
commit b9b412cd6c
33 changed files with 663 additions and 113 deletions

4
.gitignore vendored
View File

@ -138,13 +138,13 @@ icu4c/source/samples/cal/*.pdb
icu4c/source/samples/cal/Debug
icu4c/source/samples/cal/Makefile
icu4c/source/samples/cal/Release
icu4c/source/samples/cal/cal
icu4c/source/samples/cal/icucal
icu4c/source/samples/date/*.d
icu4c/source/samples/date/*.pdb
icu4c/source/samples/date/Debug
icu4c/source/samples/date/Makefile
icu4c/source/samples/date/Release
icu4c/source/samples/date/date
icu4c/source/samples/date/icudate
icu4c/source/samples/layout/Makefile
icu4c/source/stubdata/*.ao
icu4c/source/stubdata/*.d

View File

@ -3,4 +3,4 @@ Release
Makefile
*.d
*.pdb
cal
icucal

View File

@ -20,7 +20,7 @@ subdir = samples/cal
CLEANFILES = *~ $(DEPS)
## Target information
TARGET = cal
TARGET = icucal
ENABLE_STATIC = @ENABLE_STATIC@
@ -74,6 +74,7 @@ distclean-local: clean-local
$(RMV) Makefile
check-local:
-$(INVOKE) $(TARGET)
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \

View File

@ -124,7 +124,7 @@ main(int argc,
/* Make sure the month value is legal */
if(month < 0 || month > 12) {
printf("cal: Bad value for month -- %d\n", month);
printf("icucal: Bad value for month -- %d\n", month);
/* Display usage */
printUsage = 1;
@ -164,7 +164,7 @@ main(int argc,
static void
usage()
{
puts("Usage: cal [OPTIONS] [[MONTH] YEAR]");
puts("Usage: icucal [OPTIONS] [[MONTH] YEAR]");
puts("");
puts("Options:");
puts(" -h, --help Print this message and exit.");
@ -182,10 +182,9 @@ usage()
static void
version()
{
printf("cal version %s (ICU version %s), created by Stephen F. Booth.\n",
printf("icucal version %s (ICU version %s), created by Stephen F. Booth.\n",
CAL_VERSION, U_ICU_VERSION);
puts("Copyright (C) 1998-2000 International Business Machines Corporation and others.");
puts("All Rights Reserved.");
puts(U_COPYRIGHT_STRING);
}
static void

View File

@ -0,0 +1,57 @@
icucal: a sample program which displays the calendar.
This sample demonstrates
Formatting a calendar
Outputting text in the default codepage to the console
Files:
cal.c Main source file
uprint.h codepage output convenience header
uprint.h codepage output convenience implementation
cal.dsw Windows MSVC workspace. Double-click this to get started.
cal.dsp Windows MSVC project file
To Build icucal on Windows
1. Install and build ICU
2. In MSVC, open the workspace file icu\samples\cal\cal.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 cal directory, e.g.
cd c:\icu\source\samples\cal\debug
4. Run it
cal
To Build on Unixes
1. Build ICU. icucal is built automatically by default unless samples are turned off.
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
To Run on Unixes
cd <icu directory>/source/samples/cal
gmake check
-or-
export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
cal
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.

View File

@ -3,4 +3,4 @@ Release
Makefile
*.d
*.pdb
date
icudate

View File

@ -20,7 +20,7 @@ subdir = samples/date
CLEANFILES = *~ $(DEPS)
## Target information
TARGET = date
TARGET = icudate
ENABLE_STATIC = @ENABLE_STATIC@
@ -74,6 +74,7 @@ distclean-local: clean-local
$(RMV) Makefile
check-local:
-$(INVOKE) $(TARGET)
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \

View File

@ -95,7 +95,7 @@ main(int argc,
}
/* unrecognized option */
else if(strncmp(arg, "-", strlen("-")) == 0) {
printf("date: invalid option -- %s\n", arg+1);
printf("icudate: invalid option -- %s\n", arg+1);
printUsage = 1;
}
/* done with options, display date */
@ -127,7 +127,7 @@ main(int argc,
static void
usage()
{
puts("Usage: date [OPTIONS]");
puts("Usage: icudate [OPTIONS]");
puts("Options:");
puts(" -h, --help Print this message and exit.");
puts(" -v, --version Print the version number of date and exit.");
@ -142,10 +142,9 @@ usage()
static void
version()
{
printf("date version %s (ICU version %s), created by Stephen F. Booth.\n",
printf("icudate version %s (ICU version %s), created by Stephen F. Booth.\n",
DATE_VERSION, U_ICU_VERSION);
puts("Copyright (C) 1998-2000 International Business Machines Corporation and others.");
puts("All Rights Reserved.");
puts(U_COPYRIGHT_STRING);
}
/* Format the date */

View File

@ -0,0 +1,57 @@
icudate: a sample program which displays the current date
This sample demonstrates
Formatting a date
Outputting text in the default codepage to the console
Files:
date.c Main source file
uprint.h codepage output convenience header
uprint.h codepage output convenience implementation
date.dsw Windows MSVC workspace. Double-click this to get started.
date.dsp Windows MSVC project file
To Build icudate on Windows
1. Install and build ICU
2. In MSVC, open the workspace file icu\samples\date\date.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 icudate directory, e.g.
cd c:\icu\source\samples\date\debug
4. Run it
date
To Build on Unixes
1. Build ICU. icudate is built automatically by default unless samples are turned off.
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
To Run on Unixes
cd <icu directory>/source/samples/date
gmake check
-or-
export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
date
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.

View File

@ -50,7 +50,7 @@ $(TARGET): $(OBJECTS)
# Make check: simply runs the sample, logged to a file
check: $(TARGET)
$(TARGET) | tee $(TARGET).out
$(INVOKE) ./$(TARGET) | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report
@ -59,7 +59,7 @@ $(TARGET).report: check $(TARGET).cpp
more $(TARGET).cpp $(TARGET).out > $@
$(ICU_INC):
@echo "Please read the directions at the top of this file (Makefile)"
@echo "Please read the directions at the top of this file (Makefile) and the README"
@echo "Can't open $(ICU_INC)"
@false

View File

@ -1,4 +1,6 @@
This is an exercise for the ICU Workshop (September 2000).
** Workshop homepage is:
http://oss.software.ibm.com/icu/docs/workshop_2000/agenda.html
Day 2: September 12th 2000
Pre-requsit:
@ -21,24 +23,18 @@ This is an exercise for the ICU Workshop (September 2000).
INSTRUCTIONS
------------
This exercise was developed and tested on ICU release 1.6.0, Win32,
This exercise was first developed and tested on ICU release 1.6.0, Win32,
Microsoft Visual C++ 6.0. It should work on other ICU releases and
other platforms as well.
To install: Create a folder "datefmt" at:
<icu>/source/samples/datefmt
Within it, place the files:
datefmt.dsp
datefmt.dsw
main.cpp
util.cpp
util.h
Open the file "datefmt.dsw" in Microsoft Visual C++.
MSVC:
Open the file "datefmt.dsw" in Microsoft Visual C++.
Unix:
- Build and install ICU with a prefix, for example '--prefix=/home/srl/ICU'
- Set the variable ICU_PREFIX=/home/srl/ICU and use GNU make in
this directory.
- You may use 'make check' to invoke this sample.
PROBLEMS
--------

View File

@ -1,5 +1,5 @@
# Copyright (c) 2001 IBM, Inc. and others
# conversion sample code $Revision: 1.1 $
# conversion sample code $Revision: 1.2 $
# Usage:
@ -8,26 +8,23 @@
#
# - do 'make install' of icu
#
# - change the following line to point to the $(prefix) that
# was used (will look for $(prefix)/lib/icu/Makefile.inc )
# OR
# set the variable ICU_PREFIX to point at $(prefix)
# - set the variable ICU_PREFIX to point at $(prefix)
# (will look for $(prefix)/lib/icu/Makefile.inc )
#
# - set the variable ICU_LEGACY (read the README)
# ( Will look for ICU_LEGACY/include/unicode/ucol.h )
#
# - do 'make' in this directory
ICU_PREFIX=/home/weiv/build/current
ICU_LEGACY = /home/weiv/build/icu-1-8-1
#ICU_PREFIX=/home/weiv/build/current
#ICU_LEGACY = /home/weiv/build/icu-1-8-1
LEGACY_INCLUDE = $(ICU_LEGACY)/include
ifeq ($(strip $(ICU_PREFIX)),)
ICU_INC=$(ICU_DEFAULT_PREFIX)/lib/icu/Makefile.inc
else
ICU_INC=$(ICU_PREFIX)/lib/icu/Makefile.inc
endif
ICU_INC=$(ICU_PREFIX)/lib/icu/Makefile.inc
ICUPATH=
include $(ICU_INC)
-include $(ICU_INC)
# Name of your target
TARGET=legacy
@ -42,12 +39,11 @@ DEPS=$(OBJECTS:.o=.d)
# turn on super warnings
#CPPFLAGS += -Wall
all: $(TARGET)
all: $(TARGET) $(ICU_INC)
.PHONY: all clean distclean check report
oldcol.o : oldcol.cpp
oldcol.o : oldcol.cpp $(LEGACY_INCLUDE)/unicode/ucol.h
$(CXX) -I$(LEGACY_INCLUDE) $(DEFS) $(CPPFLAGS) $(CXXFLAGS) -c oldcol.cpp
distclean clean:
@ -62,7 +58,7 @@ $(TARGET): $(OBJECTS)
# Make check: simply runs the sample, logged to a file
check: $(TARGET)
$(TARGET) | tee $(TARGET).out
$(INVOKE) ./$(TARGET) | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report
@ -71,10 +67,19 @@ $(TARGET).report: check $(TARGET).cpp
more $(TARGET).cpp $(TARGET).out > $@
$(ICU_INC):
@echo ICU_PREFIX variable is not set correctly
@echo "Please read the directions at the top of this file (Makefile)"
@echo "And the README"
@echo "Can't open $(ICU_INC)"
@false
$(LEGACY_INCLUDE)/unicode/ucol.h:
@echo ICU_LEGACY variable is not set correctly.
@echo "Please read the directions at the top of this file (Makefile)"
@echo "And the README"
@echo "Can't open $@"
@false
ifneq ($(MAKECMDGOALS),distclean)
-include $(DEPS)
endif

View File

@ -14,7 +14,10 @@ In order to make the compilation unit use old version of ICU, you have to do a c
Building and running of the example:
Linux:
To make it work, you should build and install both the current ICU and ICU 1.8.1. Put both data libraries to wherever ICU_DATA points (usually it is $(prefix)/share/icu/$(icu_version)/). Copy libicuuc.so.18* and libicui18n.so.18* to $(prefix)/lib directory, together with current libraries).
To make it work, you should build and install both the current ICU and ICU 1.8.1. Put both data libraries to wherever ICU_DATA points (usually it is $(prefix)/share/icu/$(icu_version)/). If data libraries are used, then check for $(prefix)/lib/icu/1.8.1 which should contain libicudata.so and libicudt18*.so
2. Copy libicuuc.so.18* and libicui18n.so.18* to $(prefix)/lib directory, together with current libraries).
3. Should work on other Unixes.
Change $ICU_PREFIX to point to the current installation, and $ICU_LEGACY to point to 1.8.1 installation. $ICU_LEGACY is needed solely to access the 1.8.1 include directory through $LEGACY_INCLUDE variable, so if you want to move the 1.8.1. include directory, you can set $LEGACY_INCLUDE directly to that directory.
@ -34,3 +37,4 @@ Sample won't link: The path for 1.8.1. libraries is broken. Edit it so that it
Linker says: "Undefined symbol u_getVersion()" (or something similar): path to 1.8.1. libraries is bad.
Linker says: "Undefined symbol u_getVersion()_X_Y" (or something similar): path to current libraries is bad.
Legacy crashes horribly: Sorry, didn't put any error checking. If legacy crashes that's most probably because it cannot find the data libraries. You can see which data library is not found by the part of the program that is running. Make sure program can find tha data library either by putting it where ever ICU_DATA points to OR by putting the DLL version of the data library somewhere on your PATH.

View File

@ -57,10 +57,25 @@ int compare_legacy(const void *string1, const void *string2) {
void initCollator_legacy(const char *locale) {
UErrorCode status = U_ZERO_ERROR;
compareCollator = ucol_open(locale, &status);
if(U_FAILURE(status))
{
fprintf(stderr, "initCollator_legacy(%s): error opening collator, %s!\n", locale, u_errorName(status));
fprintf(stderr, "Note: ICU data directory is %s\n", u_getDataDirectory());
fprintf(stderr, "Read the README!\n");
exit(0);
}
}
void closeCollator_legacy(void) {
ucol_close(compareCollator);
if(compareCollator != NULL)
{
ucol_close(compareCollator);
}
else
{
fprintf(stderr, "closeCollator_legacy(): collator was already NULL!\n");
}
compareCollator = NULL;
}

View File

@ -7,7 +7,7 @@
# - do 'make install' of icu
#
# - change the following line to point to the $(prefix) that
# was used (will look for $(prefix)/lib/icu/Makefile.inc )
# was used (will look for $(prefix)/share/icu/Makefile.inc )
# OR
# set the variable ICU_PREFIX to point at $(prefix)
#
@ -50,7 +50,7 @@ $(TARGET): $(OBJECTS)
# Make check: simply runs the sample, logged to a file
check: $(TARGET)
$(TARGET) | tee $(TARGET).out
$(INVOKE) ./$(TARGET) | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report
@ -59,7 +59,7 @@ $(TARGET).report: check $(TARGET).cpp
more $(TARGET).cpp $(TARGET).out > $@
$(ICU_INC):
@echo "Please read the directions at the top of this file (Makefile)"
@echo "Please read the directions at the top of this file (Makefile) and the README"
@echo "Can't open $(ICU_INC)"
@false

View File

@ -1,7 +1,9 @@
This is an exercise for the ICU Workshop (September 2000).
http://oss.software.ibm.com/icu/docs/workshop_2000/agenda.html
Day 2: September 12th 2000
Pre-requsit:
Pre-requisites:
1. All the hardware and software requirements from Day 1.
2. Attended or fully understand Day 1 material.
3. Read through the ICU user's guide at
@ -21,24 +23,19 @@ This is an exercise for the ICU Workshop (September 2000).
INSTRUCTIONS
------------
This exercise was developed and tested on ICU release 1.6.0, Win32,
This exercise was first developed and tested on ICU release 1.6.0, Win32,
Microsoft Visual C++ 6.0. It should work on other ICU releases and
other platforms as well.
To install: Create a folder "datefmt" at:
<icu>/source/samples/msgfmt
Within it, place the files:
msgfmt.dsp
msgfmt.dsw
main.cpp
util.cpp
util.h
Open the file "msgfmt.dsw" in Microsoft Visual C++.
MSVC:
Open the file "msgfmt.dsw" in Microsoft Visual C++.
Unix:
- Build and install ICU with a prefix, for example '--prefix=/home/srl/ICU'
- Set the variable ICU_PREFIX=/home/srl/ICU and use GNU make in
this directory.
- You may use 'make check' to invoke this sample.
PROBLEMS
--------

View File

@ -50,7 +50,7 @@ $(TARGET): $(OBJECTS)
# Make check: simply runs the sample, logged to a file
check: $(TARGET)
$(INVOKE) $(TARGET) | tee $(TARGET).out
$(INVOKE) ./$(TARGET) | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report

View File

@ -29,7 +29,7 @@ To Run on Windows
numfmt
To Build on Unixes
1. Build ICU. numfmt is built automatically by default unless samples are turned off.
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:
@ -53,7 +53,6 @@ To Build on Unixes
export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
numfmt
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

View File

@ -0,0 +1,68 @@
# Copyright (c) 2000 IBM, Inc. and others
# Usage:
# - configure and build ICU [see the docs] .. use "--prefix=" something
# (I used --prefix=/home/srl/III )
#
# - do 'make install' of icu
#
# - change the following line to point to the $(prefix) that
# was used (will look for $(prefix)/share/icu/Makefile.inc )
# OR
# set the variable ICU_PREFIX to point at $(prefix)
#
# - do 'make' in this directory
ICU_DEFAULT_PREFIX=~/icu
ifeq ($(strip $(ICU_PREFIX)),)
ICU_INC=$(ICU_DEFAULT_PREFIX)/lib/icu/Makefile.inc
else
ICU_INC=$(ICU_PREFIX)/lib/icu/Makefile.inc
endif
ICUPATH=
include $(ICU_INC)
# Name of your target
TARGET=props
# All object files (C or C++)
OBJECTS=props.o
CLEANFILES=*~ $(TARGET).out
DEPS=$(OBJECTS:.o=.d)
all: $(TARGET)
.PHONY: all clean distclean check report
distclean clean:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
-$(RMV) $(OBJECTS) $(TARGET)
-$(RMV) $(DEPS)
# Can change this to LINK.c if it is a C only program
# Can add more libraries here.
$(TARGET): $(OBJECTS)
$(LINK.cc) -o $@ $^ $(ICULIBS)
# Make check: simply runs the sample, logged to a file
check: $(TARGET)
$(INVOKE) ./$(TARGET) | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report
$(TARGET).report: check $(TARGET).cpp
more $(TARGET).cpp $(TARGET).out > $@
$(ICU_INC):
@echo "Please read the directions at the top of this file (Makefile) and the README"
@echo "Can't open $(ICU_INC)"
@false
ifneq ($(MAKECMDGOALS),distclean)
-include $(DEPS)
endif

View File

@ -51,7 +51,7 @@ extern int
main(int argc, const char *argv[]) {
static const UChar32
codePoints[]={
0xd, 0x20, 0x2d, 0x35, 0x65, 0x284, 0x665, 0x5678, 0x23456, 0x10fffd
0xd, 0x20, 0x2d, 0x35, 0x65, 0x284, 0x665, 0x5678, 0x23456, 0x10317, 0x1D01F, 0x10fffd
};
int i;

View File

@ -0,0 +1,58 @@
props: Unicode Character Properties
This sample demonstrates
Using ICU to determine the properties of Unicode characters
Files:
props.cpp Main source file in C++
props.dsw Windows MSVC workspace. Double-click this to get started.
props.dsp Windows MSVC project file
To Build props on Windows
1. Install and build ICU
2. In MSVC, open the workspace file icu\samples\props\props.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 props directory, e.g.
cd c:\icu\source\samples\props\debug
4. Run it
props
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/props
gmake ICU_PREFIX=<icu install directory)
To Run on Unixes
cd <icu directory>/source/samples/props
gmake ICU_PREFIX=<icu install directory> check
-or-
export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
props
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.

View File

@ -0,0 +1,45 @@
## Copyright (c) 2002, International Business Machines Corporation
## and others. All Rights Reserved.
This directory contains sample code
Below is a short description of the contents of this directory.
cal - prints out a calendar.
date - prints out the current date, localized.
datefmt - an exercise using the date formatting API
layout - demonstrates the ICU layout engine
legacy - demonstrates using two versions of ICU in one application
msgfmt - demonstrates the use of the Message Format
numfmt - demonstrates the use of the number format
props - demonstrates the use of Unicode properties
translit - demonstrates the use of ICU transliteration
ucnv - demonstrates the use of ICU codepage conversion
udata - demonstrates the use of ICU low level data routines
ufortune - demonstrates packaging and use of resources in an application
uresb - demonstrates building and loading resource bundles
ustring - demonstrates ICU string manipulation functions
==
* Where can I find more sample code?
- The "uconv" utility is a full-featured command line application.
It is normally built with ICU, and is located in icu/source/extra/uconv
- The "icuapps" CVS module contains other applications and libraries not
included with ICU. You can check it out from the CVS command line
by using for example, "cvs co icuapps" instead of "cvs co icu",
or through WebCVS at http://oss.software.ibm.com/cvs/icu/icuapps/

View File

@ -29,6 +29,7 @@ TARGET=translit
# All object files (C or C++)
OBJECTS=main.o util.o
# You can simply add 'unaccent.o' to the above line for example.
CLEANFILES=*~ $(TARGET).out
@ -50,7 +51,7 @@ $(TARGET): $(OBJECTS)
# Make check: simply runs the sample, logged to a file
check: $(TARGET)
$(TARGET) | tee $(TARGET).out
$(INVOKE) ./$(TARGET) | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report

View File

@ -1,4 +1,5 @@
This is an exercise for the ICU Workshop (September 2000).
http://oss.software.ibm.com/icu/docs/workshop_2000/agenda.html
Day 2: September 12th 2000
Pre-requisite:
@ -25,19 +26,14 @@ This exercise was developed and tested on ICU release 1.6.0, Win32,
Microsoft Visual C++ 6.0. It should work on other ICU releases and
other platforms as well.
To install: Create a folder "translit" at:
MSVC:
Open the file "translit.dsw" in Microsoft Visual C++.
<icu>/source/samples/translit
Within it, place the files:
translit.dsp
translit.dsw
main.cpp
util.cpp
util.h
Open the file "translit.dsw" in Microsoft Visual C++.
Unix:
- Build and install ICU with a prefix, for example '--prefix=/home/srl/ICU'
- Set the variable ICU_PREFIX=/home/srl/ICU and use GNU make in
this directory.
- You may use 'make check' to invoke this sample.
PROBLEMS

View File

@ -1,5 +1,5 @@
# Copyright (c) 2000 IBM, Inc. and others
# conversion sample code $Revision: 1.4 $
# conversion sample code $Revision: 1.5 $
# Usage:
@ -56,7 +56,7 @@ $(TARGET): $(OBJECTS)
# Make check: simply runs the sample, logged to a file
check: $(TARGET)
$(TARGET) | tee $(TARGET).out
$(INVOKE) ./$(TARGET) | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report

View File

@ -0,0 +1,62 @@
convsamp: a sample program which demonstrates using ICU conversion
This sample demonstrates
Opening and closing converters using the C and C++ api
String manipulation in C and C++
Writing a custom conversion callback function
Files:
convsamp.c Main source file
flagcb.h codepage output convenience header
flagcb.c codepage output convenience implementation
ucnv.dsw Windows MSVC workspace. Double-click this to get started.
ucnv.dsp Windows MSVC project file
To Build ucnv on Windows
1. Install and build ICU
2. In MSVC, open the workspace file icu\samples\ucnv\ucnv.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 ufortune directory, e.g.
cd c:\icu\source\samples\ucnv\debug
4. Run it
ucnv
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. Build
set the variable ICU_PREFIX=<icu install>
gmake all
To Run on Unixes
cd <icu directory>/source/samples/ucnv
gmake check
-or-
export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
convsamp
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.

View File

@ -1,5 +1,5 @@
# Copyright (c) 2000 IBM, Inc. and others
# udata sample code $Revision: 1.2 $
# udata sample code $Revision: 1.3 $
# Usage:
@ -9,7 +9,7 @@
# - do 'make install' of icu
#
# - change ICU_DEFAULT_PREFIX line to point to the $(prefix) that
# was used (will look for $(prefix)/share/icu/Makefile.inc )
# was used (will look for $(prefix)/lib/icu/Makefile.inc )
# OR
# set the variable ICU_PREFIX to point at $(prefix)
#
@ -21,12 +21,12 @@
# - do 'make' in this directory
ICU_DEFAULT_PREFIX=/home/srl/II
ICU_DEFAULT_PATH=~/icu
ICU_DEFAULT_PATH=$(HOME)/icu
ifeq ($(strip $(ICU_PREFIX)),)
ICU_INC=$(ICU_DEFAULT_PREFIX)/share/icu/Makefile.inc
ICU_INC=$(ICU_DEFAULT_PREFIX)/lib/icu/Makefile.inc
else
ICU_INC=$(ICU_PREFIX)/share/icu/Makefile.inc
ICU_INC=$(ICU_PREFIX)/lib/icu/Makefile.inc
endif
@ -49,16 +49,20 @@ CLEANFILES=*~ $(TARGET).out
DEPS=$(OBJECTS:.o=.d)
all: $(ICU_PATH)/source/tools/toolutil/uoptions.h $(TARGET1) $(TARGET2)
all: $(TARGET1) $(TARGET2)
writer.o: $(ICU_PATH)/source/tools/toolutil/uoptions.h
$(ICU_PATH)/source/tools/toolutil/uoptions.h:
@echo "Please read the directions at the top of this file (Makefile)"
@echo "Can't open $@ - check ICU_PATH"
@echo
@echo "*** Please read the directions at the top of this file (Makefile)"
@echo "*** Can't open $@ - check ICU_PATH"
@echo
@false
# Only the writer needs these, actually.
CPPFLAGS += -I$(ICU_PATH)/source/tools/toolutil
LDFLAGS += -L$(ICU_PATH)/source/tools/toolutil -licu-toolutil
#LDFLAGS += -L$(ICU_PATH)/source/tools/toolutil -licu-toolutil
.PHONY: all clean distclean check report
@ -78,8 +82,8 @@ $(TARGET2): $(OBJECTS2)
# Make check: simply runs the sample, logged to a file
check: $(TARGET1) $(TARGET2)
$(TARGET1) | tee $(TARGET1).out
$(TARGET2) | tee $(TARGET2).out
$(INVOKE) ./$(TARGET2) | tee $(TARGET2).out
$(INVOKE) ./$(TARGET1) | tee $(TARGET1).out
$(ICU_INC):
@echo "Please read the directions at the top of this file (Makefile)"

View File

@ -0,0 +1,60 @@
udata: Low level ICU data
This sample demonstrates
Using the low level ICU data handling interfaces (udata) to create
and later access user data.
Files:
writer.c C source for Writer application, will generate data file to be read by Reader.
reader.c C source for Reader application, will read file created by Writer
udata.dsw Windows MSVC workspace. Double-click this to get started.
udata.dsp Windows MSVC project file
To Build udata on Windows
1. Install and build ICU
2. In MSVC, open the workspace file icu\samples\udata\udata.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 udata directory, e.g.
cd c:\icu\source\samples\udata\debug
4. Run it
writer
reader
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
You will need to set ICU_PATH to the location of your ICU source tree, for example ICU_PATH=/home/srl/icu (containing source, etc.)
cd <icu directory>/source/samples/udata
gmake ICU_PATH=<icu source directory> ICU_PREFIX=<icu install directory)
To Run on Unixes
cd <icu directory>/source/samples/udata
gmake ICU_PREFIX=<icu install directory> check
-or-
export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
writer
reader
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.

View File

@ -49,7 +49,7 @@ all: subdirs $(TARGET)
.PHONY: all clean distclean check report subdirs $(SUBDIRS)
subdirs: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@
@ -66,7 +66,7 @@ $(TARGET): $(OBJECTS)
# Make check: simply runs the sample, logged to a file
check: $(TARGET)
$(UFINVOKE) $(TARGET) | tee $(TARGET).out
$(UFINVOKE) ./$(TARGET) | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report

View File

@ -1,5 +1,5 @@
# Copyright (c) 2000 IBM, Inc. and others
# conversion sample code $Revision: 1.4 $
# conversion sample code $Revision: 1.5 $
# Usage:
@ -20,8 +20,8 @@
#
# - do 'make' in this directory
ICU_DEFAULT_PREFIX=/home/weiv/build/workshop
ICU_DEFAULT_PATH=/home/weiv/dev/icu
ICU_DEFAULT_PREFIX=ICU_PREFIX
ICU_DEFAULT_PATH=../../..
ifeq ($(strip $(ICU_PREFIX)),)
ICU_INC=$(ICU_DEFAULT_PREFIX)/lib/icu/Makefile.inc
@ -50,7 +50,9 @@ CLEANFILES=*~ $(TARGET).out
DEPS=$(OBJECTS:.o=.d)
all: $(ICU_PATH)/source/tools/toolutil/uoptions.h $(GENRB) $(RESOURCES) $(TARGET)
all: $(GENRB) $(RESOURCES) $(TARGET)
uresb.o: $(ICU_PATH)/source/tools/toolutil/uoptions.h
$(ICU_PATH)/source/tools/toolutil/uoptions.h:
@echo "Please read the directions at the top of this file (Makefile)"
@ -74,15 +76,15 @@ distclean clean:
## resources
root.res : root.txt
#@echo "generating $@"
@echo "generating $@"
$(GENRB) $(GENRBOPT) $?
en.res : en.txt
#@echo "generating $@"
@echo "generating $@"
$(GENRB) $(GENRBOPT) $?
sr.res : sr.txt
#@echo "generating $@"
@echo "generating $@"
$(GENRB) $(GENRBOPT) -e cp1251 $?
@ -93,8 +95,8 @@ $(TARGET): $(OBJECTS)
$(LINK.cc) -o $@ $^ $(ICULIBS)
# Make check: simply runs the sample, logged to a file
check: $(TARGET)
$(TARGET) | tee $(TARGET).out
check: $(TARGET) $(RESOURCES)
$(INVOKE) ./$(TARGET) en | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report

View File

@ -0,0 +1,65 @@
uresb: Resource Bundle
This sample demonstrates
Building a resource bundle
Using ICU to print data from a resource bundle
Files:
uresb.c Main source file in C
uresb.dsw Windows MSVC workspace. Double-click this to get started.
uresb.dsp Windows MSVC project file
resources.dsp Windows project file for resources
resources.mak Windows makefile for resources
root.txt Root resource bundle
en.txt English translation
sr.txt Serbian translation (cp1251)
To Build uresb on Windows
1. Install and build ICU
2. In MSVC, open the workspace file icu\samples\uresb\uresb.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 uresb directory, e.g.
cd c:\icu\source\samples\uresb\debug
4. Run it (with a locale name, ex. english)
uresb en
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/uresb
gmake ICU_PREFIX=<icu install directory) ICU_PATH=<icu source directory>
To Run on Unixes
cd <icu directory>/source/samples/uresb
gmake ICU_PREFIX=<icu install directory> check
-or-
export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
uresb
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.

View File

@ -1,5 +1,5 @@
# Copyright (c) 2000 IBM, Inc. and others
# conversion sample code $Revision: 1.2 $
# conversion sample code $Revision: 1.3 $
# Usage:
@ -52,7 +52,7 @@ $(TARGET): $(OBJECTS)
# Make check: simply runs the sample, logged to a file
check: $(TARGET)
$(TARGET) | tee $(TARGET).out
$(INVOKE) ./$(TARGET) | tee $(TARGET).out
# Make report: creates a 'report file' with both source and sample run
report: $(TARGET).report

View File

@ -0,0 +1,59 @@
ustring: Unicode String Manipulation
This sample demonstrates
Using ICU to manipulate UnicodeString objects
Files:
ustring.cpp Main source file in C++
ustring.dsw Windows MSVC workspace. Double-click this to get started.
ustring.dsp Windows MSVC project file
To Build ustring on Windows
1. Install and build ICU
2. In MSVC, open the workspace file icu\samples\ustring\ustring.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 ustring directory, e.g.
cd c:\icu\source\samples\ustring\debug
4. Run it
ustring
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/ustring
gmake ICU_PREFIX=<icu install directory)
To Run on Unixes
cd <icu directory>/source/samples/ustring
gmake ICU_PREFIX=<icu install directory> check
-or-
export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
ustring
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.