diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2009-04-20 18:13:48 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2009-04-20 18:13:48 +0000 |
commit | e5786f530f9555469c01435f86039b06aa53feba (patch) | |
tree | c868e8d32282422d7d445b729db95c3fcdafb6d0 /Build/source/libs/icu/icu-xetex/samples | |
parent | ebaa1768b43c8606d923d2e861b5286b74207b3e (diff) |
new build system: build icu libs and xetex plus misc updates
git-svn-id: svn://tug.org/texlive/trunk@12759 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/icu/icu-xetex/samples')
217 files changed, 24421 insertions, 0 deletions
diff --git a/Build/source/libs/icu/icu-xetex/samples/Makefile.in b/Build/source/libs/icu/icu-xetex/samples/Makefile.in new file mode 100644 index 00000000000..a1d8e367b96 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/Makefile.in @@ -0,0 +1,103 @@ +## Makefile.in for ICU samples +## Copyright (c) 1999-2007, International Business Machines Corporation and +## others. All Rights Reserved. + +## Install directory information +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ + +top_builddir = .. + +include $(top_builddir)/icudefs.mk + +## Build directory information +subdir = samples + +## Platform-specific setup +include @platform_make_fragment@ + +## Files to remove for 'make clean' +CLEANFILES = *~ + +SUBDIRS = date cal +ALLSUBDIRS = break case csdet datefmt msgfmt numfmt props translit ucnv udata ufortune uresb ustring citer uciter8 + +## List of phony targets +.PHONY : all all-local all-recursive install install-local \ +install-recursive clean clean-local clean-recursive distclean \ +distclean-local distclean-recursive dist dist-recursive dist-local \ +check check-recursive check-local + +## Clear suffix list +.SUFFIXES : + +## List of standard targets +all: all-recursive all-local +install: install-recursive install-local +clean: clean-recursive clean-local +distclean : distclean-recursive distclean-local +dist: dist-recursive dist-local + +all-samples: all-samples-recursive +clean-samples: clean-samples-recursive +check-samples: check-samples-recursive + +# Note (srl 4/15/2002) do NOT recursively check samples for 2.1, look into testing them in the future. +#check: all check-recursive check-local +check: all check-local + + +## Recursive targets +all-recursive install-recursive clean-recursive distclean-recursive dist-recursive check-recursive: + @dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "$(MAKE)[$(MAKELEVEL)]: Making \`$$target' in \`$$subdir'"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-local"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $$local_target) || exit; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) "$$target-local" || exit; \ + fi + +all-samples-recursive check-samples-recursive clean-samples-recursive: + @dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + subtarget=`echo $@ | sed s/-samples-recursive//`; \ + list='$(SUBDIRS) $(ALLSUBDIRS)'; for subdir in $$list; do \ + echo "$(MAKE)[$(MAKELEVEL)]: Making \`$$subtarget' in \`$$subdir'"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$subtarget-local"; \ + else \ + local_target="$$subtarget"; \ + fi; \ + (cd $$subdir && $(MAKE) $$local_target) || exit; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) "$$subtarget-local" || exit; \ + fi + + +all-local: + +install-local: + +dist-local: + +clean-local: + test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES) + +check-local: + +distclean-local: clean-local + $(RMV) Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status diff --git a/Build/source/libs/icu/icu-xetex/samples/all/all.sln b/Build/source/libs/icu/icu-xetex/samples/all/all.sln new file mode 100644 index 00000000000..5d4c44618cd --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/all/all.sln @@ -0,0 +1,160 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "break", "..\break\break.vcproj", "{794B1E70-7661-4C4F-8083-7CFC1023DB7F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cal", "..\cal\cal.vcproj", "{F8376996-129E-4650-8F09-72E0E292EFF2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "case", "..\case\case.vcproj", "{0A81FF07-46D8-4208-932C-B788750521F3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "date", "..\date\date.vcproj", "{35392F57-D3B4-4259-A053-3A2D5B374D4C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "datefmt", "..\datefmt\datefmt.vcproj", "{D1FDD479-324A-45EE-AB27-62ED5D721854}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "layout", "..\layout\layout.vcproj", "{EE80B3B5-40F2-46F2-AC4B-FB929683515C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "legacy", "..\legacy\legacy.vcproj", "{CFD6D1D6-60E8-4A1E-9D31-3B35BB6B482A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msgfmt", "..\msgfmt\msgfmt.vcproj", "{0D62472B-CCBF-46CD-AEA1-5DACAD6D05F2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "numfmt", "..\numfmt\numfmt.vcproj", "{CF07EC2D-94A2-4107-9CAF-087150957AFC}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "props", "..\props\props.vcproj", "{94D972F4-C678-4170-A6FE-30DE6429D97E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reader", "..\udata\reader.vcproj", "{10EE4F33-B301-47DB-90C7-1082E5460F7F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "resources", "..\uresb\resources.vcproj", "{AB75D6BC-660C-4225-A601-CC40294E775E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "strsrch", "..\strsrch\strsrch.vcproj", "{A7BC6C55-74CE-43BC-A31F-6D4FC9DAD98C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translit", "..\translit\translit.vcproj", "{BDA22320-4F5F-4FFB-8C72-413B3C19631D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uciter8", "..\uciter8\uciter8.vcproj", "{30B33964-F2D9-4FEF-8D9F-D3F8F1A64B50}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ucnv", "..\ucnv\ucnv.vcproj", "{A918AE69-E876-422E-A780-6E508FBA697F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ufortune", "..\ufortune\ufortune.vcproj", "{621EF6F2-9E09-49E0-AF19-8417FE8534DF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ugrep", "..\ugrep\ugrep.vcproj", "{482D52CE-ECE9-4E25-A756-84E3A17F6B30}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uresb", "..\uresb\uresb.vcproj", "{5AD1AEF5-E13B-4411-BDD8-FF735FADAE1B}" + ProjectSection(ProjectDependencies) = postProject + {AB75D6BC-660C-4225-A601-CC40294E775E} = {AB75D6BC-660C-4225-A601-CC40294E775E} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ustring", "..\ustring\ustring.vcproj", "{3A28CC89-98B6-4E9E-B688-DF5651819759}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "writer", "..\udata\writer.vcproj", "{45D0BE49-661A-41A5-AD81-986655688801}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "citer", "..\citer\citer.vcproj", "{247E2681-6C84-408B-B40C-5DB50BC5E18F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "coll", "..\coll\coll.vcproj", "{D7209337-9F39-4BCC-AAEA-982632FD846E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "csdet", "..\csdet\csdet.vcproj", "{683745AD-3BC2-4B89-898B-93490D7F2757}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {794B1E70-7661-4C4F-8083-7CFC1023DB7F}.Debug|Win32.ActiveCfg = Debug|Win32 + {794B1E70-7661-4C4F-8083-7CFC1023DB7F}.Debug|Win32.Build.0 = Debug|Win32 + {794B1E70-7661-4C4F-8083-7CFC1023DB7F}.Release|Win32.ActiveCfg = Release|Win32 + {794B1E70-7661-4C4F-8083-7CFC1023DB7F}.Release|Win32.Build.0 = Release|Win32 + {F8376996-129E-4650-8F09-72E0E292EFF2}.Debug|Win32.ActiveCfg = Debug|Win32 + {F8376996-129E-4650-8F09-72E0E292EFF2}.Debug|Win32.Build.0 = Debug|Win32 + {F8376996-129E-4650-8F09-72E0E292EFF2}.Release|Win32.ActiveCfg = Release|Win32 + {F8376996-129E-4650-8F09-72E0E292EFF2}.Release|Win32.Build.0 = Release|Win32 + {0A81FF07-46D8-4208-932C-B788750521F3}.Debug|Win32.ActiveCfg = Debug|Win32 + {0A81FF07-46D8-4208-932C-B788750521F3}.Debug|Win32.Build.0 = Debug|Win32 + {0A81FF07-46D8-4208-932C-B788750521F3}.Release|Win32.ActiveCfg = Release|Win32 + {0A81FF07-46D8-4208-932C-B788750521F3}.Release|Win32.Build.0 = Release|Win32 + {35392F57-D3B4-4259-A053-3A2D5B374D4C}.Debug|Win32.ActiveCfg = Debug|Win32 + {35392F57-D3B4-4259-A053-3A2D5B374D4C}.Debug|Win32.Build.0 = Debug|Win32 + {35392F57-D3B4-4259-A053-3A2D5B374D4C}.Release|Win32.ActiveCfg = Release|Win32 + {35392F57-D3B4-4259-A053-3A2D5B374D4C}.Release|Win32.Build.0 = Release|Win32 + {D1FDD479-324A-45EE-AB27-62ED5D721854}.Debug|Win32.ActiveCfg = Debug|Win32 + {D1FDD479-324A-45EE-AB27-62ED5D721854}.Debug|Win32.Build.0 = Debug|Win32 + {D1FDD479-324A-45EE-AB27-62ED5D721854}.Release|Win32.ActiveCfg = Release|Win32 + {D1FDD479-324A-45EE-AB27-62ED5D721854}.Release|Win32.Build.0 = Release|Win32 + {EE80B3B5-40F2-46F2-AC4B-FB929683515C}.Debug|Win32.ActiveCfg = Debug|Win32 + {EE80B3B5-40F2-46F2-AC4B-FB929683515C}.Debug|Win32.Build.0 = Debug|Win32 + {EE80B3B5-40F2-46F2-AC4B-FB929683515C}.Release|Win32.ActiveCfg = Release|Win32 + {EE80B3B5-40F2-46F2-AC4B-FB929683515C}.Release|Win32.Build.0 = Release|Win32 + {CFD6D1D6-60E8-4A1E-9D31-3B35BB6B482A}.Debug|Win32.ActiveCfg = Debug|Win32 + {CFD6D1D6-60E8-4A1E-9D31-3B35BB6B482A}.Debug|Win32.Build.0 = Debug|Win32 + {CFD6D1D6-60E8-4A1E-9D31-3B35BB6B482A}.Release|Win32.ActiveCfg = Release|Win32 + {CFD6D1D6-60E8-4A1E-9D31-3B35BB6B482A}.Release|Win32.Build.0 = Release|Win32 + {0D62472B-CCBF-46CD-AEA1-5DACAD6D05F2}.Debug|Win32.ActiveCfg = Debug|Win32 + {0D62472B-CCBF-46CD-AEA1-5DACAD6D05F2}.Debug|Win32.Build.0 = Debug|Win32 + {0D62472B-CCBF-46CD-AEA1-5DACAD6D05F2}.Release|Win32.ActiveCfg = Release|Win32 + {0D62472B-CCBF-46CD-AEA1-5DACAD6D05F2}.Release|Win32.Build.0 = Release|Win32 + {CF07EC2D-94A2-4107-9CAF-087150957AFC}.Debug|Win32.ActiveCfg = Debug|Win32 + {CF07EC2D-94A2-4107-9CAF-087150957AFC}.Debug|Win32.Build.0 = Debug|Win32 + {CF07EC2D-94A2-4107-9CAF-087150957AFC}.Release|Win32.ActiveCfg = Release|Win32 + {CF07EC2D-94A2-4107-9CAF-087150957AFC}.Release|Win32.Build.0 = Release|Win32 + {94D972F4-C678-4170-A6FE-30DE6429D97E}.Debug|Win32.ActiveCfg = Debug|Win32 + {94D972F4-C678-4170-A6FE-30DE6429D97E}.Debug|Win32.Build.0 = Debug|Win32 + {94D972F4-C678-4170-A6FE-30DE6429D97E}.Release|Win32.ActiveCfg = Release|Win32 + {94D972F4-C678-4170-A6FE-30DE6429D97E}.Release|Win32.Build.0 = Release|Win32 + {10EE4F33-B301-47DB-90C7-1082E5460F7F}.Debug|Win32.ActiveCfg = Debug|Win32 + {10EE4F33-B301-47DB-90C7-1082E5460F7F}.Debug|Win32.Build.0 = Debug|Win32 + {10EE4F33-B301-47DB-90C7-1082E5460F7F}.Release|Win32.ActiveCfg = Release|Win32 + {10EE4F33-B301-47DB-90C7-1082E5460F7F}.Release|Win32.Build.0 = Release|Win32 + {AB75D6BC-660C-4225-A601-CC40294E775E}.Debug|Win32.ActiveCfg = Debug|Win32 + {AB75D6BC-660C-4225-A601-CC40294E775E}.Debug|Win32.Build.0 = Debug|Win32 + {AB75D6BC-660C-4225-A601-CC40294E775E}.Release|Win32.ActiveCfg = Release|Win32 + {AB75D6BC-660C-4225-A601-CC40294E775E}.Release|Win32.Build.0 = Release|Win32 + {A7BC6C55-74CE-43BC-A31F-6D4FC9DAD98C}.Debug|Win32.ActiveCfg = Debug|Win32 + {A7BC6C55-74CE-43BC-A31F-6D4FC9DAD98C}.Debug|Win32.Build.0 = Debug|Win32 + {A7BC6C55-74CE-43BC-A31F-6D4FC9DAD98C}.Release|Win32.ActiveCfg = Release|Win32 + {A7BC6C55-74CE-43BC-A31F-6D4FC9DAD98C}.Release|Win32.Build.0 = Release|Win32 + {BDA22320-4F5F-4FFB-8C72-413B3C19631D}.Debug|Win32.ActiveCfg = Debug|Win32 + {BDA22320-4F5F-4FFB-8C72-413B3C19631D}.Debug|Win32.Build.0 = Debug|Win32 + {BDA22320-4F5F-4FFB-8C72-413B3C19631D}.Release|Win32.ActiveCfg = Release|Win32 + {BDA22320-4F5F-4FFB-8C72-413B3C19631D}.Release|Win32.Build.0 = Release|Win32 + {30B33964-F2D9-4FEF-8D9F-D3F8F1A64B50}.Debug|Win32.ActiveCfg = Debug|Win32 + {30B33964-F2D9-4FEF-8D9F-D3F8F1A64B50}.Debug|Win32.Build.0 = Debug|Win32 + {30B33964-F2D9-4FEF-8D9F-D3F8F1A64B50}.Release|Win32.ActiveCfg = Release|Win32 + {30B33964-F2D9-4FEF-8D9F-D3F8F1A64B50}.Release|Win32.Build.0 = Release|Win32 + {A918AE69-E876-422E-A780-6E508FBA697F}.Debug|Win32.ActiveCfg = Debug|Win32 + {A918AE69-E876-422E-A780-6E508FBA697F}.Debug|Win32.Build.0 = Debug|Win32 + {A918AE69-E876-422E-A780-6E508FBA697F}.Release|Win32.ActiveCfg = Release|Win32 + {A918AE69-E876-422E-A780-6E508FBA697F}.Release|Win32.Build.0 = Release|Win32 + {621EF6F2-9E09-49E0-AF19-8417FE8534DF}.Debug|Win32.ActiveCfg = Debug|Win32 + {621EF6F2-9E09-49E0-AF19-8417FE8534DF}.Debug|Win32.Build.0 = Debug|Win32 + {621EF6F2-9E09-49E0-AF19-8417FE8534DF}.Release|Win32.ActiveCfg = Release|Win32 + {621EF6F2-9E09-49E0-AF19-8417FE8534DF}.Release|Win32.Build.0 = Release|Win32 + {482D52CE-ECE9-4E25-A756-84E3A17F6B30}.Debug|Win32.ActiveCfg = Debug|Win32 + {482D52CE-ECE9-4E25-A756-84E3A17F6B30}.Debug|Win32.Build.0 = Debug|Win32 + {482D52CE-ECE9-4E25-A756-84E3A17F6B30}.Release|Win32.ActiveCfg = Release|Win32 + {482D52CE-ECE9-4E25-A756-84E3A17F6B30}.Release|Win32.Build.0 = Release|Win32 + {5AD1AEF5-E13B-4411-BDD8-FF735FADAE1B}.Debug|Win32.ActiveCfg = Debug|Win32 + {5AD1AEF5-E13B-4411-BDD8-FF735FADAE1B}.Debug|Win32.Build.0 = Debug|Win32 + {5AD1AEF5-E13B-4411-BDD8-FF735FADAE1B}.Release|Win32.ActiveCfg = Release|Win32 + {5AD1AEF5-E13B-4411-BDD8-FF735FADAE1B}.Release|Win32.Build.0 = Release|Win32 + {3A28CC89-98B6-4E9E-B688-DF5651819759}.Debug|Win32.ActiveCfg = Debug|Win32 + {3A28CC89-98B6-4E9E-B688-DF5651819759}.Debug|Win32.Build.0 = Debug|Win32 + {3A28CC89-98B6-4E9E-B688-DF5651819759}.Release|Win32.ActiveCfg = Release|Win32 + {3A28CC89-98B6-4E9E-B688-DF5651819759}.Release|Win32.Build.0 = Release|Win32 + {45D0BE49-661A-41A5-AD81-986655688801}.Debug|Win32.ActiveCfg = Debug|Win32 + {45D0BE49-661A-41A5-AD81-986655688801}.Debug|Win32.Build.0 = Debug|Win32 + {45D0BE49-661A-41A5-AD81-986655688801}.Release|Win32.ActiveCfg = Release|Win32 + {45D0BE49-661A-41A5-AD81-986655688801}.Release|Win32.Build.0 = Release|Win32 + {247E2681-6C84-408B-B40C-5DB50BC5E18F}.Debug|Win32.ActiveCfg = Debug|Win32 + {247E2681-6C84-408B-B40C-5DB50BC5E18F}.Debug|Win32.Build.0 = Debug|Win32 + {247E2681-6C84-408B-B40C-5DB50BC5E18F}.Release|Win32.ActiveCfg = Release|Win32 + {247E2681-6C84-408B-B40C-5DB50BC5E18F}.Release|Win32.Build.0 = Release|Win32 + {D7209337-9F39-4BCC-AAEA-982632FD846E}.Debug|Win32.ActiveCfg = Debug|Win32 + {D7209337-9F39-4BCC-AAEA-982632FD846E}.Debug|Win32.Build.0 = Debug|Win32 + {D7209337-9F39-4BCC-AAEA-982632FD846E}.Release|Win32.ActiveCfg = Release|Win32 + {D7209337-9F39-4BCC-AAEA-982632FD846E}.Release|Win32.Build.0 = Release|Win32 + {683745AD-3BC2-4B89-898B-93490D7F2757}.Debug|Win32.ActiveCfg = Debug|Win32 + {683745AD-3BC2-4B89-898B-93490D7F2757}.Debug|Win32.Build.0 = Debug|Win32 + {683745AD-3BC2-4B89-898B-93490D7F2757}.Release|Win32.ActiveCfg = Release|Win32 + {683745AD-3BC2-4B89-898B-93490D7F2757}.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/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; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/cal/Makefile.in b/Build/source/libs/icu/icu-xetex/samples/cal/Makefile.in new file mode 100644 index 00000000000..f2e81589075 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/cal/Makefile.in @@ -0,0 +1,75 @@ +## Makefile.in for ICU - samples/cal +## Copyright (c) 1999-2004, International Business Machines Corporation and +## others. All Rights Reserved. + +## Source directory information +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ + +## Install directory information +top_builddir = ../.. + +include $(top_builddir)/icudefs.mk + +## Build directory information +subdir = samples/cal + +## Extra files to remove for 'make clean' +CLEANFILES = *~ $(DEPS) + +## Target information +TARGET = icucal$(EXEEXT) + +CPPFLAGS += -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir)/i18n +LIBS = $(LIBICUI18N) $(LIBICUUC) $(DEFAULT_LIBS) $(LIB_M) + +OBJECTS = uprint.o cal.o + +DEPS = $(OBJECTS:.o=.d) + +## List of phony targets +.PHONY : all all-local install install-local clean clean-local \ +distclean distclean-local dist dist-local check check-local + +## Clear suffix list +.SUFFIXES : + +## List of standard targets +all: all-local +install: install-local +clean: clean-local +distclean : distclean-local +dist: dist-local +check: all check-local + +all-local: $(TARGET) + +install-local: all-local + +dist-local: + +clean-local: + test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES) + $(RMV) $(OBJECTS) $(TARGET) + +distclean-local: clean-local + $(RMV) Makefile + +check-local: + -$(INVOKE) ./$(TARGET) + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +$(TARGET) : $(OBJECTS) + $(LINK.c) $(OUTOPT)$@ $^ $(LIBS) + $(POST_BUILD_STEP) + +ifeq (,$(MAKECMDGOALS)) +-include $(DEPS) +else +ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),) +-include $(DEPS) +endif +endif diff --git a/Build/source/libs/icu/icu-xetex/samples/cal/cal.c b/Build/source/libs/icu/icu-xetex/samples/cal/cal.c new file mode 100644 index 00000000000..4b6f838ec85 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/cal/cal.c @@ -0,0 +1,762 @@ +/* +********************************************************************** +* Copyright (C) 1998-2004, International Business Machines Corporation +* and others. All Rights Reserved. +********************************************************************** +* +* File date.c +* +* Modification History: +* +* Date Name Description +* 06/16/99 stephen Creation. +******************************************************************************* +*/ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include "unicode/uloc.h" +#include "unicode/udat.h" +#include "unicode/ucal.h" +#include "unicode/ustring.h" +#include "unicode/uclean.h" + +#include "uprint.h" + +#if UCONFIG_NO_FORMATTING + +int main(int argc, char **argv) +{ + printf("%s: Sorry, UCONFIG_NO_FORMATTING was turned on (see uconfig.h). No formatting can be done. \n", argv[0]); + return 0; +} +#else + + +/* Protos */ +static void usage(void); + +static void version(void); + +static void cal(int32_t month, int32_t year, + UBool useLongNames, UErrorCode *status); + +static void get_symbols(const UDateFormat *fmt, + UDateFormatSymbolType type, + UChar *array[], + int32_t arrayLength, + int32_t lowestIndex, + int32_t firstIndex, + UErrorCode *status); + +static void free_symbols(UChar *array[], + int32_t arrayLength); + +static void get_days(const UDateFormat *fmt, + UChar *days [], UBool useLongNames, + int32_t fdow, UErrorCode *status); + +static void free_days(UChar *days[]); + +static void get_months(const UDateFormat *fmt, + UChar *months [], UBool useLongNames, + UErrorCode *status); + +static void free_months(UChar *months[]); + +static void indent(int32_t count, FILE *f); + +static void print_days(UChar *days [], FILE *f, UErrorCode *status); + +static void print_month(UCalendar *c, + UChar *days [], + UBool useLongNames, int32_t fdow, + UErrorCode *status); + +static void print_year(UCalendar *c, + UChar *days [], UChar *months [], + UBool useLongNames, int32_t fdow, + UErrorCode *status); + +/* The version of cal */ +#define CAL_VERSION "1.0" + +/* Number of days in a week */ +#define DAY_COUNT 7 + +/* Number of months in a year (yes, 13) */ +#define MONTH_COUNT 13 + +/* Separation between months in year view */ +#define MARGIN_WIDTH 4 + +/* Size of stack buffers */ +#define BUF_SIZE 64 + +/* Patterm string - "MMM yyyy" */ +static const UChar sShortPat [] = { 0x004D, 0x004D, 0x004D, 0x0020, +0x0079, 0x0079, 0x0079, 0x0079 }; +/* Pattern string - "MMMM yyyy" */ +static const UChar sLongPat [] = { 0x004D, 0x004D, 0x004D, 0x004D, 0x0020, +0x0079, 0x0079, 0x0079, 0x0079 }; + + +int +main(int argc, + char **argv) +{ + int printUsage = 0; + int printVersion = 0; + UBool useLongNames = 0; + int optind = 1; + char *arg; + int32_t month = -1, year = -1; + UErrorCode status = U_ZERO_ERROR; + + + /* parse the options */ + for(optind = 1; optind < argc; ++optind) { + arg = argv[optind]; + + /* version info */ + if(strcmp(arg, "-v") == 0 || strcmp(arg, "--version") == 0) { + printVersion = 1; + } + /* usage info */ + else if(strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) { + printUsage = 1; + } + /* use long day names */ + else if(strcmp(arg, "-l") == 0 || strcmp(arg, "--long") == 0) { + useLongNames = 1; + } + /* POSIX.1 says all arguments after -- are not options */ + else if(strcmp(arg, "--") == 0) { + /* skip the -- */ + ++optind; + break; + } + /* unrecognized option */ + else if(strncmp(arg, "-", strlen("-")) == 0) { + printf("cal: invalid option -- %s\n", arg+1); + printUsage = 1; + } + /* done with options, display cal */ + else { + break; + } + } + + /* Get the month and year to display, if specified */ + if(optind != argc) { + + /* Month and year specified */ + if(argc - optind == 2) { + sscanf(argv[optind], "%d", (int*)&month); + sscanf(argv[optind + 1], "%d", (int*)&year); + + /* Make sure the month value is legal */ + if(month < 0 || month > 12) { + printf("icucal: Bad value for month -- %d\n", (int)month); + + /* Display usage */ + printUsage = 1; + } + + /* Adjust because months are 0-based */ + --month; + } + /* Only year specified */ + else { + sscanf(argv[optind], "%d", (int*)&year); + } + } + + /* print usage info */ + if(printUsage) { + usage(); + return 0; + } + + /* print version info */ + if(printVersion) { + version(); + return 0; + } + + /* print the cal */ + cal(month, year, useLongNames, &status); + + /* ICU cleanup. Deallocate any memory ICU may be holding. */ + u_cleanup(); + + return (U_FAILURE(status) ? 1 : 0); +} + +/* Usage information */ +static void +usage() +{ + puts("Usage: icucal [OPTIONS] [[MONTH] YEAR]"); + puts(""); + puts("Options:"); + puts(" -h, --help Print this message and exit."); + puts(" -v, --version Print the version number of cal and exit."); + puts(" -l, --long Use long names."); + puts(""); + puts("Arguments (optional):"); + puts(" MONTH An integer (1-12) indicating the month to display"); + puts(" YEAR An integer indicating the year to display"); + puts(""); + puts("For an interesting calendar, look at October 1582"); +} + +/* Version information */ +static void +version() +{ + printf("icucal version %s (ICU version %s), created by Stephen F. Booth.\n", + CAL_VERSION, U_ICU_VERSION); + puts(U_COPYRIGHT_STRING); +} + +static void +cal(int32_t month, + int32_t year, + UBool useLongNames, + UErrorCode *status) +{ + UCalendar *c; + UChar *days [DAY_COUNT]; + UChar *months [MONTH_COUNT]; + int32_t fdow; + + if(U_FAILURE(*status)) return; + + /* Create a new calendar */ + c = ucal_open(0, -1, uloc_getDefault(), UCAL_TRADITIONAL, status); + + /* Determine if we are printing a calendar for one month or for a year */ + + /* Print an entire year */ + if(month == -1 && year != -1) { + + /* Set the year */ + ucal_set(c, UCAL_YEAR, year); + + /* Determine the first day of the week */ + fdow = ucal_getAttribute(c, UCAL_FIRST_DAY_OF_WEEK); + + /* Print the calendar for the year */ + print_year(c, days, months, useLongNames, fdow, status); + } + + /* Print only one month */ + else { + + /* Set the month and the year, if specified */ + if(month != -1) + ucal_set(c, UCAL_MONTH, month); + if(year != -1) + ucal_set(c, UCAL_YEAR, year); + + /* Determine the first day of the week */ + fdow = ucal_getAttribute(c, UCAL_FIRST_DAY_OF_WEEK); + + /* Print the calendar for the month */ + print_month(c, days, useLongNames, fdow, status); + } + + /* Clean up */ + ucal_close(c); +} +/* + * Get a set of DateFormat symbols of a given type. + * + * lowestIndex is the index of the first symbol to fetch. + * (e.g. it will be one to fetch day names, since Sunday is + * day 1 *not* day 0.) + * + * firstIndex is the index of the symbol to place first in + * the output array. This is used when fetching day names + * in locales where the week doesn't start on Sunday. + */ +static void get_symbols(const UDateFormat *fmt, + UDateFormatSymbolType type, + UChar *array[], + int32_t arrayLength, + int32_t lowestIndex, + int32_t firstIndex, + UErrorCode *status) +{ + int32_t count, i; + + if (U_FAILURE(*status)) { + return; + } + + count = udat_countSymbols(fmt, type); + + if(count != arrayLength + lowestIndex) { + return; + } + + for(i = 0; i < arrayLength; i++) { + int32_t index = (i + firstIndex) % arrayLength; + int32_t size = 1 + udat_getSymbols(fmt, type, index + lowestIndex, NULL, 0, status); + + array[index] = (UChar *) malloc(sizeof(UChar) * size); + + *status = U_ZERO_ERROR; + udat_getSymbols(fmt, type, index + lowestIndex, array[index], size, status); + } +} + +/* Free the symbols allocated by get_symbols(). */ +static void free_symbols(UChar *array[], + int32_t arrayLength) +{ + int32_t i; + + for(i = 0; i < arrayLength; i++) { + free(array[i]); + } +} + +/* Get the day names for the specified locale, in either long or short +form. Also, reorder the days so that they are in the proper order +for the locale (not all locales begin weeks on Sunday; in France, +weeks start on Monday) */ +static void +get_days(const UDateFormat *fmt, + UChar *days [], + UBool useLongNames, + int32_t fdow, + UErrorCode *status) +{ + UDateFormatSymbolType dayType = (useLongNames ? UDAT_WEEKDAYS : UDAT_SHORT_WEEKDAYS); + + if(U_FAILURE(*status)) + return; + + /* fdow is 1-based */ + --fdow; + + get_symbols(fmt, dayType, days, DAY_COUNT, 1, fdow, status); +} + +static void free_days(UChar *days[]) +{ + free_symbols(days, DAY_COUNT); +} + +/* Get the month names for the specified locale, in either long or +short form. */ +static void +get_months(const UDateFormat *fmt, + UChar *months [], + UBool useLongNames, + UErrorCode *status) +{ + UDateFormatSymbolType monthType = (useLongNames ? UDAT_MONTHS : UDAT_SHORT_MONTHS); + + if(U_FAILURE(*status)) + return; + + get_symbols(fmt, monthType, months, MONTH_COUNT - 1, 0, 0, status); /* some locales have 13 months, no idea why */ +} + +static void free_months(UChar *months[]) +{ + free_symbols(months, MONTH_COUNT - 1); +} + +/* Indent a certain number of spaces */ +static void +indent(int32_t count, + FILE *f) +{ + char c [BUF_SIZE]; + + if(count <= 0) + { + return; + } + + if(count < BUF_SIZE) { + memset(c, (int)' ', count); + fwrite(c, sizeof(char), count, f); + } + else { + int32_t i; + for(i = 0; i < count; ++i) + putc(' ', f); + } +} + +/* Print the days */ +static void +print_days(UChar *days [], + FILE *f, + UErrorCode *status) +{ + int32_t i; + + if(U_FAILURE(*status)) return; + + /* Print the day names */ + for(i = 0; i < DAY_COUNT; ++i) { + uprint(days[i], f, status); + putc(' ', f); + } +} + +/* Print out a calendar for c's current month */ +static void +print_month(UCalendar *c, + UChar *days [], + UBool useLongNames, + int32_t fdow, + UErrorCode *status) +{ + int32_t width, pad, i, day; + int32_t lens [DAY_COUNT]; + int32_t firstday, current; + UNumberFormat *nfmt; + UDateFormat *dfmt; + UChar s [BUF_SIZE]; + const UChar *pat = (useLongNames ? sLongPat : sShortPat); + int32_t len = (useLongNames ? 9 : 8); + + if(U_FAILURE(*status)) return; + + + /* ========== Generate the header containing the month and year */ + + /* Open a formatter with a month and year only pattern */ + dfmt = udat_open(UDAT_IGNORE,UDAT_IGNORE,NULL,NULL,0,pat, len,status); + + /* Format the date */ + udat_format(dfmt, ucal_getMillis(c, status), s, BUF_SIZE, 0, status); + + + /* ========== Get the day names */ + get_days(dfmt, days, useLongNames, fdow, status); + + /* ========== Print the header */ + + /* Calculate widths for justification */ + width = 6; /* 6 spaces, 1 between each day name */ + for(i = 0; i < DAY_COUNT; ++i) { + lens[i] = u_strlen(days[i]); + width += lens[i]; + } + + /* Print the header, centered among the day names */ + pad = width - u_strlen(s); + indent(pad / 2, stdout); + uprint(s, stdout, status); + putc('\n', stdout); + + + /* ========== Print the day names */ + + print_days(days, stdout, status); + putc('\n', stdout); + + + /* ========== Print the calendar */ + + /* Get the first of the month */ + ucal_set(c, UCAL_DATE, 1); + firstday = ucal_get(c, UCAL_DAY_OF_WEEK, status); + + /* The day of the week for the first day of the month is based on + 1-based days of the week, which were also reordered when placed + in the days array. Account for this here by offsetting by the + first day of the week for the locale, which is also 1-based. */ + firstday -= fdow; + + /* Open the formatter */ + nfmt = unum_open(UNUM_DECIMAL, NULL,0,NULL,NULL, status); + + /* Indent the correct number of spaces for the first week */ + current = firstday; + if(current < 0) + { + current += 7; + } + for(i = 0; i < current; ++i) + indent(lens[i] + 1, stdout); + + /* Finally, print out the days */ + day = ucal_get(c, UCAL_DATE, status); + do { + + /* Format the current day string */ + unum_format(nfmt, day, s, BUF_SIZE, 0, status); + + /* Calculate the justification and indent */ + pad = lens[current] - u_strlen(s); + indent(pad, stdout); + + /* Print the day number out, followed by a space */ + uprint(s, stdout, status); + putc(' ', stdout); + + /* Update the current day */ + ++current; + current %= DAY_COUNT; + + /* If we're at day 0 (first day of the week), insert a newline */ + if(current == 0) { + putc('\n', stdout); + } + + /* Go to the next day */ + ucal_add(c, UCAL_DATE, 1, status); + day = ucal_get(c, UCAL_DATE, status); + + } while(day != 1); + + /* Output a trailing newline */ + putc('\n', stdout); + + /* Clean up */ + free_days(days); + unum_close(nfmt); + udat_close(dfmt); +} + +/* Print out a calendar for c's current year */ +static void +print_year(UCalendar *c, + UChar *days [], + UChar *months [], + UBool useLongNames, + int32_t fdow, + UErrorCode *status) +{ + int32_t width, pad, i, j; + int32_t lens [DAY_COUNT]; + UNumberFormat *nfmt; + UDateFormat *dfmt; + UChar s [BUF_SIZE]; + const UChar pat [] = { 0x0079, 0x0079, 0x0079, 0x0079 }; + int32_t len = 4; + UCalendar *left_cal, *right_cal; + int32_t left_day, right_day; + int32_t left_firstday, right_firstday, left_current, right_current; + int32_t left_month, right_month; + + if(U_FAILURE(*status)) return; + + /* Alias */ + left_cal = c; + + /* ========== Generate the header containing the year (only) */ + + /* Open a formatter with a month and year only pattern */ + dfmt = udat_open(UDAT_IGNORE,UDAT_IGNORE,NULL,NULL,0,pat, len, status); + + /* Format the date */ + udat_format(dfmt, ucal_getMillis(left_cal, status), s, BUF_SIZE, 0, status); + + /* ========== Get the month and day names */ + get_days(dfmt, days, useLongNames, fdow, status); + get_months(dfmt, months, useLongNames, status); + + /* ========== Print the header, centered */ + + /* Calculate widths for justification */ + width = 6; /* 6 spaces, 1 between each day name */ + for(i = 0; i < DAY_COUNT; ++i) { + lens[i] = u_strlen(days[i]); + width += lens[i]; + } + + /* width is the width for 1 calendar; we are displaying in 2 cols + with MARGIN_WIDTH spaces between months */ + + /* Print the header, centered among the day names */ + pad = 2 * width + MARGIN_WIDTH - u_strlen(s); + indent(pad / 2, stdout); + uprint(s, stdout, status); + putc('\n', stdout); + putc('\n', stdout); + + /* Generate a copy of the calendar to use */ + right_cal = ucal_open(0, -1, uloc_getDefault(), UCAL_TRADITIONAL, status); + ucal_setMillis(right_cal, ucal_getMillis(left_cal, status), status); + + /* Open the formatter */ + nfmt = unum_open(UNUM_DECIMAL,NULL, 0,NULL,NULL, status); + + /* ========== Calculate and display the months, two at a time */ + for(i = 0; i < MONTH_COUNT - 1; i += 2) { + + /* Print the month names for the two current months */ + pad = width - u_strlen(months[i]); + indent(pad / 2, stdout); + uprint(months[i], stdout, status); + indent(pad / 2 + MARGIN_WIDTH, stdout); + pad = width - u_strlen(months[i + 1]); + indent(pad / 2, stdout); + uprint(months[i + 1], stdout, status); + putc('\n', stdout); + + /* Print the day names, twice */ + print_days(days, stdout, status); + indent(MARGIN_WIDTH, stdout); + print_days(days, stdout, status); + putc('\n', stdout); + + /* Setup the two calendars */ + ucal_set(left_cal, UCAL_MONTH, i); + ucal_set(left_cal, UCAL_DATE, 1); + ucal_set(right_cal, UCAL_MONTH, i + 1); + ucal_set(right_cal, UCAL_DATE, 1); + + left_firstday = ucal_get(left_cal, UCAL_DAY_OF_WEEK, status); + right_firstday = ucal_get(right_cal, UCAL_DAY_OF_WEEK, status); + + /* The day of the week for the first day of the month is based on + 1-based days of the week. However, the days were reordered + when placed in the days array. Account for this here by + offsetting by the first day of the week for the locale, which + is also 1-based. */ + + /* We need to mod by DAY_COUNT since fdow can be > firstday. IE, + if fdow = 2 = Monday (like in France) and the first day of the + month is a 1 = Sunday, we want firstday to be 6, not -1 */ + left_firstday += (DAY_COUNT - fdow); + left_firstday %= DAY_COUNT; + + right_firstday += (DAY_COUNT - fdow); + right_firstday %= DAY_COUNT; + + left_current = left_firstday; + right_current = right_firstday; + + left_day = ucal_get(left_cal, UCAL_DATE, status); + right_day = ucal_get(right_cal, UCAL_DATE, status); + + left_month = ucal_get(left_cal, UCAL_MONTH, status); + right_month = ucal_get(right_cal, UCAL_MONTH, status); + + /* Finally, print out the days */ + while(left_month == i || right_month == i + 1) { + + /* If the left month is finished printing, but the right month + still has days to be printed, indent the width of the days + strings and reset the left calendar's current day to 0 */ + if(left_month != i && right_month == i + 1) { + indent(width + 1, stdout); + left_current = 0; + } + + while(left_month == i) { + + /* If the day is the first, indent the correct number of + spaces for the first week */ + if(left_day == 1) { + for(j = 0; j < left_current; ++j) + indent(lens[j] + 1, stdout); + } + + /* Format the current day string */ + unum_format(nfmt, left_day, s, BUF_SIZE, 0, status); + + /* Calculate the justification and indent */ + pad = lens[left_current] - u_strlen(s); + indent(pad, stdout); + + /* Print the day number out, followed by a space */ + uprint(s, stdout, status); + putc(' ', stdout); + + /* Update the current day */ + ++left_current; + left_current %= DAY_COUNT; + + /* Go to the next day */ + ucal_add(left_cal, UCAL_DATE, 1, status); + left_day = ucal_get(left_cal, UCAL_DATE, status); + + /* Determine the month */ + left_month = ucal_get(left_cal, UCAL_MONTH, status); + + /* If we're at day 0 (first day of the week), break and go to + the next month */ + if(left_current == 0) { + break; + } + }; + + /* If the current day isn't 0, indent to make up for missing + days at the end of the month */ + if(left_current != 0) { + for(j = left_current; j < DAY_COUNT; ++j) + indent(lens[j] + 1, stdout); + } + + /* Indent between the two months */ + indent(MARGIN_WIDTH, stdout); + + while(right_month == i + 1) { + + /* If the day is the first, indent the correct number of + spaces for the first week */ + if(right_day == 1) { + for(j = 0; j < right_current; ++j) + indent(lens[j] + 1, stdout); + } + + /* Format the current day string */ + unum_format(nfmt, right_day, s, BUF_SIZE, 0, status); + + /* Calculate the justification and indent */ + pad = lens[right_current] - u_strlen(s); + indent(pad, stdout); + + /* Print the day number out, followed by a space */ + uprint(s, stdout, status); + putc(' ', stdout); + + /* Update the current day */ + ++right_current; + right_current %= DAY_COUNT; + + /* Go to the next day */ + ucal_add(right_cal, UCAL_DATE, 1, status); + right_day = ucal_get(right_cal, UCAL_DATE, status); + + /* Determine the month */ + right_month = ucal_get(right_cal, UCAL_MONTH, status); + + /* If we're at day 0 (first day of the week), break out */ + if(right_current == 0) { + break; + } + + }; + + /* Output a newline */ + putc('\n', stdout); + } + + /* Output a trailing newline */ + putc('\n', stdout); + } + + /* Clean up */ + free_months(months); + free_days(days); + udat_close(dfmt); + unum_close(nfmt); + ucal_close(right_cal); +} + +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/cal/cal.sln b/Build/source/libs/icu/icu-xetex/samples/cal/cal.sln new file mode 100644 index 00000000000..7a9c76a0a2b --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/cal/cal.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cal", "cal.vcproj", "{F7659D77-09CF-4FE9-ACEE-927287AA9509}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F7659D77-09CF-4FE9-ACEE-927287AA9509}.Debug|Win32.ActiveCfg = Debug|Win32 + {F7659D77-09CF-4FE9-ACEE-927287AA9509}.Debug|Win32.Build.0 = Debug|Win32 + {F7659D77-09CF-4FE9-ACEE-927287AA9509}.Release|Win32.ActiveCfg = Release|Win32 + {F7659D77-09CF-4FE9-ACEE-927287AA9509}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/cal/cal.vcproj b/Build/source/libs/icu/icu-xetex/samples/cal/cal.vcproj new file mode 100644 index 00000000000..f67b44f9a6b --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/cal/cal.vcproj @@ -0,0 +1,232 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="cal" + ProjectGUID="{F7659D77-09CF-4FE9-ACEE-927287AA9509}" + > + <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" + TypeLibraryName=".\Release/cal.tlb" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE" + StringPooling="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Release/cal.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/cal.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib" + ProgramDatabaseFile=".\Release/cal.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" + TypeLibraryName=".\Debug/cal.tlb" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Debug/cal.pch" + AssemblerListingLocation=".\Debug/" + ObjectFile=".\Debug/" + ProgramDataBaseFileName=".\Debug/" + BrowseInformation="1" + 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/cal.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/cal.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=".\cal.c" + > + </File> + <File + RelativePath=".\uprint.c" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl" + > + <File + RelativePath=".\uprint.h" + > + </File> + </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/cal/readme.txt b/Build/source/libs/icu/icu-xetex/samples/cal/readme.txt new file mode 100644 index 00000000000..69d08e8880b --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/cal/readme.txt @@ -0,0 +1,58 @@ +Copyright (c) 2002-2005, International Business Machines Corporation and others. All Rights Reserved. +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.sln Windows MSVC workspace. Double-click this to get started. + cal.vcproj 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.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 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. + diff --git a/Build/source/libs/icu/icu-xetex/samples/cal/uprint.c b/Build/source/libs/icu/icu-xetex/samples/cal/uprint.c new file mode 100644 index 00000000000..2b0c8115103 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/cal/uprint.c @@ -0,0 +1,75 @@ +/* +********************************************************************** +* Copyright (C) 1998-2001, International Business Machines Corporation +* and others. All Rights Reserved. +********************************************************************** +* +* File date.c +* +* Modification History: +* +* Date Name Description +* 06/14/99 stephen Creation. +******************************************************************************* +*/ + +#include "uprint.h" +#include "unicode/ucnv.h" +#include "unicode/ustring.h" + +#define BUF_SIZE 128 + +/* Print a ustring to the specified FILE* in the default codepage */ +void +uprint(const UChar *s, + FILE *f, + UErrorCode *status) +{ + /* converter */ + UConverter *converter; + char buf [BUF_SIZE]; + int32_t sourceLen; + const UChar *mySource; + const UChar *mySourceEnd; + char *myTarget; + int32_t arraySize; + + if(s == 0) return; + + /* set up the conversion parameters */ + sourceLen = u_strlen(s); + mySource = s; + mySourceEnd = mySource + sourceLen; + myTarget = buf; + arraySize = BUF_SIZE; + + /* open a default converter */ + converter = ucnv_open(0, status); + + /* if we failed, clean up and exit */ + if(U_FAILURE(*status)) goto finish; + + /* perform the conversion */ + do { + /* reset the error code */ + *status = U_ZERO_ERROR; + + /* perform the conversion */ + ucnv_fromUnicode(converter, &myTarget, myTarget + arraySize, + &mySource, mySourceEnd, NULL, + TRUE, status); + + /* Write the converted data to the FILE* */ + fwrite(buf, sizeof(char), myTarget - buf, f); + + /* update the conversion parameters*/ + myTarget = buf; + arraySize = BUF_SIZE; + } + while(*status == U_BUFFER_OVERFLOW_ERROR); + + finish: + + /* close the converter */ + ucnv_close(converter); +} diff --git a/Build/source/libs/icu/icu-xetex/samples/cal/uprint.h b/Build/source/libs/icu/icu-xetex/samples/cal/uprint.h new file mode 100644 index 00000000000..16ffb47c115 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/cal/uprint.h @@ -0,0 +1,26 @@ +/* +********************************************************************** +* Copyright (C) 1998-2004, International Business Machines Corporation +* and others. All Rights Reserved. +********************************************************************** +* +* File uprint.h +* +* Modification History: +* +* Date Name Description +* 06/14/99 stephen Creation. +******************************************************************************* +*/ + +#ifndef UPRINT_H +#define UPRINT_H 1 + +#include <stdio.h> + +#include "unicode/utypes.h" + +/* Print a ustring to the specified FILE* in the default codepage */ +U_CFUNC void uprint(const UChar *s, FILE *f, UErrorCode *status); + +#endif /* ! UPRINT_H */ diff --git a/Build/source/libs/icu/icu-xetex/samples/case/Makefile b/Build/source/libs/icu/icu-xetex/samples/case/Makefile new file mode 100644 index 00000000000..36905e4b33a --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/case/Makefile @@ -0,0 +1,24 @@ +# 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 diff --git a/Build/source/libs/icu/icu-xetex/samples/case/case.cpp b/Build/source/libs/icu/icu-xetex/samples/case/case.cpp new file mode 100644 index 00000000000..fa2fab1a157 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/case/case.cpp @@ -0,0 +1,84 @@ +/* +******************************************************************************* +* +* Copyright (C) 2003-2004, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +*/ + +#include <unicode/unistr.h> +#include <unicode/ustdio.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, "\"%S\"", 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=%S, uppercase=%S\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; +} + diff --git a/Build/source/libs/icu/icu-xetex/samples/case/case.sln b/Build/source/libs/icu/icu-xetex/samples/case/case.sln new file mode 100644 index 00000000000..a34d55de47f --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/case/case.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "case", "case.vcproj", "{2316BE8C-189D-4C8B-B506-9D9EE25AC46D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Debug|Win32.ActiveCfg = Debug|Win32 + {2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Debug|Win32.Build.0 = Debug|Win32 + {2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Release|Win32.ActiveCfg = Release|Win32 + {2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/case/case.vcproj b/Build/source/libs/icu/icu-xetex/samples/case/case.vcproj new file mode 100644 index 00000000000..a4313781201 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/case/case.vcproj @@ -0,0 +1,227 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="case" + ProjectGUID="{2316BE8C-189D-4C8B-B506-9D9EE25AC46D}" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <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" + TypeLibraryName=".\Debug/case.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/case.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 icuiod.lib" + OutputFile=".\Debug/case.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/case.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="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" + TypeLibraryName=".\Release/case.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/case.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 icuio.lib" + OutputFile=".\Release/case.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + ProgramDatabaseFile=".\Release/case.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=".\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> diff --git a/Build/source/libs/icu/icu-xetex/samples/case/readme.txt b/Build/source/libs/icu/icu-xetex/samples/case/readme.txt new file mode 100644 index 00000000000..893bb575fd5 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/case/readme.txt @@ -0,0 +1,61 @@ +Copyright (c) 2003-2005, 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.sln Windows MSVC workspace. Double-click this to get started. + case.vcproj Windows MSVC project file + +To Build case on Windows + 1. Install and build ICU + 2. In MSVC, open the solution file icu\samples\case\case.sln + (or, use the workspace All, in icu\samples\all\all.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 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. + diff --git a/Build/source/libs/icu/icu-xetex/samples/case/ucase.c b/Build/source/libs/icu/icu-xetex/samples/case/ucase.c new file mode 100644 index 00000000000..585f49b7cf0 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/case/ucase.c @@ -0,0 +1,85 @@ +/* +******************************************************************************* +* +* Copyright (C) 2003-2004, 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(%C) = %C\n", char_k, ch); + ch = u_tolower(ch); /* ch = 'k' */ + u_fprintf(out, "tolower() = %C\n", ch); + ch = u_totitle(char_k); /* ch = 'K' */ + u_fprintf(out, "totitle(%C) = %C\n", char_k, ch); + ch = u_foldCase(char_K, U_FOLD_CASE_DEFAULT); /* ch = 'k' */ + u_fprintf(out, "u_foldCase(%C, U_FOLD_CASE_DEFAULT) = %C\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(%S, turkish) -> %S\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(%S, english) -> %S\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(%S, U_FOLD_CASE_DEFAULT) -> %S\n", unfold, buffer); + u_fprintf(out, "\n** end of C sample\n"); + + return 0; +} 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. + diff --git a/Build/source/libs/icu/icu-xetex/samples/coll/Makefile b/Build/source/libs/icu/icu-xetex/samples/coll/Makefile new file mode 100644 index 00000000000..09981866588 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/coll/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=coll + +# All object files (C or C++) +OBJECTS=coll.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/coll/coll.cpp b/Build/source/libs/icu/icu-xetex/samples/coll/coll.cpp new file mode 100644 index 00000000000..28e52392c0a --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/coll/coll.cpp @@ -0,0 +1,266 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (C) 2002-2006 IBM, Inc. All Rights Reserved. + * + ********************************************************************/ + +/** + * This program demos string collation + */ + +const char gHelpString[] = + "usage: coll [options*] -source source_string -target target_string\n" + "-help Display this message.\n" + "-locale name ICU locale to use. Default is en_US\n" + "-rules rule Collation rules file (overrides locale)\n" + "-french French accent ordering\n" + "-norm Normalizing mode on\n" + "-shifted Shifted mode\n" + "-lower Lower case first\n" + "-upper Upper case first\n" + "-case Enable separate case level\n" + "-level n Sort level, 1 to 5, for Primary, Secndary, Tertiary, Quaternary, Identical\n" + "-source string Source string for comparison\n" + "-target string Target string for comparison\n" + "Example coll -rules \\u0026b\\u003ca -source a -target b\n" + "The format \\uXXXX is supported for the rules and comparison strings\n" + ; + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include <unicode/utypes.h> +#include <unicode/ucol.h> +#include <unicode/ustring.h> + +/** + * Command line option variables + * These global variables are set according to the options specified + * on the command line by the user. + */ +char * opt_locale = "en_US"; +char * opt_rules = 0; +UBool opt_help = FALSE; +UBool opt_norm = FALSE; +UBool opt_french = FALSE; +UBool opt_shifted = FALSE; +UBool opt_lower = FALSE; +UBool opt_upper = FALSE; +UBool opt_case = FALSE; +int opt_level = 0; +char * opt_source = "abc"; +char * opt_target = "abd"; +UCollator * collator = 0; + +/** + * Definitions for the command line options + */ +struct OptSpec { + const char *name; + enum {FLAG, NUM, STRING} type; + void *pVar; +}; + +OptSpec opts[] = { + {"-locale", OptSpec::STRING, &opt_locale}, + {"-rules", OptSpec::STRING, &opt_rules}, + {"-source", OptSpec::STRING, &opt_source}, + {"-target", OptSpec::STRING, &opt_target}, + {"-norm", OptSpec::FLAG, &opt_norm}, + {"-french", OptSpec::FLAG, &opt_french}, + {"-shifted", OptSpec::FLAG, &opt_shifted}, + {"-lower", OptSpec::FLAG, &opt_lower}, + {"-upper", OptSpec::FLAG, &opt_upper}, + {"-case", OptSpec::FLAG, &opt_case}, + {"-level", OptSpec::NUM, &opt_level}, + {"-help", OptSpec::FLAG, &opt_help}, + {"-?", OptSpec::FLAG, &opt_help}, + {0, OptSpec::FLAG, 0} +}; + +/** + * processOptions() Function to read the command line options. + */ +UBool processOptions(int argc, const char **argv, OptSpec opts[]) +{ + for (int argNum = 1; argNum < argc; argNum ++) { + const char *pArgName = argv[argNum]; + OptSpec *pOpt; + for (pOpt = opts; pOpt->name != 0; pOpt ++) { + if (strcmp(pOpt->name, pArgName) == 0) { + switch (pOpt->type) { + case OptSpec::FLAG: + *(UBool *)(pOpt->pVar) = TRUE; + break; + case OptSpec::STRING: + argNum ++; + if (argNum >= argc) { + fprintf(stderr, "value expected for \"%s\" option.\n", + pOpt->name); + return FALSE; + } + *(const char **)(pOpt->pVar) = argv[argNum]; + break; + case OptSpec::NUM: + argNum ++; + if (argNum >= argc) { + fprintf(stderr, "value expected for \"%s\" option.\n", + pOpt->name); + return FALSE; + } + char *endp; + int i = strtol(argv[argNum], &endp, 0); + if (endp == argv[argNum]) { + fprintf(stderr, + "integer value expected for \"%s\" option.\n", + pOpt->name); + return FALSE; + } + *(int *)(pOpt->pVar) = i; + } + break; + } + } + if (pOpt->name == 0) + { + fprintf(stderr, "Unrecognized option \"%s\"\n", pArgName); + return FALSE; + } + } + return TRUE; +} + +/** + * ICU string comparison + */ +int strcmp() +{ + UChar source[100]; + UChar target[100]; + u_unescape(opt_source, source, 100); + u_unescape(opt_target, target, 100); + UCollationResult result = ucol_strcoll(collator, source, -1, target, -1); + if (result == UCOL_LESS) { + return -1; + } + else if (result == UCOL_GREATER) { + return 1; + } + return 0; +} + +/** + * Creates a collator + */ +UBool processCollator() +{ + // Set up an ICU collator + UErrorCode status = U_ZERO_ERROR; + UChar rules[100]; + + if (opt_rules != 0) { + u_unescape(opt_rules, rules, 100); + collator = ucol_openRules(rules, -1, UCOL_OFF, UCOL_TERTIARY, + NULL, &status); + } + else { + collator = ucol_open(opt_locale, &status); + } + if (U_FAILURE(status)) { + fprintf(stderr, "Collator creation failed.: %d\n", status); + return FALSE; + } + if (status == U_USING_DEFAULT_WARNING) { + fprintf(stderr, "Warning, U_USING_DEFAULT_WARNING for %s\n", + opt_locale); + } + if (status == U_USING_FALLBACK_WARNING) { + fprintf(stderr, "Warning, U_USING_FALLBACK_ERROR for %s\n", + opt_locale); + } + if (opt_norm) { + ucol_setAttribute(collator, UCOL_NORMALIZATION_MODE, UCOL_ON, &status); + } + if (opt_french) { + ucol_setAttribute(collator, UCOL_FRENCH_COLLATION, UCOL_ON, &status); + } + if (opt_lower) { + ucol_setAttribute(collator, UCOL_CASE_FIRST, UCOL_LOWER_FIRST, + &status); + } + if (opt_upper) { + ucol_setAttribute(collator, UCOL_CASE_FIRST, UCOL_UPPER_FIRST, + &status); + } + if (opt_case) { + ucol_setAttribute(collator, UCOL_CASE_LEVEL, UCOL_ON, &status); + } + if (opt_shifted) { + ucol_setAttribute(collator, UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, + &status); + } + if (opt_level != 0) { + switch (opt_level) { + case 1: + ucol_setAttribute(collator, UCOL_STRENGTH, UCOL_PRIMARY, &status); + break; + case 2: + ucol_setAttribute(collator, UCOL_STRENGTH, UCOL_SECONDARY, + &status); + break; + case 3: + ucol_setAttribute(collator, UCOL_STRENGTH, UCOL_TERTIARY, &status); + break; + case 4: + ucol_setAttribute(collator, UCOL_STRENGTH, UCOL_QUATERNARY, + &status); + break; + case 5: + ucol_setAttribute(collator, UCOL_STRENGTH, UCOL_IDENTICAL, + &status); + break; + default: + fprintf(stderr, "-level param must be between 1 and 5\n"); + return FALSE; + } + } + if (U_FAILURE(status)) { + fprintf(stderr, "Collator attribute setting failed.: %d\n", status); + return FALSE; + } + return TRUE; +} + +/** + * Main -- process command line, read in and pre-process the test file, + * call other functions to do the actual tests. + */ +int main(int argc, const char** argv) +{ + if (processOptions(argc, argv, opts) != TRUE || opt_help) { + printf(gHelpString); + return -1; + } + + if (processCollator() != TRUE) { + fprintf(stderr, "Error creating collator for comparison\n"); + return -1; + } + + fprintf(stdout, "Comparing source=%s and target=%s\n", opt_source, + opt_target); + int result = strcmp(); + if (result == 0) { + fprintf(stdout, "source is equals to target\n"); + } + else if (result < 0) { + fprintf(stdout, "source is less than target\n"); + } + else { + fprintf(stdout, "source is greater than target\n"); + } + + ucol_close(collator); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/coll/coll.sln b/Build/source/libs/icu/icu-xetex/samples/coll/coll.sln new file mode 100644 index 00000000000..6744ce84c78 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/coll/coll.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "coll", "coll.vcproj", "{7664D0D2-0263-4BFB-AE19-9A1CAD231440}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7664D0D2-0263-4BFB-AE19-9A1CAD231440}.Debug|Win32.ActiveCfg = Debug|Win32 + {7664D0D2-0263-4BFB-AE19-9A1CAD231440}.Debug|Win32.Build.0 = Debug|Win32 + {7664D0D2-0263-4BFB-AE19-9A1CAD231440}.Release|Win32.ActiveCfg = Release|Win32 + {7664D0D2-0263-4BFB-AE19-9A1CAD231440}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/coll/coll.vcproj b/Build/source/libs/icu/icu-xetex/samples/coll/coll.vcproj new file mode 100644 index 00000000000..517ad42756a --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/coll/coll.vcproj @@ -0,0 +1,224 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="coll" + ProjectGUID="{7664D0D2-0263-4BFB-AE19-9A1CAD231440}" + > + <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" + TypeLibraryName=".\Release/coll.tlb" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32,NDEBUG,_CONSOLE" + StringPooling="true" + RuntimeLibrary="0" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Release/coll.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="icuind.lib icuucd.lib" + OutputFile=".\Release/coll.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + ProgramDatabaseFile=".\Release/coll.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" + TypeLibraryName=".\Debug/coll.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/coll.pch" + AssemblerListingLocation=".\Debug/" + ObjectFile=".\Debug/" + ProgramDataBaseFileName=".\Debug/" + BrowseInformation="1" + 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="icuind.lib icuucd.lib" + OutputFile=".\Debug/coll.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/coll.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=".\coll.cpp" + > + </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/coll/readme.txt b/Build/source/libs/icu/icu-xetex/samples/coll/readme.txt new file mode 100644 index 00000000000..b5aa4acf5f4 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/coll/readme.txt @@ -0,0 +1,55 @@ +Copyright (c) 2002-2005, International Business Machines Corporation and others. All Rights Reserved. +coll: a sample program which compares 2 strings with a user-defined collator. + +This sample demonstrates + Creating a user-defined collator + Comparing 2 string using the collator created + +Files: + coll.c Main source file + coll.sln Windows MSVC workspace. Double-click this to get started. + coll.vcproj Windows MSVC project file + +To Build coll on Windows + 1. Install and build ICU + 2. In MSVC, open the workspace file icu\samples\coll\coll.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 coll directory, e.g. + cd c:\icu\source\samples\coll\debug + 4. Run it + coll [options*] -source source_string -target target_string + +To Build on Unixes + 1. Build ICU. coll 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/coll + + 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. + diff --git a/Build/source/libs/icu/icu-xetex/samples/csdet/Makefile b/Build/source/libs/icu/icu-xetex/samples/csdet/Makefile new file mode 100644 index 00000000000..410590a2c11 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/csdet/Makefile @@ -0,0 +1,22 @@ +# Copyright (c) 2000-2007 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=csdet + +# All object files (C or C++) +OBJECTS=csdet.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/csdet/csdet.c b/Build/source/libs/icu/icu-xetex/samples/csdet/csdet.c new file mode 100644 index 00000000000..b0c89f28599 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/csdet/csdet.c @@ -0,0 +1,73 @@ +/* + ******************************************************************************** + * Copyright (C) 2005-2006, International Business Machines + * Corporation and others. All Rights Reserved. + ******************************************************************************** + */ + +#include "unicode/utypes.h" +#include "unicode/ucsdet.h" + +#include <string.h> +#include <stdio.h> + +#define BUFFER_SIZE 8192 + +int main(int argc, char *argv[]) +{ + static char buffer[BUFFER_SIZE]; + int32_t arg; + + if( argc <= 1 ) { + printf("Usage: %s [filename]...\n", argv[0]); + return -1; + } + + for(arg = 1; arg < argc; arg += 1) { + FILE *file; + char *filename = argv[arg]; + int32_t inputLength, match, matchCount = 0; + UCharsetDetector* csd; + const UCharsetMatch **csm; + UErrorCode status = U_ZERO_ERROR; + + if (arg > 1) { + printf("\n"); + } + + file = fopen(filename, "rb"); + + if (file == NULL) { + printf("Cannot open file \"%s\"\n\n", filename); + continue; + } + + printf("%s:\n", filename); + + inputLength = (int32_t) fread(buffer, 1, BUFFER_SIZE, file); + + fclose(file); + + csd = ucsdet_open(&status); + ucsdet_setText(csd, buffer, inputLength, &status); + + csm = ucsdet_detectAll(csd, &matchCount, &status); + + for(match = 0; match < matchCount; match += 1) { + const char *name = ucsdet_getName(csm[match], &status); + const char *lang = ucsdet_getLanguage(csm[match], &status); + int32_t confidence = ucsdet_getConfidence(csm[match], &status); + + if (lang == NULL || strlen(lang) == 0) { + lang = "**"; + } + + printf("%s (%s) %d\n", name, lang, confidence); + } + + ucsdet_close(csd); + } + + return 0; +} + diff --git a/Build/source/libs/icu/icu-xetex/samples/csdet/csdet.vcproj b/Build/source/libs/icu/icu-xetex/samples/csdet/csdet.vcproj new file mode 100644 index 00000000000..a6d3d0ed622 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/csdet/csdet.vcproj @@ -0,0 +1,208 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="csdet" + ProjectGUID="{683745AD-3BC2-4B89-898B-93490D7F2757}" + 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" + OutputFile="$(OutDir)/csdet.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="../../../lib" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/csdet.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" + OutputFile="$(OutDir)/csdet.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=".\csdet.c" + > + </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/date/Makefile.in b/Build/source/libs/icu/icu-xetex/samples/date/Makefile.in new file mode 100644 index 00000000000..c1873721df5 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/date/Makefile.in @@ -0,0 +1,75 @@ +## Makefile.in for ICU - samples/date +## Copyright (c) 1999-2004, International Business Machines Corporation and +## others. All Rights Reserved. + +## Source directory information + +srcdir=@srcdir@ +top_srcdir=@top_srcdir@ + +top_builddir = ../.. + +include $(top_builddir)/icudefs.mk + +## Build directory information +subdir = samples/date + +## Extra files to remove for 'make clean' +CLEANFILES = *~ $(DEPS) + +## Target information +TARGET = icudate$(EXEEXT) + +CPPFLAGS += -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir)/i18n +LIBS = $(LIBICUI18N) $(LIBICUUC) $(DEFAULT_LIBS) $(LIB_M) + +OBJECTS = uprint.o date.o + +DEPS = $(OBJECTS:.o=.d) + +## List of phony targets +.PHONY : all all-local install install-local clean clean-local \ +distclean distclean-local dist dist-local check check-local + +## Clear suffix list +.SUFFIXES : + +## List of standard targets +all: all-local +install: install-local +clean: clean-local +distclean : distclean-local +dist: dist-local +check: all check-local + +all-local: $(TARGET) + +install-local: all-local + +dist-local: + +clean-local: + test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES) + $(RMV) $(OBJECTS) $(TARGET) + +distclean-local: clean-local + $(RMV) Makefile + +check-local: + -$(INVOKE) ./$(TARGET) + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +$(TARGET) : $(OBJECTS) + $(LINK.c) $(OUTOPT)$@ $^ $(LIBS) + $(POST_BUILD_STEP) + +ifeq (,$(MAKECMDGOALS)) +-include $(DEPS) +else +ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),) +-include $(DEPS) +endif +endif diff --git a/Build/source/libs/icu/icu-xetex/samples/date/date.c b/Build/source/libs/icu/icu-xetex/samples/date/date.c new file mode 100644 index 00000000000..8a7ebe1f964 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/date/date.c @@ -0,0 +1,204 @@ +/* +********************************************************************** +* Copyright (C) 1998-2007, International Business Machines +* Corporation and others. All Rights Reserved. +********************************************************************** +* +* File date.c +* +* Modification History: +* +* Date Name Description +* 06/11/99 stephen Creation. +* 06/16/99 stephen Modified to use uprint. +******************************************************************************* +*/ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "unicode/utypes.h" +#include "unicode/ustring.h" +#include "unicode/uclean.h" + +#include "unicode/ucnv.h" +#include "unicode/udat.h" +#include "unicode/ucal.h" + +#include "uprint.h" + +int main(int argc, char **argv); + +#if UCONFIG_NO_FORMATTING + +int main(int argc, char **argv) +{ + printf("%s: Sorry, UCONFIG_NO_FORMATTING was turned on (see uconfig.h). No formatting can be done. \n", argv[0]); + return 0; +} +#else + + +/* Protos */ +static void usage(void); +static void version(void); +static void date(const UChar *tz, UDateFormatStyle style, char *format, UErrorCode *status); + + +/* The version of date */ +#define DATE_VERSION "1.0" + +/* "GMT" */ +static const UChar GMT_ID [] = { 0x0047, 0x004d, 0x0054, 0x0000 }; + + +int +main(int argc, + char **argv) +{ + int printUsage = 0; + int printVersion = 0; + int optind = 1; + char *arg; + const UChar *tz = 0; + UDateFormatStyle style = UDAT_DEFAULT; + UErrorCode status = U_ZERO_ERROR; + char *format = NULL; + + + /* parse the options */ + for(optind = 1; optind < argc; ++optind) { + arg = argv[optind]; + + /* version info */ + if(strcmp(arg, "-v") == 0 || strcmp(arg, "--version") == 0) { + printVersion = 1; + } + /* usage info */ + else if(strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) { + printUsage = 1; + } + /* display date in gmt */ + else if(strcmp(arg, "-u") == 0 || strcmp(arg, "--gmt") == 0) { + tz = GMT_ID; + } + /* display date in gmt */ + else if(strcmp(arg, "-f") == 0 || strcmp(arg, "--full") == 0) { + style = UDAT_FULL; + } + /* display date in long format */ + else if(strcmp(arg, "-l") == 0 || strcmp(arg, "--long") == 0) { + style = UDAT_LONG; + } + /* display date in medium format */ + else if(strcmp(arg, "-m") == 0 || strcmp(arg, "--medium") == 0) { + style = UDAT_MEDIUM; + } + /* display date in short format */ + else if(strcmp(arg, "-s") == 0 || strcmp(arg, "--short") == 0) { + style = UDAT_SHORT; + } + else if(strcmp(arg, "-F") == 0 || strcmp(arg, "--format") == 0) { + if ( optind + 1 < argc ) { + optind++; + format = argv[optind]; + } + } + /* POSIX.1 says all arguments after -- are not options */ + else if(strcmp(arg, "--") == 0) { + /* skip the -- */ + ++optind; + break; + } + /* unrecognized option */ + else if(strncmp(arg, "-", strlen("-")) == 0) { + printf("icudate: invalid option -- %s\n", arg+1); + printUsage = 1; + } + /* done with options, display date */ + else { + break; + } + } + + /* print usage info */ + if(printUsage) { + usage(); + return 0; + } + + /* print version info */ + if(printVersion) { + version(); + return 0; + } + + /* print the date */ + date(tz, style, format, &status); + + u_cleanup(); + return (U_FAILURE(status) ? 1 : 0); +} + +/* Usage information */ +static void +usage() +{ + 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."); + puts(" -u, --gmt Display the date in Greenwich Mean Time."); + puts(" -f, --full Use full display format."); + puts(" -l, --long Use long display format."); + puts(" -m, --medium Use medium display format."); + puts(" -s, --short Use short display format."); +} + +/* Version information */ +static void +version() +{ + printf("icudate version %s (ICU version %s), created by Stephen F. Booth.\n", + DATE_VERSION, U_ICU_VERSION); + puts(U_COPYRIGHT_STRING); +} + +/* Format the date */ +static void +date(const UChar *tz, + UDateFormatStyle style, + char *format, + UErrorCode *status) +{ + UChar *s = 0; + int32_t len = 0; + UDateFormat *fmt; + UChar uFormat[100]; + + fmt = udat_open(style, style, 0, tz, -1,NULL,0, status); + if ( format != NULL ) { + u_charsToUChars(format,uFormat,strlen(format)), + udat_applyPattern(fmt,FALSE,uFormat,strlen(format)); + } + len = udat_format(fmt, ucal_getNow(), 0, len, 0, status); + if(*status == U_BUFFER_OVERFLOW_ERROR) { + *status = U_ZERO_ERROR; + s = (UChar*) malloc(sizeof(UChar) * (len+1)); + if(s == 0) goto finish; + udat_format(fmt, ucal_getNow(), s, len + 1, 0, status); + if(U_FAILURE(*status)) goto finish; + } + + /* print the date string */ + uprint(s, stdout, status); + + /* print a trailing newline */ + printf("\n"); + + finish: + udat_close(fmt); + free(s); +} +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/date/date.sln b/Build/source/libs/icu/icu-xetex/samples/date/date.sln new file mode 100644 index 00000000000..d392b392bfb --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/date/date.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "date", "date.vcproj", "{38B5751A-C6F9-4409-950C-F4F9DA17275F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Debug|Win32.ActiveCfg = Debug|Win32 + {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Debug|Win32.Build.0 = Debug|Win32 + {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Release|Win32.ActiveCfg = Release|Win32 + {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/date/date.vcproj b/Build/source/libs/icu/icu-xetex/samples/date/date.vcproj new file mode 100644 index 00000000000..eb4327dd166 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/date/date.vcproj @@ -0,0 +1,231 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="date" + ProjectGUID="{38B5751A-C6F9-4409-950C-F4F9DA17275F}" + > + <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" + TypeLibraryName=".\Release/date.tlb" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE" + StringPooling="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Release/date.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/date.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib" + ProgramDatabaseFile=".\Release/date.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" + TypeLibraryName=".\Debug/date.tlb" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Debug/date.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/date.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/date.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=".\date.c" + > + </File> + <File + RelativePath=".\uprint.c" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl" + > + <File + RelativePath=".\uprint.h" + > + </File> + </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/date/readme.txt b/Build/source/libs/icu/icu-xetex/samples/date/readme.txt new file mode 100644 index 00000000000..3ba36d518e4 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/date/readme.txt @@ -0,0 +1,58 @@ +Copyright (c) 2002-2005, International Business Machines Corporation and others. All Rights Reserved. +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.sln Windows MSVC workspace. Double-click this to get started. + date.vcproj 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.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 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. + diff --git a/Build/source/libs/icu/icu-xetex/samples/date/uprint.c b/Build/source/libs/icu/icu-xetex/samples/date/uprint.c new file mode 100644 index 00000000000..27e82af2f2b --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/date/uprint.c @@ -0,0 +1,76 @@ +/* +********************************************************************** +* Copyright (C) 1998-2001, International Business Machines Corporation +* and others. All Rights Reserved. +********************************************************************** +* +* File date.c +* +* Modification History: +* +* Date Name Description +* 06/14/99 stephen Creation. +******************************************************************************* +*/ + +#include "uprint.h" + +#include "unicode/ucnv.h" +#include "unicode/ustring.h" + +#define BUF_SIZE 128 + +/* Print a ustring to the specified FILE* in the default codepage */ +void +uprint(const UChar *s, + FILE *f, + UErrorCode *status) +{ + /* converter */ + UConverter *converter; + char buf [BUF_SIZE]; + int32_t sourceLen; + const UChar *mySource; + const UChar *mySourceEnd; + char *myTarget; + int32_t arraySize; + + if(s == 0) return; + + /* set up the conversion parameters */ + sourceLen = u_strlen(s); + mySource = s; + mySourceEnd = mySource + sourceLen; + myTarget = buf; + arraySize = BUF_SIZE; + + /* open a default converter */ + converter = ucnv_open(0, status); + + /* if we failed, clean up and exit */ + if(U_FAILURE(*status)) goto finish; + + /* perform the conversion */ + do { + /* reset the error code */ + *status = U_ZERO_ERROR; + + /* perform the conversion */ + ucnv_fromUnicode(converter, &myTarget, myTarget + arraySize, + &mySource, mySourceEnd, NULL, + TRUE, status); + + /* Write the converted data to the FILE* */ + fwrite(buf, sizeof(char), myTarget - buf, f); + + /* update the conversion parameters*/ + myTarget = buf; + arraySize = BUF_SIZE; + } + while(*status == U_BUFFER_OVERFLOW_ERROR); + + finish: + + /* close the converter */ + ucnv_close(converter); +} diff --git a/Build/source/libs/icu/icu-xetex/samples/date/uprint.h b/Build/source/libs/icu/icu-xetex/samples/date/uprint.h new file mode 100644 index 00000000000..16ffb47c115 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/date/uprint.h @@ -0,0 +1,26 @@ +/* +********************************************************************** +* Copyright (C) 1998-2004, International Business Machines Corporation +* and others. All Rights Reserved. +********************************************************************** +* +* File uprint.h +* +* Modification History: +* +* Date Name Description +* 06/14/99 stephen Creation. +******************************************************************************* +*/ + +#ifndef UPRINT_H +#define UPRINT_H 1 + +#include <stdio.h> + +#include "unicode/utypes.h" + +/* Print a ustring to the specified FILE* in the default codepage */ +U_CFUNC void uprint(const UChar *s, FILE *f, UErrorCode *status); + +#endif /* ! UPRINT_H */ diff --git a/Build/source/libs/icu/icu-xetex/samples/datecal/Makefile b/Build/source/libs/icu/icu-xetex/samples/datecal/Makefile new file mode 100644 index 00000000000..89e728c87ba --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/datecal/Makefile @@ -0,0 +1,24 @@ +# Copyright (c) 2000-2006 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=datecal + +# All object files (C or C++) +OBJECTS=cal.o ccal.o + +#### rules +# 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/datecal/cal.cpp b/Build/source/libs/icu/icu-xetex/samples/datecal/cal.cpp new file mode 100644 index 00000000000..f06538418f9 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/datecal/cal.cpp @@ -0,0 +1,67 @@ +/* +******************************************************************************* +* +* Copyright (C) 2002-2003, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +*/ + +#include "unicode/calendar.h" +#include "unicode/gregocal.h" +#include <stdio.h> + +extern "C" { extern void c_main(); }; + +void cpp_main() +{ + UErrorCode status = U_ZERO_ERROR; + puts("C++ sample"); + GregorianCalendar* gc = new GregorianCalendar(status); + if (U_FAILURE(status)) { + puts("Couldn't create GregorianCalendar"); + return; + } + /* set up the date */ + gc->set(2000, UCAL_FEBRUARY, 26); + gc->set(UCAL_HOUR_OF_DAY, 23); + gc->set(UCAL_MINUTE, 0); + gc->set(UCAL_SECOND, 0); + gc->set(UCAL_MILLISECOND, 0); + /* Iterate through the days and print it out. */ + for (int32_t i = 0; i < 30; i++) { + /* print out the date. */ + /* You should use the DateFormat to properly format it */ + printf("year: %d, month: %d (%d in the implementation), day: %d\n", + gc->get(UCAL_YEAR, status), + gc->get(UCAL_MONTH, status) + 1, + gc->get(UCAL_MONTH, status), + gc->get(UCAL_DATE, status)); + if (U_FAILURE(status)) + { + puts("Calendar::get failed"); + return; + } + /* Add a day to the date */ + gc->add(UCAL_DATE, 1, status); + if (U_FAILURE(status)) { + puts("Calendar::add failed"); + return; + } + } + delete gc; +} + + +/* Creating and using text boundaries */ +int main( void ) +{ + puts("Date-Calendar sample program"); + + cpp_main(); + + c_main(); + + return 0; +} + diff --git a/Build/source/libs/icu/icu-xetex/samples/datecal/ccal.c b/Build/source/libs/icu/icu-xetex/samples/datecal/ccal.c new file mode 100644 index 00000000000..1b65579f1cc --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/datecal/ccal.c @@ -0,0 +1,55 @@ +/* +******************************************************************************* +* +* Copyright (C) 2002-2003, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +*/ + +#include "unicode/ucal.h" +#include <stdio.h> + +void c_main() +{ + puts("----"); + puts("C Sample"); + +UErrorCode status = U_ZERO_ERROR; +int32_t i; +UCalendar *cal = ucal_open(NULL, -1, NULL, UCAL_GREGORIAN, &status); +if (U_FAILURE(status)) { + puts("Couldn't create GregorianCalendar"); + return; + } + /* set up the date */ + ucal_set(cal, UCAL_YEAR, 2000); + ucal_set(cal, UCAL_MONTH, UCAL_FEBRUARY); /* FEBRUARY */ + ucal_set(cal, UCAL_DATE, 26); + ucal_set(cal, UCAL_HOUR_OF_DAY, 23); + ucal_set(cal, UCAL_MINUTE, 0); + ucal_set(cal, UCAL_SECOND, 0); + ucal_set(cal, UCAL_MILLISECOND, 0); + /* Iterate through the days and print it out. */ + for (i = 0; i < 30; i++) { + /* print out the date. */ + /* You should use the udat_* API to properly format it */ + printf("year: %d, month: %d (%d in the implementation), day: %d\n", + ucal_get(cal, UCAL_YEAR, &status), + ucal_get(cal, UCAL_MONTH, &status) + 1, + ucal_get(cal, UCAL_MONTH, &status), + ucal_get(cal, UCAL_DATE, &status)); + if (U_FAILURE(status)) { + puts("Calendar::get failed"); + return; + } + /* Add a day to the date */ + ucal_add(cal, UCAL_DATE, 1, &status); + if (U_FAILURE(status)) + { + puts("Calendar::add failed"); + return; + } + } + ucal_close(cal); +} diff --git a/Build/source/libs/icu/icu-xetex/samples/datefmt/Makefile b/Build/source/libs/icu/icu-xetex/samples/datefmt/Makefile new file mode 100644 index 00000000000..6b0cb23b7b1 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/datefmt/Makefile @@ -0,0 +1,20 @@ +# 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 + +# Name of your target +TARGET=datefmt + +# All object files (C or C++) +OBJECTS=main.o util.o + +# 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/datefmt/README.TXT b/Build/source/libs/icu/icu-xetex/samples/datefmt/README.TXT new file mode 100644 index 00000000000..7a12224ddec --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/datefmt/README.TXT @@ -0,0 +1,104 @@ +Copyright (c) 2002-2007, International Business Machines Corporation and others. All Rights Reserved. +This is an exercise for the ICU Workshop (September 2000). +** Workshop homepage is: + http://www.icu-project.org/docs/workshop_2000/agenda.html + + Day 2: September 12th 2000 + Pre-requsit: + 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 + http://www.icu-project.org/userguide/. + + #Date/Time/Number Formatting Support + 9:30am - 10:30am + Alan Liu + + Topics: + 1. What is the date/time support in ICU? + 2. What is the timezone support in ICU? + 3. What kind of formatting and parsing support is available in ICU, i.e. + NumberFormat, DateFormat, MessageFormat? + + +INSTRUCTIONS +------------ + +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. + + MSVC: + Open the file "datefmt.sln" 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 +-------- + +Problem 0: + + Set up the program, build it, and run it. To start with, the + program prints out a list of languages. + +Problem 1: Basic Date Formatting (Easy) + + Create a calendar, and use it to get the UDate for June 4, 1999, + 0:00 GMT (or any date of your choosing). You will have to create a + TimeZone (use the createZone() function already defined in main.cpp) + and a Calendar object, and make the calendar use the time zone. + + Once you have the UDate, create a DateFormat object in each of the + languages in the LANGUAGE array, and display the date in that + language. Use the DateFormat::createDateInstance() method to create + the date formatter. + +Problem 2: Date Formatting, Specific Time Zone (Medium) + + To really localize a time display, one can also specify the time + zone in which the time should be displayed. For each language, + also create different time zones from the TIMEZONE list. + + To format a date with a specific calendar and zone, you must deal with + three objects: a DateFormat, a Calendar, and a TimeZone. Each object + must be linked to another in correct sequence: The Calendar must use + the TimeZone, and the DateFormat must use the Calendar. + + DateFormat =uses=> Calendar =uses=> TimeZone + + Use either setFoo() or adoptFoo() methods, depending on where you + want to have ownership. + + NOTE: It's not always desirable to change the time to a local time + zone before display. For instance, if some even occurs at 0:00 GMT + on the first of the month, it's probably clearer to just state that. + Stating that it occurs at 5:00 PM PDT on the day before in the + summer, and 4:00 PM PST on the day before in the winter will just + confuse the issue. + + +NOTES +----- + +To see a list of system TimeZone IDs, use the TimeZone::create- +AvailableIDs() methods. Alternatively, look at the file +icu/docs/tz.htm. This has a hyperlinked list of current system zones. + + +ANSWERS +------- + +The exercise includes answers. These are in the "answers" directory, +and are numbered 1, 2, etc. + +If you get stuck and you want to move to the next step, copy the +answers file into the main directory in order to proceed. E.g., +"main_1.cpp" contains the original "main.cpp" file. "main_2.cpp" +contains the "main.cpp" file after problem 1. Etc. + + +Have fun! diff --git a/Build/source/libs/icu/icu-xetex/samples/datefmt/answers/main_0.cpp b/Build/source/libs/icu/icu-xetex/samples/datefmt/answers/main_0.cpp new file mode 100644 index 00000000000..2f4dad212aa --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/datefmt/answers/main_0.cpp @@ -0,0 +1,66 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2003, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include "unicode/uclean.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" + +/** + * If the ID supplied to TimeZone is not a valid system ID, + * TimeZone::createTimeZone() will return a GMT zone object. In order + * to detect this error, we check the ID of the returned zone against + * the ID we requested. If they don't match, we fail with an error. + */ +TimeZone* createZone(const UnicodeString& id) { + UnicodeString str; + TimeZone* zone = TimeZone::createTimeZone(id); + if (zone->getID(str) != id) { + delete zone; + printf("Error: TimeZone::createTimeZone("); + uprintf(id); + printf(") returned zone with ID "); + uprintf(str); + printf("\n"); + exit(1); + } + return zone; +} + +int main(int argc, char **argv) { + + UErrorCode status = U_ZERO_ERROR; + UnicodeString str; + + // The languages in which we will display the date + static char* LANGUAGE[] = { + "en", "de", "fr" + }; + static const int32_t N_LANGUAGE = sizeof(LANGUAGE)/sizeof(LANGUAGE[0]); + + // The time zones in which we will display the time + static char* TIMEZONE[] = { + "America/Los_Angeles", + "America/New_York", + "Europe/Paris", + "Europe/Berlin" + }; + static const int32_t N_TIMEZONE = sizeof(TIMEZONE)/sizeof(TIMEZONE[0]); + + for (int32_t i=0; i<N_LANGUAGE; ++i) { + Locale loc(LANGUAGE[i]); + + // Display the formatted date string + printf("Date (%s)\n", LANGUAGE[i]); + } + + printf("Exiting successfully\n"); + u_cleanup(); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/datefmt/answers/main_1.cpp b/Build/source/libs/icu/icu-xetex/samples/datefmt/answers/main_1.cpp new file mode 100644 index 00000000000..ad8c99c88a6 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/datefmt/answers/main_1.cpp @@ -0,0 +1,64 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" + +/** + * If the ID supplied to TimeZone is not a valid system ID, + * TimeZone::createTimeZone() will return a GMT zone object. In order + * to detect this error, we check the ID of the returned zone against + * the ID we requested. If they don't match, we fail with an error. + */ +TimeZone* createZone(const UnicodeString& id) { + UnicodeString str; + TimeZone* zone = TimeZone::createTimeZone(id); + if (zone->getID(str) != id) { + delete zone; + printf("Error: TimeZone::createTimeZone("); + uprintf(id); + printf(") returned zone with ID "); + uprintf(str); + printf("\n"); + exit(1); + } + return zone; +} + +int main(int argc, char **argv) { + + UErrorCode status = U_ZERO_ERROR; + UnicodeString str; + + // The languages in which we will display the date + static char* LANGUAGE[] = { + "en", "de", "fr" + }; + static const int32_t N_LANGUAGE = sizeof(LANGUAGE)/sizeof(LANGUAGE[0]); + + // The time zones in which we will display the time + static char* TIMEZONE[] = { + "America/Los_Angeles", + "America/New_York", + "Europe/Paris", + "Europe/Berlin" + }; + static const int32_t N_TIMEZONE = sizeof(TIMEZONE)/sizeof(TIMEZONE[0]); + + for (int32_t i=0; i<N_LANGUAGE; ++i) { + Locale loc(LANGUAGE[i]); + + // Display the formatted date string + printf("Date (%s)\n", LANGUAGE[i]); + } + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/datefmt/answers/main_2.cpp b/Build/source/libs/icu/icu-xetex/samples/datefmt/answers/main_2.cpp new file mode 100644 index 00000000000..e677a4fd1b2 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/datefmt/answers/main_2.cpp @@ -0,0 +1,87 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" + +/** + * If the ID supplied to TimeZone is not a valid system ID, + * TimeZone::createTimeZone() will return a GMT zone object. In order + * to detect this error, we check the ID of the returned zone against + * the ID we requested. If they don't match, we fail with an error. + */ +TimeZone* createZone(const UnicodeString& id) { + UnicodeString str; + TimeZone* zone = TimeZone::createTimeZone(id); + if (zone->getID(str) != id) { + delete zone; + printf("Error: TimeZone::createTimeZone("); + uprintf(id); + printf(") returned zone with ID "); + uprintf(str); + printf("\n"); + exit(1); + } + return zone; +} + +int main(int argc, char **argv) { + + Calendar *cal; + TimeZone *zone; + DateFormat *fmt; + UErrorCode status = U_ZERO_ERROR; + UnicodeString str; + UDate date; + + // The languages in which we will display the date + static char* LANGUAGE[] = { + "en", "de", "fr" + }; + static const int32_t N_LANGUAGE = sizeof(LANGUAGE)/sizeof(LANGUAGE[0]); + + // The time zones in which we will display the time + static char* TIMEZONE[] = { + "America/Los_Angeles", + "America/New_York", + "Europe/Paris", + "Europe/Berlin" + }; + static const int32_t N_TIMEZONE = sizeof(TIMEZONE)/sizeof(TIMEZONE[0]); + + // Create a calendar + cal = Calendar::createInstance(status); + check(status, "Calendar::createInstance"); + zone = createZone("GMT"); // Create a GMT zone + cal->adoptTimeZone(zone); + cal->clear(); + cal->set(1999, Calendar::JUNE, 4); + date = cal->getTime(status); + check(status, "Calendar::getTime"); + + for (int32_t i=0; i<N_LANGUAGE; ++i) { + Locale loc(LANGUAGE[i]); + + // Create a formatter for DATE + fmt = DateFormat::createDateInstance(DateFormat::kFull, loc); + + // Format the date + str.remove(); + fmt->format(date, str, status); + + // Display the formatted date string + printf("Date (%s): ", LANGUAGE[i]); + uprintf(escape(str)); + printf("\n\n"); + } + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/datefmt/answers/main_3.cpp b/Build/source/libs/icu/icu-xetex/samples/datefmt/answers/main_3.cpp new file mode 100644 index 00000000000..e7776836277 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/datefmt/answers/main_3.cpp @@ -0,0 +1,96 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" + +/** + * If the ID supplied to TimeZone is not a valid system ID, + * TimeZone::createTimeZone() will return a GMT zone object. In order + * to detect this error, we check the ID of the returned zone against + * the ID we requested. If they don't match, we fail with an error. + */ +TimeZone* createZone(const UnicodeString& id) { + UnicodeString str; + TimeZone* zone = TimeZone::createTimeZone(id); + if (zone->getID(str) != id) { + delete zone; + printf("Error: TimeZone::createTimeZone("); + uprintf(id); + printf(") returned zone with ID "); + uprintf(str); + printf("\n"); + exit(1); + } + return zone; +} + +int main(int argc, char **argv) { + + Calendar *cal; + TimeZone *zone; + DateFormat *fmt; + UErrorCode status = U_ZERO_ERROR; + UnicodeString str; + UDate date; + + // The languages in which we will display the date + static char* LANGUAGE[] = { + "en", "de", "fr" + }; + static const int32_t N_LANGUAGE = sizeof(LANGUAGE)/sizeof(LANGUAGE[0]); + + // The time zones in which we will display the time + static char* TIMEZONE[] = { + "America/Los_Angeles", + "America/New_York", + "Europe/Paris", + "Europe/Berlin" + }; + static const int32_t N_TIMEZONE = sizeof(TIMEZONE)/sizeof(TIMEZONE[0]); + + // Create a calendar + cal = Calendar::createInstance(status); + check(status, "Calendar::createInstance"); + zone = createZone("GMT"); // Create a GMT zone + cal->adoptTimeZone(zone); + cal->clear(); + cal->set(1999, Calendar::JUNE, 4); + date = cal->getTime(status); + check(status, "Calendar::getTime"); + + for (int32_t i=0; i<N_LANGUAGE; ++i) { + Locale loc(LANGUAGE[i]); + + // Create a formatter for DATE and TIME + fmt = DateFormat::createDateTimeInstance( + DateFormat::kFull, DateFormat::kFull, loc); + + for (int32_t j=0; j<N_TIMEZONE; ++j) { + + cal->adoptTimeZone(createZone(TIMEZONE[j])); + fmt->setCalendar(*cal); + + // Format the date + str.remove(); + fmt->format(date, str, status); + + // Display the formatted date string + printf("Date (%s, %s): ", LANGUAGE[i], TIMEZONE[j]); + uprintf(escape(str)); + printf("\n\n"); + } + + delete fmt; + } + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/datefmt/datefmt.sln b/Build/source/libs/icu/icu-xetex/samples/datefmt/datefmt.sln new file mode 100644 index 00000000000..4ba47593e58 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/datefmt/datefmt.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "datefmt", "datefmt.vcproj", "{6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Debug|Win32.ActiveCfg = Debug|Win32 + {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Debug|Win32.Build.0 = Debug|Win32 + {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Release|Win32.ActiveCfg = Release|Win32 + {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/datefmt/datefmt.vcproj b/Build/source/libs/icu/icu-xetex/samples/datefmt/datefmt.vcproj new file mode 100644 index 00000000000..8c420385aef --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/datefmt/datefmt.vcproj @@ -0,0 +1,227 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="datefmt" + ProjectGUID="{6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <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" + TypeLibraryName=".\Debug/datefmt.tlb" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Debug/datefmt.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/datefmt.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/datefmt.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="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" + TypeLibraryName=".\Release/datefmt.tlb" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE" + StringPooling="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Release/datefmt.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/datefmt.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + ProgramDatabaseFile=".\Release/datefmt.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=".\main.cpp" + > + </File> + <File + RelativePath=".\util.cpp" + > + </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/datefmt/main.cpp b/Build/source/libs/icu/icu-xetex/samples/datefmt/main.cpp new file mode 100644 index 00000000000..e004f9c1307 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/datefmt/main.cpp @@ -0,0 +1,96 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2003, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" + +/** + * If the ID supplied to TimeZone is not a valid system ID, + * TimeZone::createTimeZone() will return a GMT zone object. In order + * to detect this error, we check the ID of the returned zone against + * the ID we requested. If they don't match, we fail with an error. + */ +TimeZone* createZone(const UnicodeString& id) { + UnicodeString str; + TimeZone* zone = TimeZone::createTimeZone(id); + if (zone->getID(str) != id) { + delete zone; + printf("Error: TimeZone::createTimeZone("); + uprintf(id); + printf(") returned zone with ID "); + uprintf(str); + printf("\n"); + exit(1); + } + return zone; +} + +int main(int argc, char **argv) { + + Calendar *cal; + TimeZone *zone; + DateFormat *fmt; + UErrorCode status = U_ZERO_ERROR; + UnicodeString str; + UDate date; + + // The languages in which we will display the date + static char* LANGUAGE[] = { + "en", "de", "fr" + }; + static const int32_t N_LANGUAGE = sizeof(LANGUAGE)/sizeof(LANGUAGE[0]); + + // The time zones in which we will display the time + static char* TIMEZONE[] = { + "America/Los_Angeles", + "America/New_York", + "Europe/Paris", + "Europe/Berlin" + }; + static const int32_t N_TIMEZONE = sizeof(TIMEZONE)/sizeof(TIMEZONE[0]); + + // Create a calendar + cal = Calendar::createInstance(status); + check(status, "Calendar::createInstance"); + zone = createZone("GMT"); // Create a GMT zone + cal->adoptTimeZone(zone); + cal->clear(); + cal->set(1999, Calendar::JUNE, 4); + date = cal->getTime(status); + check(status, "Calendar::getTime"); + + for (int32_t i=0; i<N_LANGUAGE; ++i) { + Locale loc(LANGUAGE[i]); + + // Create a formatter for DATE and TIME + fmt = DateFormat::createDateTimeInstance( + DateFormat::kFull, DateFormat::kFull, loc); + + for (int32_t j=0; j<N_TIMEZONE; ++j) { + + cal->adoptTimeZone(createZone(TIMEZONE[j])); + fmt->setCalendar(*cal); + + // Format the date + str.remove(); + fmt->format(date, str, status); + + // Display the formatted date string + printf("Date (%s, %s): ", LANGUAGE[i], TIMEZONE[j]); + uprintf(escape(str)); + printf("\n\n"); + } + + delete fmt; + } + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/datefmt/util.cpp b/Build/source/libs/icu/icu-xetex/samples/datefmt/util.cpp new file mode 100644 index 00000000000..25a8f0224d4 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/datefmt/util.cpp @@ -0,0 +1,63 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include <stdio.h> +#include <stdlib.h> + +// Verify that a UErrorCode is successful; exit(1) if not +void check(UErrorCode& status, const char* msg) { + if (U_FAILURE(status)) { + printf("ERROR: %s (%s)\n", u_errorName(status), msg); + exit(1); + } + // printf("Ok: %s\n", msg); +} + +// Append a hex string to the target +static UnicodeString& appendHex(uint32_t number, + int8_t digits, + UnicodeString& target) { + static const UnicodeString DIGIT_STRING("0123456789ABCDEF"); + while (digits > 0) { + target += DIGIT_STRING[(number >> ((--digits) * 4)) & 0xF]; + } + return target; +} + +// Replace nonprintable characters with unicode escapes +UnicodeString escape(const UnicodeString &source) { + int32_t i; + UnicodeString target; + target += "\""; + for (i=0; i<source.length(); ++i) { + UChar ch = source[i]; + if (ch < 0x09 || (ch > 0x0A && ch < 0x20) || ch > 0x7E) { + target += "\\u"; + appendHex(ch, 4, target); + } else { + target += ch; + } + } + target += "\""; + return target; +} + +// Print the given string to stdout +void uprintf(const UnicodeString &str) { + char *buf = 0; + int32_t len = str.length(); + // int32_t bufLen = str.extract(0, len, buf); // Preflight + /* Preflighting seems to be broken now, so assume 1-1 conversion, + plus some slop. */ + int32_t bufLen = len + 16; + int32_t actualLen; + buf = new char[bufLen + 1]; + actualLen = str.extract(0, len, buf/*, bufLen*/); // Default codepage conversion + buf[actualLen] = 0; + printf("%s", buf); + delete buf; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/datefmt/util.h b/Build/source/libs/icu/icu-xetex/samples/datefmt/util.h new file mode 100644 index 00000000000..2d9c4c724e2 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/datefmt/util.h @@ -0,0 +1,16 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" + +// Verify that a UErrorCode is successful; exit(1) if not +void check(UErrorCode& status, const char* msg); + +// Replace nonprintable characters with unicode escapes +UnicodeString escape(const UnicodeString &source); + +// Print the given string to stdout +void uprintf(const UnicodeString &str); diff --git a/Build/source/libs/icu/icu-xetex/samples/defs.mk b/Build/source/libs/icu/icu-xetex/samples/defs.mk new file mode 100644 index 00000000000..7b91c4ba1ad --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/defs.mk @@ -0,0 +1,28 @@ +# Copyright (c) 2002-2005 IBM, Inc. and others +# Sample code makefile definitions + +CLEANFILES=*~ $(TARGET).out +#################################################################### +# Load ICU information. You can copy this to other makefiles ####### +#################################################################### +CC=$(shell icu-config --cc) +CXX=$(shell icu-config --cxx) +CPPFLAGS=$(shell icu-config --cppflags) +CFLAGS=$(shell icu-config --cflags) +CXXFLAGS=$(shell icu-config --cxxflags) +LDFLAGS =$(shell icu-config --ldflags) +LDFLAGS_USTDIO =$(shell icu-config --ldflags-icuio) +INVOKE=$(shell icu-config --invoke) +GENRB=$(shell icu-config --invoke=genrb) +GENRBOPT= +PKGDATA=$(shell icu-config --invoke=pkgdata) +SO=$(shell icu-config --so) +PKGDATAOPTS=-v -d . +# default - resources in same mode as ICU +RESMODE=$(shell icu-config --icudata-mode) + +#################################################################### +### Project independent things (common) +### We depend on gmake for the bulk of the work + +RMV=rm -rf diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/FontMap.GDI b/Build/source/libs/icu/icu-xetex/samples/layout/FontMap.GDI new file mode 100644 index 00000000000..198c02218a7 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/FontMap.GDI @@ -0,0 +1,11 @@ +# Copyright (C) 2001-2005, International Business Machines +# Corporation and others. All Rights Reserved. +# +# This is a sample FontMap file for Windows. +# Fonts are specified by font name, as shown +# in the "Fonts" folder. + + DEVANAGARI: Raghindi + THAI: AngsanaDSE + DEFAULT: Code2000 + diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/FontMap.Gnome b/Build/source/libs/icu/icu-xetex/samples/layout/FontMap.Gnome new file mode 100644 index 00000000000..1f57bb4814d --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/FontMap.Gnome @@ -0,0 +1,8 @@ +# Copyright (C) 2001-2005, International Business Machines +# Corporation and others. All Rights Reserved. +# This is a sample FontMap file for Linux. +# Fonts are specified by file names. + + DEVANAGARI: raghu.ttf + THAI: angsd___.ttf + DEFAULT: CODE2000.TTF diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/FontMap.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/FontMap.cpp new file mode 100644 index 00000000000..1510b29b2da --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/FontMap.cpp @@ -0,0 +1,287 @@ +/* + ****************************************************************************** + * Copyright (C) 1998-2006, International Business Machines Corporation and * + * others. All Rights Reserved. * + ****************************************************************************** + */ + +#include <stdio.h> +#include <string.h> +#include <ctype.h> + +#include "unicode/utypes.h" +#include "unicode/uscript.h" + +#include "layout/LETypes.h" +#include "layout/LEScripts.h" +#include "layout/LEFontInstance.h" + +#include "GUISupport.h" +#include "FontMap.h" + +FontMap::FontMap(const char *fileName, le_int16 pointSize, GUISupport *guiSupport, LEErrorCode &status) + : fPointSize(pointSize), fFontCount(0), fAscent(0), fDescent(0), fLeading(0), fGUISupport(guiSupport) +{ + le_int32 defaultFont = -1, i, script; + le_bool haveFonts = FALSE; + +/**/ + for (i = 0; i < scriptCodeCount; i += 1) { + fFontIndices[i] = -1; + fFontNames[i] = NULL; + fFontInstances[i] = NULL; + } + /**/ + + if (LE_FAILURE(status)) { + return; + } + + char *c, *scriptName, *fontName, *line, buffer[BUFFER_SIZE]; + FILE *file; + + file = fopen(fileName, "r"); + + if (file == NULL) { + sprintf(errorMessage, "Could not open the font map file: %s.", fileName); + fGUISupport->postErrorMessage(errorMessage, "Font Map Error"); + status = LE_FONT_FILE_NOT_FOUND_ERROR; + return; + } + + while (fgets(buffer, BUFFER_SIZE, file) != NULL) { + UScriptCode scriptCode; + UErrorCode scriptStatus = U_ZERO_ERROR; + + line = strip(buffer); + if (line[0] == '#' || line[0] == 0) { + continue; + } + + c = strchr(line, ':'); + c[0] = 0; + + fontName = strip(&c[1]); + scriptName = strip(line); + + if (strcmp(scriptName, "DEFAULT") == 0) { + defaultFont = getFontIndex(fontName); + haveFonts = TRUE; + continue; + } + + le_int32 fillCount = uscript_getCode(scriptName, &scriptCode, 1, &scriptStatus); + + if (U_FAILURE(scriptStatus) || fillCount <= 0 || + scriptStatus == U_USING_FALLBACK_WARNING || scriptStatus == U_USING_DEFAULT_WARNING) { + sprintf(errorMessage, "The script name %s is invalid.", line); + fGUISupport->postErrorMessage(errorMessage, "Font Map Error"); + continue; + } + + script = (le_int32) scriptCode; + + if (fFontIndices[script] >= 0) { + // FIXME: complain that this is a duplicate entry and bail (?) + fFontIndices[script] = -1; + } + + fFontIndices[script] = getFontIndex(fontName); + haveFonts = TRUE; + } + + if (defaultFont >= 0) { + for (script = 0; script < scriptCodeCount; script += 1) { + if (fFontIndices[script] < 0) { + fFontIndices[script] = defaultFont; + } + } + } + + if (! haveFonts) { + sprintf(errorMessage, "The font map file %s does not contain any valid scripts.", fileName); + fGUISupport->postErrorMessage(errorMessage, "Font Map Error"); + status = LE_ILLEGAL_ARGUMENT_ERROR; + } + + fclose(file); +} + +FontMap::~FontMap() +{ + le_int32 font; + + for (font = 0; font < fFontCount; font += 1) { + if (fFontNames[font] != NULL) { + delete[] (char *) fFontNames[font]; + } + } + + for (font = 0; font < fFontCount; font += 1) { + if (fFontInstances[font] != NULL) { + delete fFontInstances[font]; + } + } +} + +le_int32 FontMap::getFontIndex(const char *fontName) +{ + le_int32 index; + + for (index = 0; index < fFontCount; index += 1) { + if (strcmp(fontName, fFontNames[index]) == 0) { + return index; + } + } + + if (fFontCount < (le_int32) scriptCodeCount) { + index = fFontCount++; + } else { + // The font name table is full. Since there can + // only be scriptCodeCount fonts in use at once, + // there should be at least one that's not being + // referenced; find it and resue it's index. + + for (index = 0; index < fFontCount; index += 1) { + le_int32 script; + + for (script = 0; script < scriptCodeCount; script += 1) { + if (fFontIndices[script] == index) { + break; + } + } + + if (script >= scriptCodeCount) { + break; + } + } + } + + if (index >= scriptCodeCount) { + return -1; + } + + le_int32 len = strlen(fontName); + char *s = new char[len + 1]; + + fFontNames[index] = strcpy(s, fontName); + return index; +} + +char *FontMap::strip(char *s) +{ + le_int32 start, end, len; + + start = 0; + len = strlen(s); + + while (start < len && isspace(s[start])) { + start += 1; + } + + end = len - 1; + + while (end > start && isspace(s[end])) { + end -= 1; + } + + if (end < len) { + s[end + 1] = '\0'; + } + + return &s[start]; +} + +const LEFontInstance *FontMap::getScriptFont(le_int32 scriptCode, LEErrorCode &status) +{ + if (LE_FAILURE(status)) { + return NULL; + } + + if (scriptCode <= -1 || scriptCode >= scriptCodeCount) { + status = LE_ILLEGAL_ARGUMENT_ERROR; + return NULL; + } + + + le_int32 fontIndex = fFontIndices[scriptCode]; + + if (fontIndex < 0) { + sprintf(errorMessage, "No font was set for script %s", uscript_getName((UScriptCode) scriptCode)); + fGUISupport->postErrorMessage(errorMessage, "Font Map Error"); + status = LE_FONT_FILE_NOT_FOUND_ERROR; + return NULL; + } + + if (fFontInstances[fontIndex] == NULL) { + fFontInstances[fontIndex] = openFont(fFontNames[fontIndex], fPointSize, status); + + if (LE_FAILURE(status)) { + sprintf(errorMessage, "Could not open font file %s", fFontNames[fontIndex]); + fGUISupport->postErrorMessage(errorMessage, "Font Map Error"); + return NULL; + } + } + + return fFontInstances[fontIndex]; +} + +le_int32 FontMap::getAscent() const +{ + if (fAscent <= 0) { + ((FontMap *) this)->getMaxMetrics(); + } + + return fAscent; +} + +le_int32 FontMap::getDescent() const +{ + if (fDescent <= 0) { + ((FontMap *) this)->getMaxMetrics(); + } + + return fDescent; +} + +le_int32 FontMap::getLeading() const +{ + if (fLeading <= 0) { + ((FontMap *) this)->getMaxMetrics(); + } + + return fLeading; +} + +void FontMap::getMaxMetrics() +{ + for (le_int32 i = 0; i < fFontCount; i += 1) { + LEErrorCode status = LE_NO_ERROR; + le_int32 ascent, descent, leading; + + if (fFontInstances[i] == NULL) { + fFontInstances[i] = openFont(fFontNames[i], fPointSize, status); + + if (LE_FAILURE(status)) { + continue; + } + } + + ascent = fFontInstances[i]->getAscent(); + descent = fFontInstances[i]->getDescent(); + leading = fFontInstances[i]->getLeading(); + + if (ascent > fAscent) { + fAscent = ascent; + } + + if (descent > fDescent) { + fDescent = descent; + } + + if (leading > fLeading) { + fLeading = leading; + } + } +} + diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/FontMap.h b/Build/source/libs/icu/icu-xetex/samples/layout/FontMap.h new file mode 100644 index 00000000000..fa80ebfd090 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/FontMap.h @@ -0,0 +1,66 @@ +/* + ****************************************************************************** + * Copyright (C) 1998-2003, International Business Machines Corporation and * + * others. All Rights Reserved. * + ****************************************************************************** + */ + +#ifndef __FONTMAP_H +#define __FONTMAP_H + +#include "layout/LETypes.h" +#include "layout/LEScripts.h" +#include "layout/LEFontInstance.h" + +#include "GUISupport.h" + +#define BUFFER_SIZE 128 + +class FontMap +{ +public: + FontMap(const char *fileName, le_int16 pointSize, GUISupport *guiSupport, LEErrorCode &status); + + virtual ~FontMap(); + + virtual const LEFontInstance *getScriptFont(le_int32 scriptCode, LEErrorCode &status); + + virtual le_int16 getPointSize() const; + + virtual le_int32 getAscent() const; + + virtual le_int32 getDescent() const; + + virtual le_int32 getLeading() const; + +protected: + virtual const LEFontInstance *openFont(const char *fontName, le_int16 pointSize, LEErrorCode &status) = 0; + + char errorMessage[256]; + +private: + static char *strip(char *s); + le_int32 getFontIndex(const char *fontName); + void getMaxMetrics(); + + le_int16 fPointSize; + le_int32 fFontCount; + + le_int32 fAscent; + le_int32 fDescent; + le_int32 fLeading; + + GUISupport *fGUISupport; + + const LEFontInstance *fFontInstances[scriptCodeCount]; + const char *fFontNames[scriptCodeCount]; + le_int32 fFontIndices[scriptCodeCount]; +}; + +inline le_int16 FontMap::getPointSize() const +{ + return fPointSize; +} + +#endif + diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/FontTableCache.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/FontTableCache.cpp new file mode 100644 index 00000000000..75130ff3af1 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/FontTableCache.cpp @@ -0,0 +1,86 @@ +/* + ********************************************************************** + * Copyright (C) 2003, International Business Machines + * Corporation and others. All Rights Reserved. + ********************************************************************** + */ + +#include "layout/LETypes.h" + +#include "FontTableCache.h" + +#define TABLE_CACHE_INIT 5 +#define TABLE_CACHE_GROW 5 + +struct FontTableCacheEntry +{ + LETag tag; + const void *table; +}; + +FontTableCache::FontTableCache() + : fTableCacheCurr(0), fTableCacheSize(TABLE_CACHE_INIT) +{ + fTableCache = LE_NEW_ARRAY(FontTableCacheEntry, fTableCacheSize); + + if (fTableCache == NULL) { + fTableCacheSize = 0; + return; + } + + for (int i = 0; i < fTableCacheSize; i += 1) { + fTableCache[i].tag = 0; + fTableCache[i].table = NULL; + } +} + +FontTableCache::~FontTableCache() +{ + for (int i = fTableCacheCurr - 1; i >= 0; i -= 1) { + LE_DELETE_ARRAY(fTableCache[i].table); + + fTableCache[i].tag = 0; + fTableCache[i].table = NULL; + } + + fTableCacheCurr = 0; + + LE_DELETE_ARRAY(fTableCache); + fTableCache = NULL; +} + +const void *FontTableCache::find(LETag tableTag) const +{ + for (int i = 0; i < fTableCacheCurr; i += 1) { + if (fTableCache[i].tag == tableTag) { + return fTableCache[i].table; + } + } + + const void *table = readFontTable(tableTag); + + ((FontTableCache *) this)->add(tableTag, table); + + return table; +} + +void FontTableCache::add(LETag tableTag, const void *table) +{ + if (fTableCacheCurr >= fTableCacheSize) { + le_int32 newSize = fTableCacheSize + TABLE_CACHE_GROW; + + fTableCache = (FontTableCacheEntry *) LE_GROW_ARRAY(fTableCache, newSize); + + for (le_int32 i = fTableCacheSize; i < newSize; i += 1) { + fTableCache[i].tag = 0; + fTableCache[i].table = NULL; + } + + fTableCacheSize = newSize; + } + + fTableCache[fTableCacheCurr].tag = tableTag; + fTableCache[fTableCacheCurr].table = table; + + fTableCacheCurr += 1; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/FontTableCache.h b/Build/source/libs/icu/icu-xetex/samples/layout/FontTableCache.h new file mode 100644 index 00000000000..bb85eeb011d --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/FontTableCache.h @@ -0,0 +1,38 @@ +/* + ********************************************************************** + * Copyright (C) 2003, International Business Machines + * Corporation and others. All Rights Reserved. + ********************************************************************** + */ + +#ifndef __FONTTABLECACHE_H + +#define __FONTTABLECACHE_H + +#include "layout/LETypes.h" + +struct FontTableCacheEntry; + +class FontTableCache +{ +public: + FontTableCache(); + + virtual ~FontTableCache(); + + const void *find(LETag tableTag) const; + +protected: + virtual const void *readFontTable(LETag tableTag) const = 0; + +private: + + void add(LETag tableTag, const void *table); + + FontTableCacheEntry *fTableCache; + le_int32 fTableCacheCurr; + le_int32 fTableCacheSize; +}; + +#endif + diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/GDIFontInstance.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/GDIFontInstance.cpp new file mode 100644 index 00000000000..d3451e9a575 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/GDIFontInstance.cpp @@ -0,0 +1,378 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2006, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: GDIFontInstance.cpp + * + * created on: 08/09/2000 + * created by: Eric R. Mader + */ + +#include <windows.h> + +#include "layout/LETypes.h" +#include "layout/LESwaps.h" +#include "layout/LEFontInstance.h" + +#include "GDIFontInstance.h" +#include "sfnt.h" +#include "cmaps.h" + +GDISurface::GDISurface(HDC theHDC) + : fHdc(theHDC), fCurrentFont(NULL) +{ + // nothing else to do +} + +GDISurface::~GDISurface() +{ + // nothing to do +} + +void GDISurface::setHDC(HDC theHDC) +{ + fHdc = theHDC; + fCurrentFont = NULL; +} + +void GDISurface::setFont(const GDIFontInstance *font) +{ +#if 0 + if (fCurrentFont != font) { + fCurrentFont = font; + SelectObject(fHdc, font->getFont()); + } +#else + SelectObject(fHdc, font->getFont()); +#endif +} + +void GDISurface::drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs, le_int32 count, const float *positions, + le_int32 x, le_int32 y, le_int32 width, le_int32 height) +{ + TTGlyphID *ttGlyphs = LE_NEW_ARRAY(TTGlyphID, count); + le_int32 *dx = LE_NEW_ARRAY(le_int32, count); + float *ps = LE_NEW_ARRAY(float, count * 2 + 2); + le_int32 out = 0; + RECT clip; + + clip.top = 0; + clip.left = 0; + clip.bottom = height; + clip.right = width; + + for (le_int32 g = 0; g < count; g += 1) { + TTGlyphID ttGlyph = (TTGlyphID) LE_GET_GLYPH(glyphs[g]); + + if (ttGlyph < 0xFFFE) { + ttGlyphs[out] = ttGlyph; + dx[out] = (le_int32) (positions[g * 2 + 2] - positions[g * 2]); + ps[out * 2] = positions[g * 2]; + ps[out * 2 + 1] = positions[g * 2 + 1]; + out += 1; + } + } + + le_int32 dyStart, dyEnd; + + setFont((GDIFontInstance *) font); + + dyStart = dyEnd = 0; + + while (dyEnd < out) { + float yOffset = ps[dyStart * 2 + 1]; + float xOffset = ps[dyStart * 2]; + + while (dyEnd < out && yOffset == ps[dyEnd * 2 + 1]) { + dyEnd += 1; + } + + ExtTextOut(fHdc, x + (le_int32) xOffset, y + (le_int32) yOffset - font->getAscent(), ETO_CLIPPED | ETO_GLYPH_INDEX, &clip, + (LPCWSTR) &ttGlyphs[dyStart], dyEnd - dyStart, (INT *) &dx[dyStart]); + + dyStart = dyEnd; + } + + LE_DELETE_ARRAY(ps); + LE_DELETE_ARRAY(dx); + LE_DELETE_ARRAY(ttGlyphs); +} + +GDIFontInstance::GDIFontInstance(GDISurface *surface, TCHAR *faceName, le_int16 pointSize, LEErrorCode &status) + : FontTableCache(), fSurface(surface), fFont(NULL), + fPointSize(pointSize), fUnitsPerEM(0), fAscent(0), fDescent(0), fLeading(0), + fDeviceScaleX(1), fDeviceScaleY(1), fMapper(NULL) +{ + LOGFONT lf; + FLOAT dpiX, dpiY; + POINT pt; + OUTLINETEXTMETRIC otm; + HDC hdc = surface->getHDC(); + + if (LE_FAILURE(status)) { + return; + } + + SaveDC(hdc); + + SetGraphicsMode(hdc, GM_ADVANCED); + ModifyWorldTransform(hdc, NULL, MWT_IDENTITY); + SetViewportOrgEx(hdc, 0, 0, NULL); + SetWindowOrgEx(hdc, 0, 0, NULL); + + dpiX = (FLOAT) GetDeviceCaps(hdc, LOGPIXELSX); + dpiY = (FLOAT) GetDeviceCaps(hdc, LOGPIXELSY); + +#if 1 + pt.x = (int) (pointSize * dpiX / 72); + pt.y = (int) (pointSize * dpiY / 72); + + DPtoLP(hdc, &pt, 1); +#else + pt.x = pt.y = pointSize; +#endif + + lf.lfHeight = - pt.y; + lf.lfWidth = 0; + lf.lfEscapement = 0; + lf.lfOrientation = 0; + lf.lfWeight = 0; + lf.lfItalic = 0; + lf.lfUnderline = 0; + lf.lfStrikeOut = 0; + lf.lfCharSet = DEFAULT_CHARSET; + lf.lfOutPrecision = 0; + lf.lfClipPrecision = 0; + lf.lfQuality = 0; + lf.lfPitchAndFamily = 0; + + lstrcpy(lf.lfFaceName, faceName); + + fFont = CreateFontIndirect(&lf); + + if (fFont == NULL) { + status = LE_FONT_FILE_NOT_FOUND_ERROR; + return; + } + + SelectObject(hdc, fFont); + + UINT ret = GetOutlineTextMetrics(hdc, sizeof otm, &otm); + + if (ret == 0) { + status = LE_MISSING_FONT_TABLE_ERROR; + goto restore; + } + + fUnitsPerEM = otm.otmEMSquare; + fAscent = otm.otmTextMetrics.tmAscent; + fDescent = otm.otmTextMetrics.tmDescent; + fLeading = otm.otmTextMetrics.tmExternalLeading; + + status = initMapper(); + + if (LE_FAILURE(status)) { + goto restore; + } + +#if 0 + status = initFontTableCache(); +#endif + +restore: + RestoreDC(hdc, -1); +} + +GDIFontInstance::GDIFontInstance(GDISurface *surface, const char *faceName, le_int16 pointSize, LEErrorCode &status) + : FontTableCache(), fSurface(surface), fFont(NULL), + fPointSize(pointSize), fUnitsPerEM(0), fAscent(0), fDescent(0), fLeading(0), + fDeviceScaleX(1), fDeviceScaleY(1), fMapper(NULL) +{ + LOGFONTA lf; + FLOAT dpiX, dpiY; + POINT pt; + OUTLINETEXTMETRIC otm; + HDC hdc = surface->getHDC(); + + if (LE_FAILURE(status)) { + return; + } + + SaveDC(hdc); + + SetGraphicsMode(hdc, GM_ADVANCED); + ModifyWorldTransform(hdc, NULL, MWT_IDENTITY); + SetViewportOrgEx(hdc, 0, 0, NULL); + SetWindowOrgEx(hdc, 0, 0, NULL); + + dpiX = (FLOAT) GetDeviceCaps(hdc, LOGPIXELSX); + dpiY = (FLOAT) GetDeviceCaps(hdc, LOGPIXELSY); + + fDeviceScaleX = dpiX / 72; + fDeviceScaleY = dpiY / 72; + +#if 1 + pt.x = (int) (pointSize * fDeviceScaleX); + pt.y = (int) (pointSize * fDeviceScaleY); + + DPtoLP(hdc, &pt, 1); +#else + pt.x = pt.y = pointSize; +#endif + + lf.lfHeight = - pt.y; + lf.lfWidth = 0; + lf.lfEscapement = 0; + lf.lfOrientation = 0; + lf.lfWeight = 0; + lf.lfItalic = 0; + lf.lfUnderline = 0; + lf.lfStrikeOut = 0; + lf.lfCharSet = DEFAULT_CHARSET; + lf.lfOutPrecision = 0; + lf.lfClipPrecision = 0; + lf.lfQuality = 0; + lf.lfPitchAndFamily = 0; + + strcpy(lf.lfFaceName, faceName); + + fFont = CreateFontIndirectA(&lf); + + if (fFont == NULL) { + status = LE_FONT_FILE_NOT_FOUND_ERROR; + return; + } + + SelectObject(hdc, fFont); + + UINT ret = GetOutlineTextMetrics(hdc, sizeof otm, &otm); + + if (ret == 0) { + status = LE_MISSING_FONT_TABLE_ERROR; + goto restore; + } + + fUnitsPerEM = otm.otmEMSquare; + fAscent = otm.otmTextMetrics.tmAscent; + fDescent = otm.otmTextMetrics.tmDescent; + fLeading = otm.otmTextMetrics.tmExternalLeading; + + status = initMapper(); + + if (LE_FAILURE(status)) { + goto restore; + } + +#if 0 + status = initFontTableCache(); +#endif + +restore: + RestoreDC(hdc, -1); +} + +GDIFontInstance::~GDIFontInstance() +{ +#if 0 + flushFontTableCache(); + delete[] fTableCache; +#endif + + if (fFont != NULL) { + // FIXME: call RemoveObject first? + DeleteObject(fFont); + } + + delete fMapper; + fMapper = NULL; +} + +LEErrorCode GDIFontInstance::initMapper() +{ + LETag cmapTag = LE_CMAP_TABLE_TAG; + const CMAPTable *cmap = (const CMAPTable *) readFontTable(cmapTag); + + if (cmap == NULL) { + return LE_MISSING_FONT_TABLE_ERROR; + } + + fMapper = CMAPMapper::createUnicodeMapper(cmap); + + if (fMapper == NULL) { + return LE_MISSING_FONT_TABLE_ERROR; + } + + return LE_NO_ERROR; +} + +const void *GDIFontInstance::getFontTable(LETag tableTag) const +{ + return FontTableCache::find(tableTag); +} + +const void *GDIFontInstance::readFontTable(LETag tableTag) const +{ + fSurface->setFont(this); + + HDC hdc = fSurface->getHDC(); + DWORD stag = SWAPL(tableTag); + DWORD len = GetFontData(hdc, stag, 0, NULL, 0); + void *result = NULL; + + if (len != GDI_ERROR) { + result = LE_NEW_ARRAY(char, len); + GetFontData(hdc, stag, 0, result, len); + } + + return result; +} + +void GDIFontInstance::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const +{ + advance.fX = 0; + advance.fY = 0; + + if (glyph == 0xFFFE || glyph == 0xFFFF) { + return; + } + + + GLYPHMETRICS metrics; + DWORD result; + MAT2 identity = {{0, 1}, {0, 0}, {0, 0}, {0, 1}}; + HDC hdc = fSurface->getHDC(); + + fSurface->setFont(this); + + result = GetGlyphOutline(hdc, glyph, GGO_GLYPH_INDEX | GGO_METRICS, &metrics, 0, NULL, &identity); + + if (result == GDI_ERROR) { + return; + } + + advance.fX = metrics.gmCellIncX; + return; +} + +le_bool GDIFontInstance::getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const +{ +#if 0 + hsFixedPoint2 pt; + le_bool result; + + result = fFontInstance->getGlyphPoint(glyph, pointNumber, pt); + + if (result) { + point.fX = xUnitsToPoints(pt.fX); + point.fY = yUnitsToPoints(pt.fY); + } + + return result; +#else + return FALSE; +#endif +} + diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/GDIFontInstance.h b/Build/source/libs/icu/icu-xetex/samples/layout/GDIFontInstance.h new file mode 100644 index 00000000000..7b677e77262 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/GDIFontInstance.h @@ -0,0 +1,156 @@ + +/* + ******************************************************************************* + * + * Copyright (C) 1999-2003, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: GDIFontInstance.h + * + * created on: 08/09/2000 + * created by: Eric R. Mader + */ + +#ifndef __GDIFONTINSTANCE_H +#define __GDIFONTINSTANCE_H + +#include <windows.h> + +#include "layout/LETypes.h" +#include "layout/LEFontInstance.h" +#include "RenderingSurface.h" +#include "FontTableCache.h" +#include "cmaps.h" + +class GDIFontInstance; + +class GDISurface : public RenderingSurface +{ +public: + GDISurface(HDC theHDC); + virtual ~GDISurface(); + + virtual void drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs, le_int32 count, + const float *positions, le_int32 x, le_int32 y, le_int32 width, le_int32 height); + + void setFont(const GDIFontInstance *font); + HDC getHDC() const; + void setHDC(HDC theHDC); + +private: + HDC fHdc; + const GDIFontInstance *fCurrentFont; +}; + +inline HDC GDISurface::getHDC() const +{ + return fHdc; +} + +class GDIFontInstance : public LEFontInstance, protected FontTableCache +{ +protected: + GDISurface *fSurface; + HFONT fFont; + + le_int32 fPointSize; + le_int32 fUnitsPerEM; + le_int32 fAscent; + le_int32 fDescent; + le_int32 fLeading; + + float fDeviceScaleX; + float fDeviceScaleY; + + CMAPMapper *fMapper; + + virtual const void *readFontTable(LETag tableTag) const; + + virtual LEErrorCode initMapper(); + +public: + GDIFontInstance(GDISurface *surface, TCHAR *faceName, le_int16 pointSize, LEErrorCode &status); + GDIFontInstance(GDISurface *surface, const char *faceName, le_int16 pointSize, LEErrorCode &status); + //GDIFontInstance(GDISurface *surface, le_int16 pointSize); + + virtual ~GDIFontInstance(); + + HFONT getFont() const; + + virtual const void *getFontTable(LETag tableTag) const; + + virtual le_int32 getUnitsPerEM() const; + + virtual le_int32 getAscent() const; + + virtual le_int32 getDescent() const; + + virtual le_int32 getLeading() const; + + virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const; + + virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const; + + virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const; + + float getXPixelsPerEm() const; + + float getYPixelsPerEm() const; + + float getScaleFactorX() const; + + float getScaleFactorY() const; +}; + +inline HFONT GDIFontInstance::getFont() const +{ + return fFont; +} + +inline le_int32 GDIFontInstance::getUnitsPerEM() const +{ + return fUnitsPerEM; +} + +inline le_int32 GDIFontInstance::getAscent() const +{ + return fAscent; +} + +inline le_int32 GDIFontInstance::getDescent() const +{ + return fDescent; +} + +inline le_int32 GDIFontInstance::getLeading() const +{ + return fLeading; +} + +inline LEGlyphID GDIFontInstance::mapCharToGlyph(LEUnicode32 ch) const +{ + return fMapper->unicodeToGlyph(ch); +} + +inline float GDIFontInstance::getXPixelsPerEm() const +{ + return (float) fPointSize; +} + +inline float GDIFontInstance::getYPixelsPerEm() const +{ + return (float) fPointSize; +} + +inline float GDIFontInstance::getScaleFactorX() const +{ + return fDeviceScaleX; +} + +inline float GDIFontInstance::getScaleFactorY() const +{ + return fDeviceScaleY; +} + +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/GDIFontMap.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/GDIFontMap.cpp new file mode 100644 index 00000000000..480bbe0eb8a --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/GDIFontMap.cpp @@ -0,0 +1,39 @@ +/* + ****************************************************************************** + * Copyright (C) 1998-2003, International Business Machines Corporation and * + * others. All Rights Reserved. * + ****************************************************************************** + */ + +#include <windows.h> + +#include "layout/LEFontInstance.h" + +#include "GDIFontInstance.h" + +#include "GUISupport.h" +#include "FontMap.h" +#include "GDIFontMap.h" + +GDIFontMap::GDIFontMap(GDISurface *surface, const char *fileName, le_int16 pointSize, GUISupport *guiSupport, LEErrorCode &status) + : FontMap(fileName, pointSize, guiSupport, status), fSurface(surface) +{ + // nothing to do? +} + +GDIFontMap::~GDIFontMap() +{ + // anything? +} + +const LEFontInstance *GDIFontMap::openFont(const char *fontName, le_int16 pointSize, LEErrorCode &status) +{ + LEFontInstance *result = new GDIFontInstance(fSurface, fontName, pointSize, status); + + if (LE_FAILURE(status)) { + delete result; + result = NULL; + } + + return result; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/GDIFontMap.h b/Build/source/libs/icu/icu-xetex/samples/layout/GDIFontMap.h new file mode 100644 index 00000000000..e92f47f0c0c --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/GDIFontMap.h @@ -0,0 +1,38 @@ +/* + ****************************************************************************** + * Copyright (C) 1998-2003, International Business Machines Corporation and * + * others. All Rights Reserved. * + ****************************************************************************** + */ + +#ifndef __GDIFONTMAP_H +#define __GDIFONTMAP_H + +#include <windows.h> + +#include "unicode/uscript.h" + +#include "layout/LETypes.h" +#include "layout/LEFontInstance.h" + +#include "FontMap.h" +#include "GUISupport.h" +#include "GDIFontInstance.h" + +#define BUFFER_SIZE 128 + +class GDIFontMap : public FontMap +{ +public: + GDIFontMap(GDISurface *surface, const char *fileName, le_int16 pointSize, GUISupport *guiSupport, LEErrorCode &status); + + virtual ~GDIFontMap(); + +protected: + virtual const LEFontInstance *openFont(const char *fontName, le_int16 pointSize, LEErrorCode &status); + +private: + GDISurface *fSurface; +}; + +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/GDIGUISupport.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/GDIGUISupport.cpp new file mode 100644 index 00000000000..9f55ffed61e --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/GDIGUISupport.cpp @@ -0,0 +1,22 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2001, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: GDIGUISupport.h + * + * created on: 11/06/2001 + * created by: Eric R. Mader + */ + +#include <windows.h> + +#include "GDIGUISupport.h" + +void GDIGUISupport::postErrorMessage(const char *message, const char *title) +{ + MessageBoxA(NULL, message, title, MB_ICONERROR); +} + diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/GDIGUISupport.h b/Build/source/libs/icu/icu-xetex/samples/layout/GDIGUISupport.h new file mode 100644 index 00000000000..ad4c7143b5a --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/GDIGUISupport.h @@ -0,0 +1,28 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2005, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: GDIGUISupport.h + * + * created on: 11/06/2001 + * created by: Eric R. Mader + */ + +#ifndef __GDIGUISUPPORT_H +#define __GDIGUISUPPORT_H + +#include "GUISupport.h" + +class GDIGUISupport : public GUISupport +{ +public: + GDIGUISupport() {}; + virtual ~GDIGUISupport() {}; + + virtual void postErrorMessage(const char *message, const char *title); +}; + +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/GUISupport.h b/Build/source/libs/icu/icu-xetex/samples/layout/GUISupport.h new file mode 100644 index 00000000000..f41b7cec91d --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/GUISupport.h @@ -0,0 +1,26 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2005, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: GUISupport.h + * + * created on: 11/06/2001 + * created by: Eric R. Mader + */ + +#ifndef __GUISUPPORT_H +#define __GUISUPPORT_H + +class GUISupport +{ +public: + GUISupport() {}; + virtual ~GUISupport() {}; + + virtual void postErrorMessage(const char *message, const char *title) = 0; +}; + +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/GnomeFontInstance.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/GnomeFontInstance.cpp new file mode 100644 index 00000000000..2a5c307b8f7 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/GnomeFontInstance.cpp @@ -0,0 +1,201 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2007, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: GnomeFontInstance.cpp + * + * created on: 08/30/2001 + * created by: Eric R. Mader + */ + +#include <gnome.h> +#include <ft2build.h> +#include FT_FREETYPE_H +#include FT_GLYPH_H +#include FT_RENDER_H +#include FT_TRUETYPE_TABLES_H +#include <cairo.h> +#include <cairo-ft.h> + +#include "layout/LETypes.h" +#include "layout/LESwaps.h" + +#include "GnomeFontInstance.h" +#include "sfnt.h" +#include "cmaps.h" + +GnomeSurface::GnomeSurface(GtkWidget *theWidget) + : fWidget(theWidget) +{ + fCairo = gdk_cairo_create(fWidget->window); +} + +GnomeSurface::~GnomeSurface() +{ + cairo_destroy(fCairo); +} + +void GnomeSurface::drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs, le_int32 count, + const float *positions, le_int32 x, le_int32 y, le_int32 /*width*/, le_int32 /*height*/) +{ + GnomeFontInstance *gFont = (GnomeFontInstance *) font; + + gFont->rasterizeGlyphs(fCairo, glyphs, count, positions, x, y); +} + +GnomeFontInstance::GnomeFontInstance(FT_Library engine, const char *fontPathName, le_int16 pointSize, LEErrorCode &status) + : FontTableCache(), fPointSize(pointSize), fUnitsPerEM(0), fAscent(0), fDescent(0), fLeading(0), + fDeviceScaleX(1), fDeviceScaleY(1), fMapper(NULL) +{ + FT_Error error; + + fFace = NULL; + fCairoFace = NULL; + + error = FT_New_Face(engine, fontPathName, 0, &fFace); + + if (error != 0) { + printf("OOPS! Got error code %d\n", error); + status = LE_FONT_FILE_NOT_FOUND_ERROR; + return; + } + + // FIXME: what about the display resolution? + fDeviceScaleX = ((float) 96) / 72; + fDeviceScaleY = ((float) 96) / 72; + + error = FT_Set_Char_Size(fFace, 0, pointSize << 6, 92, 92); + + fCairoFace = cairo_ft_font_face_create_for_ft_face(fFace, 0); + + fUnitsPerEM = fFace->units_per_EM; + + fAscent = (le_int32) (yUnitsToPoints(fFace->ascender) * fDeviceScaleY); + fDescent = (le_int32) -(yUnitsToPoints(fFace->descender) * fDeviceScaleY); + fLeading = (le_int32) (yUnitsToPoints(fFace->height) * fDeviceScaleY) - fAscent - fDescent; + + // printf("Face = %s, unitsPerEM = %d, ascent = %d, descent = %d\n", fontPathName, fUnitsPerEM, fAscent, fDescent); + + if (error != 0) { + status = LE_MEMORY_ALLOCATION_ERROR; + return; + } + + status = initMapper(); +} + +GnomeFontInstance::~GnomeFontInstance() +{ + cairo_font_face_destroy(fCairoFace); + + if (fFace != NULL) { + FT_Done_Face(fFace); + } +} + +LEErrorCode GnomeFontInstance::initMapper() +{ + LETag cmapTag = LE_CMAP_TABLE_TAG; + const CMAPTable *cmap = (const CMAPTable *) readFontTable(cmapTag); + + if (cmap == NULL) { + return LE_MISSING_FONT_TABLE_ERROR; + } + + fMapper = CMAPMapper::createUnicodeMapper(cmap); + + if (fMapper == NULL) { + return LE_MISSING_FONT_TABLE_ERROR; + } + + return LE_NO_ERROR; +} + +const void *GnomeFontInstance::getFontTable(LETag tableTag) const +{ + return FontTableCache::find(tableTag); +} + +const void *GnomeFontInstance::readFontTable(LETag tableTag) const +{ + FT_ULong len = 0; + FT_Byte *result = NULL; + + FT_Load_Sfnt_Table(fFace, tableTag, 0, NULL, &len); + + if (len > 0) { + result = LE_NEW_ARRAY(FT_Byte, len); + FT_Load_Sfnt_Table(fFace, tableTag, 0, result, &len); + } + + return result; +} + +void GnomeFontInstance::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const +{ + advance.fX = 0; + advance.fY = 0; + + if (glyph >= 0xFFFE) { + return; + } + + FT_Error error; + + error = FT_Load_Glyph(fFace, glyph, FT_LOAD_DEFAULT); + + if (error != 0) { + return; + } + + advance.fX = fFace->glyph->metrics.horiAdvance >> 6; + return; +} + +le_bool GnomeFontInstance::getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const +{ + FT_Error error; + + error = FT_Load_Glyph(fFace, glyph, FT_LOAD_DEFAULT); + + if (error != 0) { + return FALSE; + } + + if (pointNumber >= fFace->glyph->outline.n_points) { + return FALSE; + } + + point.fX = fFace->glyph->outline.points[pointNumber].x >> 6; + point.fY = fFace->glyph->outline.points[pointNumber].y >> 6; + + return TRUE; +} + +void GnomeFontInstance::rasterizeGlyphs(cairo_t *cairo, const LEGlyphID *glyphs, le_int32 glyphCount, const float *positions, + le_int32 x, le_int32 y) const +{ + cairo_glyph_t *glyph_t = LE_NEW_ARRAY(cairo_glyph_t, glyphCount); + le_int32 in, out; + + for (in = 0, out = 0; in < glyphCount; in += 1) { + TTGlyphID glyph = LE_GET_GLYPH(glyphs[in]); + + if (glyph < 0xFFFE) { + glyph_t[out].index = glyph; + glyph_t[out].x = x + positions[in*2]; + glyph_t[out].y = y + positions[in*2 + 1]; + + out += 1; + } + } + + cairo_set_font_face(cairo, fCairoFace); + cairo_set_font_size(cairo, getXPixelsPerEm() * getScaleFactorX()); + cairo_show_glyphs(cairo, glyph_t, out); + + LE_DELETE_ARRAY(glyph_t); +} diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/GnomeFontInstance.h b/Build/source/libs/icu/icu-xetex/samples/layout/GnomeFontInstance.h new file mode 100644 index 00000000000..4af393804cd --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/GnomeFontInstance.h @@ -0,0 +1,166 @@ + +/* + ******************************************************************************* + * + * Copyright (C) 1999-2006, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: GnomeFontInstance.h + * + * created on: 08/30/2001 + * created by: Eric R. Mader + */ + +#ifndef __GNOMEFONTINSTANCE_H +#define __GNOMEFONTINSTANCE_H + +#include <gnome.h> +#include <ft2build.h> +#include FT_FREETYPE_H +#include FT_GLYPH_H +#include <cairo.h> + +#include "layout/LETypes.h" +#include "layout/LEFontInstance.h" + +#include "RenderingSurface.h" +#include "FontTableCache.h" +#include "cmaps.h" + +class GnomeSurface : public RenderingSurface +{ +public: + GnomeSurface(GtkWidget *theWidget); + virtual ~GnomeSurface(); + + virtual void drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs, le_int32 count, + const float *positions, le_int32 x, le_int32 y, le_int32 width, le_int32 height); + + GtkWidget *getWidget() const; + void setWidget(GtkWidget *theWidget); + +private: + GtkWidget *fWidget; + cairo_t *fCairo; +}; + +class GnomeFontInstance : public LEFontInstance, protected FontTableCache +{ + protected: + FT_Face fFace; +// FT_Glyph fGlyph; + + cairo_font_face_t *fCairoFace; + + le_int32 fPointSize; + le_int32 fUnitsPerEM; + le_int32 fAscent; + le_int32 fDescent; + le_int32 fLeading; + + float fDeviceScaleX; + float fDeviceScaleY; + + CMAPMapper *fMapper; + + virtual const void *readFontTable(LETag tableTag) const; + + virtual LEErrorCode initMapper(); + + public: + GnomeFontInstance(FT_Library engine, const char *fontPathName, le_int16 pointSize, LEErrorCode &status); + + virtual ~GnomeFontInstance(); + + virtual const void *getFontTable(LETag tableTag) const; + + virtual le_int32 getUnitsPerEM() const; + + virtual le_int32 getAscent() const; + + virtual le_int32 getDescent() const; + + virtual le_int32 getLeading() const; + + virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const; + + virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const; + + virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const; + + float getXPixelsPerEm() const; + + float getYPixelsPerEm() const; + + float getScaleFactorX() const; + + float getScaleFactorY() const; + + void rasterizeGlyphs(cairo_t *cairo, const LEGlyphID *glyphs, le_int32 glyphCount, const float *positions, + le_int32 x, le_int32 y) const; +}; + +inline GtkWidget *GnomeSurface::getWidget() const +{ + return fWidget; +} + +inline void GnomeSurface::setWidget(GtkWidget *theWidget) +{ + fWidget = theWidget; +} + +/* +inline FT_Instance GnomeFontInstance::getFont() const +{ + return fInstance; +} +*/ + +inline le_int32 GnomeFontInstance::getUnitsPerEM() const +{ + return fUnitsPerEM; +} + +inline le_int32 GnomeFontInstance::getAscent() const +{ + return fAscent; +} + +inline le_int32 GnomeFontInstance::getDescent() const +{ + return fDescent; +} + +inline le_int32 GnomeFontInstance::getLeading() const +{ + return fLeading; +} + +inline LEGlyphID GnomeFontInstance::mapCharToGlyph(LEUnicode32 ch) const +{ + return fMapper->unicodeToGlyph(ch); +} + +inline float GnomeFontInstance::getXPixelsPerEm() const +{ + return (float) fPointSize; +} + +inline float GnomeFontInstance::getYPixelsPerEm() const +{ + return (float) fPointSize; +} + +inline float GnomeFontInstance::getScaleFactorX() const +{ + return fDeviceScaleX; +} + +inline float GnomeFontInstance::getScaleFactorY() const +{ + return fDeviceScaleY; +} + +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/GnomeFontMap.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/GnomeFontMap.cpp new file mode 100644 index 00000000000..6a23b305627 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/GnomeFontMap.cpp @@ -0,0 +1,41 @@ +/* + ****************************************************************************** + * Copyright (C) 1998-2006, International Business Machines Corporation and * + * others. All Rights Reserved. * + ****************************************************************************** + */ + +#include <stdio.h> + +#include <ft2build.h> +#include FT_FREETYPE_H + +#include "layout/LEFontInstance.h" +#include "GnomeFontInstance.h" + +#include "GUISupport.h" +#include "FontMap.h" +#include "GnomeFontMap.h" + +GnomeFontMap::GnomeFontMap(FT_Library engine, const char *fileName, le_int16 pointSize, GUISupport *guiSupport, LEErrorCode &status) + : FontMap(fileName, pointSize, guiSupport, status), fEngine(engine) +{ + // nothing to do? +} + +GnomeFontMap::~GnomeFontMap() +{ + // anything? +} + +const LEFontInstance *GnomeFontMap::openFont(const char *fontName, le_int16 pointSize, LEErrorCode &status) +{ + LEFontInstance *result = new GnomeFontInstance(fEngine, fontName, pointSize, status); + + if (LE_FAILURE(status)) { + delete result; + result = NULL; + } + + return result; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/GnomeFontMap.h b/Build/source/libs/icu/icu-xetex/samples/layout/GnomeFontMap.h new file mode 100644 index 00000000000..a068b2b558f --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/GnomeFontMap.h @@ -0,0 +1,38 @@ +/* + ****************************************************************************** + * Copyright (C) 1998-2006, International Business Machines Corporation and * + * others. All Rights Reserved. * + ****************************************************************************** + */ + +#ifndef __GNOMEFONTMAP_H +#define __GNOMEFONTMAP_H + +#include <ft2build.h> +#include FT_FREETYPE_H + +#include "unicode/uscript.h" + +#include "layout/LETypes.h" +#include "layout/LEFontInstance.h" + +#include "GUISupport.h" +#include "FontMap.h" + +#define BUFFER_SIZE 128 + +class GnomeFontMap : public FontMap +{ + public: + GnomeFontMap(FT_Library engine, const char *fileName, le_int16 pointSize, GUISupport *guiSupport, LEErrorCode &status); + + virtual ~GnomeFontMap(); + + protected: + virtual const LEFontInstance *openFont(const char *fontName, le_int16 pointSize, LEErrorCode &status); + + private: + FT_Library fEngine; +}; + +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/GnomeGUISupport.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/GnomeGUISupport.cpp new file mode 100644 index 00000000000..2835b616a01 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/GnomeGUISupport.cpp @@ -0,0 +1,37 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2001, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: GnomeGUISupport.cpp + * + * created on: 11/06/2001 + * created by: Eric R. Mader + */ + +#if 1 +#include <gnome.h> +#else +#include <stdio.h> +#endif + +#include "GnomeGUISupport.h" + +void GnomeGUISupport::postErrorMessage(const char *message, const char *title) +{ +#if 1 + gchar *s; + GtkWidget *error; + + s = g_strconcat(title, ":\n", message, NULL); + error = gnome_error_dialog(s); + gtk_widget_show(error); + g_free(s); +#else + fprintf(stderr, "%s: %s\n", title, message); +#endif +} + + diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/GnomeGUISupport.h b/Build/source/libs/icu/icu-xetex/samples/layout/GnomeGUISupport.h new file mode 100644 index 00000000000..e88ef128a14 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/GnomeGUISupport.h @@ -0,0 +1,28 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2005, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: GnomeGUISupport.h + * + * created on: 11/06/2001 + * created by: Eric R. Mader + */ + +#ifndef __GNOMEGUISUPPORT_H +#define __GNOMEGUISUPPORT_H + +#include "GUISupport.h" + +class GnomeGUISupport : public GUISupport +{ +public: + GnomeGUISupport() {}; + virtual ~GnomeGUISupport() {}; + + virtual void postErrorMessage(const char *message, const char *title); +}; + +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/LayoutSample.rc b/Build/source/libs/icu/icu-xetex/samples/layout/LayoutSample.rc new file mode 100644 index 00000000000..9b0d3df88cc --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/LayoutSample.rc @@ -0,0 +1,115 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +/* +******************************************************************************* +* +* Copyright (C) 2002-2003, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +*/ +#include <winresrc.h> + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +LAYOUTSAMPLE MENU DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&New Sample\tCtrl+N", IDM_FILE_NEWSAMPLE + MENUITEM "&Open...\tCtrl+O", IDM_FILE_OPEN + MENUITEM SEPARATOR + MENUITEM "&Close\tCtrl+W", IDM_FILE_CLOSE + MENUITEM "E&xit\tCtrl+Q", IDM_FILE_EXIT + END + POPUP "&Help" + BEGIN + MENUITEM "&About Layout Sample...", IDM_HELP_ABOUTLAYOUTSAMPLE + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +LAYOUTSAMPLE ACCELERATORS DISCARDABLE +BEGIN + "N", IDM_FILE_NEWSAMPLE, VIRTKEY, CONTROL, NOINVERT + "O", IDM_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT + "Q", IDM_FILE_EXIT, VIRTKEY, CONTROL, NOINVERT + "W", IDM_FILE_CLOSE, VIRTKEY, CONTROL, NOINVERT +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "/*\r\n" + "*******************************************************************************\r\n" + "*\r\n" + "* Copyright (C) 2002-2003, International Business Machines\r\n" + "* Corporation and others. All Rights Reserved.\r\n" + "*\r\n" + "*******************************************************************************\r\n" + "*/\r\n" + "#include <winresrc.h>\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/Makefile.in b/Build/source/libs/icu/icu-xetex/samples/layout/Makefile.in new file mode 100644 index 00000000000..15fae07c16a --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/Makefile.in @@ -0,0 +1,107 @@ +## Makefile.in for ICU - samples/layout +## Copyright (c) 2001-2007, International Business Machines Corporation and +## others. All Rights Reserved. + +## Source directory information +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ + +top_builddir = ../.. + +include $(top_builddir)/icudefs.mk + +## Platform-specific setup +include @platform_make_fragment@ + +## Build directory information +subdir = samples/layout + +## Extra files to remove for 'make clean' +CLEANFILES = *~ $(DEPS) + +## Target information +TARGET = gnomelayout +CTARGET = cgnomelayout + +CPPFLAGS += -DLE_USE_CMEMORY `pkg-config --cflags libgnomeui-2.0 freetype2 cairo` -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/layoutex -I$(top_srcdir)/layout -I$(top_srcdir) -g + +LIBS = $(LIBICULX) $(LIBICULE) $(LIBICUUC) $(LIBICUI18N) @LIBS@ @LIB_M@ `pkg-config --libs libgnomeui-2.0 freetype2 cairo` + +COMMON=cmaps.o UnicodeReader.o GnomeGUISupport.o FontMap.o GnomeFontMap.o ScriptCompositeFontInstance.o GnomeFontInstance.o FontTableCache.o paragraph.o + +OBJECTS=gnomelayout.o + +COBJECTS=gnomeglue.o pflow.o rsurface.o ucreader.o cgnomelayout.o + +DEPS = $(OBJECTS:.o=.d) + +## List of phony targets +.PHONY : all all-local install install-local clean clean-local \ +distclean distclean-local dist dist-local check check-local + +## Clear suffix list +.SUFFIXES : + +## List of standard targets +all: all-local +install: install-local +clean: clean-local +distclean : distclean-local +dist: dist-local +check: all check-local +c-all: c-all-local +c-check: c-all c-check-local + +all-local: $(TARGET) + +c-all-local: $(CTARGET) + +install-local: + +dist-local: + +clean-local: + test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES) + $(RMV) $(COMMON) $(OBJECTS) $(COBJECTS) $(TARGET) + +distclean-local: clean-local + $(RMV) Makefile + +check-local: all-local + $(INVOKE) ./$(TARGET) + +c-check-local: c-all-local + $(INVOKE) ./$(CTARGET) + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +# The following two rules make it possible to +# compile scrptrun.cpp from the extra/scrptrun directory. +# they were copied from the default rules in mh-linux which +# is probably OK because this sample will only run on Linux... +scrptrun.d: $(top_srcdir)/extra/scrptrun/scrptrun.cpp + $(SHELL) -ec '$(GEN_DEPS.cc) $< \ + | sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \ + [ -s $@ ] || rm -f $@' + +scrptrun.o: $(top_srcdir)/extra/scrptrun/scrptrun.cpp + $(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $< + +$(TARGET) : $(COMMON) $(OBJECTS) + $(LINK.cc) -o $@ $^ $(LIBS) + +$(CTARGET) : $(COMMON) $(COBJECTS) + $(LINK.cc) -o $@ $^ $(LIBS) + +invoke: + ICU_DATA=$${ICU_DATA:-$(top_builddir)/data/} TZ=PST8PDT $(INVOKE) $(INVOCATION) + +ifeq (,$(MAKECMDGOALS)) +-include $(DEPS) +else +ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),) +-include $(DEPS) +endif +endif diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/RenderingSurface.h b/Build/source/libs/icu/icu-xetex/samples/layout/RenderingSurface.h new file mode 100644 index 00000000000..ab0ad561956 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/RenderingSurface.h @@ -0,0 +1,30 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2003, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: RenderingFontInstance.h + * + * created on: 02/20/2003 + * created by: Eric R. Mader + */ + +#ifndef __RENDERINGSURFACE_H +#define __RENDERINGSURFACE_H + +#include "layout/LETypes.h" +#include "layout/LEFontInstance.h" + +class RenderingSurface +{ +public: + RenderingSurface() {}; + virtual ~RenderingSurface() {}; + + virtual void drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs, le_int32 count, + const float *positions, le_int32 x, le_int32 y, le_int32 width, le_int32 height) = 0; +}; + +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/Sample.txt b/Build/source/libs/icu/icu-xetex/samples/layout/Sample.txt new file mode 100644 index 00000000000..367821b7933 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/Sample.txt @@ -0,0 +1 @@ +The LayoutEngine does all the work necessary to display Unicode text written in languages with complex writing systems such as Hindi (हिनà¥à¤¦à¥€) Thai (ไทย) and Arabic (العربية). Here's a sample of some text written in Sanskrit: शà¥à¤°à¥€à¤®à¤¦à¥ à¤à¤—वदà¥à¤—ीता अधà¥à¤¯à¤¾à¤¯ अरà¥à¤œà¥à¤¨ विषाद योग धृतराषà¥à¤Ÿà¥à¤° उवाच। धरà¥à¤®à¤•à¥à¤·à¥‡à¤¤à¥à¤°à¥‡ कà¥à¤°à¥à¤•à¥à¤·à¥‡à¤¤à¥à¤°à¥‡ समवेता यà¥à¤¯à¥à¤¤à¥à¤¸à¤µà¤ƒ मामकाः पाणà¥à¤¡à¤µà¤¾à¤¶à¥à¤šà¥ˆà¤µ किमकà¥à¤°à¥à¤µà¤¤ संजय Here's a sample of some text written in Arabic: أساسًا، تتعامل الØواسيب Ùقط مع الأرقام، وتقوم بتخزين الأØر٠والمØار٠الأخرى بعد أن تÙعطي رقما معينا لكل واØد منها. وقبل اختراع "يونÙكود"ØŒ كان هناك مئات الأنظمة للتشÙير وتخصيص هذه الأرقام للمØارÙØŒ ولم يوجد نظام تشÙير واØد ÙŠØتوي على جميع المØار٠الضرورية and here's a sample of some text written in Thai: บทที่๑พายุไซโคลนโดโรธีà¸à¸²à¸¨à¸±à¸¢à¸à¸¢à¸¹à¹ˆà¸—่ามà¸à¸¥à¸²à¸‡à¸—ุ่งใหà¸à¹ˆà¹ƒà¸™à¹à¸„นซัสà¸à¸±à¸šà¸¥à¸¸à¸‡à¹€à¸®à¸™à¸£à¸µà¸Šà¸²à¸§à¹„ร่à¹à¸¥à¸°à¸›à¹‰à¸²à¹€à¸à¹‡à¸¡à¸ รรยาชาวไร่บ้านขà¸à¸‡à¸žà¸§à¸à¹€à¸‚าหลังเล็à¸à¹€à¸žà¸£à¸²à¸°à¹„ม้สร้างบ้านต้à¸à¸‡à¸‚นมาด้วยเà¸à¸§à¸µà¸¢à¸™à¹€à¸›à¹‡à¸™à¸£à¸°à¸¢à¸°à¸—างหลายไมล์ diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/ScriptCompositeFontInstance.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/ScriptCompositeFontInstance.cpp new file mode 100644 index 00000000000..2fbbaca0d4b --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/ScriptCompositeFontInstance.cpp @@ -0,0 +1,103 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2003, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: ScriptCompositeFontInstance.cpp + * + * created on: 02/05/2003 + * created by: Eric R. Mader + */ + +#include "layout/LETypes.h" + +#include "unicode/uscript.h" + +#include "FontMap.h" + +#include "ScriptCompositeFontInstance.h" + +const char ScriptCompositeFontInstance::fgClassID=0; + +ScriptCompositeFontInstance::ScriptCompositeFontInstance(FontMap *fontMap) + : fFontMap(fontMap) +{ + // nothing else to do +} + +ScriptCompositeFontInstance::~ScriptCompositeFontInstance() +{ + delete fFontMap; + fFontMap = NULL; +} + +void ScriptCompositeFontInstance::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const +{ + LEErrorCode status = LE_NO_ERROR; + le_int32 script = LE_GET_SUB_FONT(glyph); + const LEFontInstance *font = fFontMap->getScriptFont(script, status); + + advance.fX = 0; + advance.fY = 0; + + if (LE_SUCCESS(status)) { + font->getGlyphAdvance(LE_GET_GLYPH(glyph), advance); + } +} + +le_bool ScriptCompositeFontInstance::getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const +{ + LEErrorCode status = LE_NO_ERROR; + le_int32 script = LE_GET_SUB_FONT(glyph); + const LEFontInstance *font = fFontMap->getScriptFont(script, status); + + if (LE_SUCCESS(status)) { + return font->getGlyphPoint(LE_GET_GLYPH(glyph), pointNumber, point); + } + + return FALSE; +} + +const LEFontInstance *ScriptCompositeFontInstance::getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit, le_int32 script, LEErrorCode &success) const +{ + if (LE_FAILURE(success)) { + return NULL; + } + + if (chars == NULL || *offset < 0 || limit < 0 || *offset >= limit || script < 0 || script >= scriptCodeCount) { + success = LE_ILLEGAL_ARGUMENT_ERROR; + return NULL; + } + + const LEFontInstance *result = fFontMap->getScriptFont(script, success); + + if (LE_FAILURE(success)) { + return NULL; + } + + *offset = limit; + return result; +} + +// This is the really stupid version that doesn't look in any other font for the character... +// It would be better to also look in the "DEFAULT:" font. Another thing to do would be to +// look in all the fonts in some order, script code order being the most obvious... +LEGlyphID ScriptCompositeFontInstance::mapCharToGlyph(LEUnicode32 ch) const +{ + UErrorCode error = U_ZERO_ERROR; + LEErrorCode status = LE_NO_ERROR; + le_int32 script = uscript_getScript(ch, &error); + const LEFontInstance *scriptFont = fFontMap->getScriptFont(script, status); + LEGlyphID subFont = LE_SET_SUB_FONT(0, script); + + if (LE_FAILURE(status)) { + return subFont; + } + + LEGlyphID glyph = scriptFont->mapCharToGlyph(ch); + + return LE_SET_GLYPH(subFont, glyph); +} + diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/ScriptCompositeFontInstance.h b/Build/source/libs/icu/icu-xetex/samples/layout/ScriptCompositeFontInstance.h new file mode 100644 index 00000000000..241461769d0 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/ScriptCompositeFontInstance.h @@ -0,0 +1,191 @@ +/* + * %W% %E% + * + * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved + * + */ + +#ifndef __SCRIPTCOMPOSITEFONTINSTANCE_H +#define __SCRIPTCOMPOSITEFONTINSTANCE_H + +#include "layout/LETypes.h" +#include "layout/LEFontInstance.h" + +#include "FontMap.h" + +// U_NAMESPACE_BEGIN + +class ScriptCompositeFontInstance : public LEFontInstance +{ +public: + + ScriptCompositeFontInstance(FontMap *fontMap); + + virtual ~ScriptCompositeFontInstance(); + + /** + * Get a physical font which can render the given text. For composite fonts, + * if there is no single physical font which can render all of the text, + * return a physical font which can render an initial substring of the text, + * and set the <code>offset</code> parameter to the end of that substring. + * + * Internally, the LayoutEngine works with runs of text all in the same + * font and script, so it is best to call this method with text which is + * in a single script, passing the script code in as a hint. If you don't + * know the script of the text, you can use zero, which is the script code + * for characters used in more than one script. + * + * The default implementation of this method is intended for instances of + * <code>LEFontInstance</code> which represent a physical font. It returns + * <code>this</code> and indicates that the entire string can be rendered. + * + * This method will return a valid <code>LEFontInstance</code> unless you + * have passed illegal parameters, or an internal error has been encountered. + * For composite fonts, it may return the warning <code>LE_NO_SUBFONT_WARNING</code> + * to indicate that the returned font may not be able to render all of + * the text. Whenever a valid font is returned, the <code>offset</code> parameter + * will be advanced by at least one. + * + * Subclasses which implement composite fonts must override this method. + * Where it makes sense, they should use the script code as a hint to render + * characters from the COMMON script in the font which is used for the given + * script. For example, if the input text is a series of Arabic words separated + * by spaces, and the script code passed in is <code>arabScriptCode</code> you + * should return the font used for Arabic characters for all of the input text, + * including the spaces. If, on the other hand, the input text contains characters + * which cannot be rendered by the font used for Arabic characters, but which can + * be rendered by another font, you should return that font for those characters. + * + * @param chars - the array of Unicode characters. + * @param offset - a pointer to the starting offset in the text. On exit this + * will be set the the limit offset of the text which can be + * rendered using the returned font. + * @param limit - the limit offset for the input text. + * @param script - the script hint. + * @param success - set to an error code if the arguments are illegal, or no font + * can be returned for some reason. May also be set to + * <code>LE_NO_SUBFONT_WARNING</code> if the subfont which + * was returned cannot render all of the text. + * + * @return an <code>LEFontInstance</code> for the sub font which can render the characters, or + * <code>NULL</code> if there is an error. + * + * @see LEScripts.h + * + * @draft ICU 2.6 + */ + virtual const LEFontInstance *getSubFont(const LEUnicode chars[], le_int32 *offset, le_int32 limit, le_int32 script, LEErrorCode &success) const; + + /** + * This method maps a single character to a glyph index, using the + * font's charcter to glyph map. + * + * @param ch - the character + * + * @return the glyph index + * + * @draft ICU 2.6 + */ + virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const; + + virtual const void *getFontTable(LETag tableTag) const; + + virtual le_int32 getUnitsPerEM() const; + + virtual le_int32 getAscent() const; + + virtual le_int32 getDescent() const; + + virtual le_int32 getLeading() const; + + virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const; + + virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const; + + float getXPixelsPerEm() const; + + float getYPixelsPerEm() const; + + float getScaleFactorX() const; + + float getScaleFactorY() const; + + /** + * ICU "poor man's RTTI", returns a UClassID for the actual class. + * + * @draft ICU 2.2 + */ + virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + + /** + * ICU "poor man's RTTI", returns a UClassID for this class. + * + * @draft ICU 2.2 + */ + static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + +protected: + FontMap *fFontMap; + +private: + + /** + * The address of this static class variable serves as this class's ID + * for ICU "poor man's RTTI". + */ + static const char fgClassID; +}; + +inline const void *ScriptCompositeFontInstance::getFontTable(LETag /*tableTag*/) const +{ + return NULL; +} + +// Can't get units per EM without knowing which sub-font, so +// return a value that will make units == points +inline le_int32 ScriptCompositeFontInstance::getUnitsPerEM() const +{ + return 1; +} + +inline le_int32 ScriptCompositeFontInstance::getAscent() const +{ + return fFontMap->getAscent(); +} + +inline le_int32 ScriptCompositeFontInstance::getDescent() const +{ + return fFontMap->getDescent(); +} + +inline le_int32 ScriptCompositeFontInstance::getLeading() const +{ + return fFontMap->getLeading(); +} + +inline float ScriptCompositeFontInstance::getXPixelsPerEm() const +{ + return fFontMap->getPointSize(); +} + +inline float ScriptCompositeFontInstance::getYPixelsPerEm() const +{ + return fFontMap->getPointSize(); +} + +// Can't get a scale factor without knowing the sub-font, so +// return 1.0. +inline float ScriptCompositeFontInstance::getScaleFactorX() const +{ + return 1.0; +} + +// Can't get a scale factor without knowing the sub-font, so +// return 1.0 +inline float ScriptCompositeFontInstance::getScaleFactorY() const +{ + return 1.0; +} + +// U_NAMESPACE_END +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/Surface.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/Surface.cpp new file mode 100644 index 00000000000..1f515241a95 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/Surface.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2003, International Business Machines + * Corporation and others. All Rights Reserved. + */ +void GDISurface::setFont(RenderingFontInstance *font) +{ + GDIFontInstance *gFont = (GDIFontInstance *) font; + + if (fCurrentFont != font) { + fCurrentFont = font; + SelectObject(fHdc, gFont->fFont); + } +} + +void GDISurface::drawGlyphs(RenderingFontInstance *font, const LEGlyphID *glyphs, le_int32 count, const le_int32 *dx, + le_int32 x, le_int32 y, le_int32 width, le_int32 height) +{ + RECT clip; + + clip.top = 0; + clip.left = 0; + clip.bottom = height; + clip.right = width; + + setFont(font); + + ExtTextOut(fHdc, x, y - fAscent, ETO_CLIPPED | ETO_GLYPH_INDEX, &clip, + glyphs, count, (INT *) dx); +} + diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/Surface.h b/Build/source/libs/icu/icu-xetex/samples/layout/Surface.h new file mode 100644 index 00000000000..423ddaaf12c --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/Surface.h @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2003, International Business Machines + * Corporation and others. All Rights Reserved. + */ +class Surface +{ +public: + Surface(/*what?*/); + + void setFont(RenderingFontInstance *font); + + void drawGlyphs(RenderingFontInstance *font, const LEGlyphID *glyphs, le_int32 count, const le_int32 *dx, + le_int32 x, le_int32 y, le_int32 width, le_int32 height); +}; diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/UnicodeReader.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/UnicodeReader.cpp new file mode 100644 index 00000000000..ab5a7ef70b7 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/UnicodeReader.cpp @@ -0,0 +1,119 @@ +/* + ****************************************************************************** + * Copyright (C) 1998-2005, International Business Machines Corporation and * + * others. All Rights Reserved. * + ****************************************************************************** + */ + +#include <errno.h> +#include <stdio.h> +#include <string.h> + +#include "unicode/utypes.h" +#include "unicode/unistr.h" + +#include "layout/LETypes.h" + +#include "GUISupport.h" +#include "UnicodeReader.h" + +#define BYTE(b) (((int) b) & 0xFF) + +/* + * Read the text from a file. The text must start with a Unicode Byte + * Order Mark (BOM) so that we know what order to read the bytes in. + */ +const UChar *UnicodeReader::readFile(const char *fileName, GUISupport *guiSupport, int32_t &charCount) +{ + FILE *f; + int32_t fileSize; + + UChar *charBuffer; + char *byteBuffer; + char startBytes[4] = {'\xA5', '\xA5', '\xA5', '\xA5'}; + char errorMessage[128]; + const char *cp = ""; + int32_t signatureLength = 0; + + f = fopen(fileName, "rb"); + + if( f == NULL ) { + sprintf(errorMessage,"Couldn't open %s: %s \n", fileName, strerror(errno)); + guiSupport->postErrorMessage(errorMessage, "Text File Error"); + return 0; + } + + fseek(f, 0, SEEK_END); + fileSize = ftell(f); + + fseek(f, 0, SEEK_SET); + fread(startBytes, sizeof(char), 4, f); + + if (startBytes[0] == '\xFE' && startBytes[1] == '\xFF') { + cp = "UTF-16BE"; + signatureLength = 2; + } else if (startBytes[0] == '\xFF' && startBytes[1] == '\xFE') { + if (startBytes[2] == '\x00' && startBytes[3] == '\x00') { + cp = "UTF-32LE"; + signatureLength = 4; + } else { + cp = "UTF-16LE"; + signatureLength = 2; + } + } else if (startBytes[0] == '\xEF' && startBytes[1] == '\xBB' && startBytes[2] == '\xBF') { + cp = "UTF-8"; + signatureLength = 3; + } else if (startBytes[0] == '\x0E' && startBytes[1] == '\xFE' && startBytes[2] == '\xFF') { + cp = "SCSU"; + signatureLength = 3; + } else if (startBytes[0] == '\x00' && startBytes[1] == '\x00' && + startBytes[2] == '\xFE' && startBytes[3] == '\xFF') { + cp = "UTF-32BE"; + signatureLength = 4; + } else { + sprintf(errorMessage, "Couldn't detect the encoding of %s: (%2.2X, %2.2X, %2.2X, %2.2X)\n", fileName, + BYTE(startBytes[0]), BYTE(startBytes[1]), BYTE(startBytes[2]), BYTE(startBytes[3])); + guiSupport->postErrorMessage(errorMessage, "Text File Error"); + fclose(f); + return 0; + } + + fileSize -= signatureLength; + fseek(f, signatureLength, SEEK_SET); + byteBuffer = new char[fileSize]; + + if(byteBuffer == 0) { + sprintf(errorMessage,"Couldn't get memory for reading %s: %s \n", fileName, strerror(errno)); + guiSupport->postErrorMessage(errorMessage, "Text File Error"); + fclose(f); + return 0; + } + + fread(byteBuffer, sizeof(char), fileSize, f); + if( ferror(f) ) { + sprintf(errorMessage,"Couldn't read %s: %s \n", fileName, strerror(errno)); + guiSupport->postErrorMessage(errorMessage, "Text File Error"); + fclose(f); + delete[] byteBuffer; + return 0; + } + fclose(f); + + UnicodeString myText(byteBuffer, fileSize, cp); + + delete[] byteBuffer; + + charCount = myText.length(); + charBuffer = LE_NEW_ARRAY(UChar, charCount + 1); + if(charBuffer == 0) { + sprintf(errorMessage,"Couldn't get memory for reading %s: %s \n", fileName, strerror(errno)); + guiSupport->postErrorMessage(errorMessage, "Text File Error"); + return 0; + } + + myText.extract(0, myText.length(), charBuffer); + charBuffer[charCount] = 0; // NULL terminate for easier reading in the debugger + + return charBuffer; +} + diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/UnicodeReader.h b/Build/source/libs/icu/icu-xetex/samples/layout/UnicodeReader.h new file mode 100644 index 00000000000..47959bb3a49 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/UnicodeReader.h @@ -0,0 +1,32 @@ +/* + ****************************************************************************** + * Copyright (C) 1998-2001, International Business Machines Corporation and * + * others. All Rights Reserved. * + ****************************************************************************** + */ + +#ifndef __UNICODEREADER_H +#define __UNICODEREADER_H + +#include "unicode/utypes.h" + +#include "GUISupport.h" + +class UnicodeReader +{ +public: + UnicodeReader() + { + // nothing... + } + + ~UnicodeReader() + { + // nothing, too + } + + static const UChar *readFile(const char *fileName, GUISupport *guiSupport, int32_t &charCount); +}; + +#endif + diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/arraymem.h b/Build/source/libs/icu/icu-xetex/samples/layout/arraymem.h new file mode 100644 index 00000000000..7c54d96bdd0 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/arraymem.h @@ -0,0 +1,22 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#ifndef __ARRAYMEM_H +#define __ARRAYMEM_H + +#include <stdlib.h> + +#define ARRAY_SIZE(array) (sizeof array / sizeof array[0]) + +#define ARRAY_COPY(dst, src, count) memcpy((void *) (dst), (void *) (src), (count) * sizeof (src)[0]) + +#define NEW_ARRAY(type,count) (type *) malloc((count) * sizeof(type)) + +#define DELETE_ARRAY(array) free((void *) (array)) + +#define GROW_ARRAY(array,newSize) realloc((void *) (array), (newSize) * sizeof (array)[0]) + +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/cgnomelayout.c b/Build/source/libs/icu/icu-xetex/samples/layout/cgnomelayout.c new file mode 100644 index 00000000000..f95b7a5c6bc --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/cgnomelayout.c @@ -0,0 +1,342 @@ + +/* + ****************************************************************************** * + * + * Copyright (C) 1999-2007, International Business Machines + * Corporation and others. All Rights Reserved. + * + ****************************************************************************** * + */ + +#include <gnome.h> +#include <ft2build.h> +#include FT_FREETYPE_H + +#include "pflow.h" + +#include "gnomeglue.h" + +#include "arraymem.h" + +struct Context +{ + long width; + long height; + pf_flow *paragraph; +}; + +typedef struct Context Context; + +static FT_Library engine; +static gs_guiSupport *guiSupport; +static fm_fontMap *fontMap; +static le_font *font; + +static GSList *appList = NULL; + +GtkWidget *newSample(const gchar *fileName); +void closeSample(GtkWidget *sample); + +static void showabout(GtkWidget *widget, gpointer data) +{ + GtkWidget *aboutBox; + const gchar *documentedBy[] = {NULL}; + const gchar *writtenBy[] = { + "Eric Mader", + NULL + }; + + aboutBox = gnome_about_new("Gnome Layout Sample", + "0.1", + "Copyright (C) 1998-2006 By International Business Machines Corporation and others. All Rights Reserved.", + "A simple demo of the ICU LayoutEngine.", + writtenBy, + documentedBy, + "", + NULL); + + gtk_widget_show(aboutBox); +} + +#if 0 +static void notimpl(GtkObject *object, gpointer data) +{ + gnome_ok_dialog("Not implemented..."); +} +#endif + +static gchar *prettyTitle(const gchar *path) +{ + const gchar *name = g_basename(path); + gchar *title = g_strconcat("Gnome Layout Sample - ", name, NULL); + + return title; +} + +static void openOK(GtkObject *object, gpointer data) +{ + GtkFileSelection *fileselection = GTK_FILE_SELECTION(data); + GtkWidget *app = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(fileselection), "app")); + Context *context = (Context *) gtk_object_get_data(GTK_OBJECT(app), "context"); + gchar *fileName = g_strdup(gtk_file_selection_get_filename(fileselection)); + pf_flow *newPara; + + gtk_widget_destroy(GTK_WIDGET(fileselection)); + + newPara = pf_factory(fileName, font, guiSupport); + + if (newPara != NULL) { + gchar *title = prettyTitle(fileName); + GtkWidget *area = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(app), "area")); + + if (context->paragraph != NULL) { + pf_close(context->paragraph); + } + + context->paragraph = newPara; + gtk_window_set_title(GTK_WINDOW(app), title); + + gtk_widget_hide(area); + pf_breakLines(context->paragraph, context->width, context->height); + gtk_widget_show_all(area); + + g_free(title); + } + + g_free(fileName); +} + +static void openfile(GtkObject *object, gpointer data) +{ + GtkWidget *app = GTK_WIDGET(data); + GtkWidget *fileselection; + GtkWidget *okButton; + GtkWidget *cancelButton; + + fileselection = + gtk_file_selection_new("Open File"); + + gtk_object_set_data(GTK_OBJECT(fileselection), "app", app); + + okButton = + GTK_FILE_SELECTION(fileselection)->ok_button; + + cancelButton = + GTK_FILE_SELECTION(fileselection)->cancel_button; + + gtk_signal_connect(GTK_OBJECT(fileselection), "destroy", + GTK_SIGNAL_FUNC(gtk_main_quit), NULL); + + gtk_signal_connect(GTK_OBJECT(okButton), "clicked", + GTK_SIGNAL_FUNC(openOK), fileselection); + + gtk_signal_connect_object(GTK_OBJECT(cancelButton), "clicked", + GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(fileselection)); + + gtk_window_set_modal(GTK_WINDOW(fileselection), TRUE); + gtk_widget_show(fileselection); + gtk_main(); +} + +static void newapp(GtkObject *object, gpointer data) +{ + GtkWidget *app = newSample("Sample.txt"); + + gtk_widget_show_all(app); +} + +static void closeapp(GtkWidget *widget, gpointer data) +{ + GtkWidget *app = GTK_WIDGET(data); + + closeSample(app); +} + +static void shutdown(GtkObject *object, gpointer data) +{ + gtk_main_quit(); +} + +GnomeUIInfo fileMenu[] = +{ + GNOMEUIINFO_MENU_NEW_ITEM((gchar *) "_New Sample", + (gchar *) "Create a new Gnome Layout Sample", + newapp, NULL), + + GNOMEUIINFO_MENU_OPEN_ITEM(openfile, NULL), + GNOMEUIINFO_SEPARATOR, + GNOMEUIINFO_MENU_CLOSE_ITEM(closeapp, NULL), + GNOMEUIINFO_MENU_EXIT_ITEM(shutdown, NULL), + GNOMEUIINFO_END +}; + +GnomeUIInfo helpMenu[] = +{ + /* GNOMEUIINFO_HELP("gnomelayout"), */ + GNOMEUIINFO_MENU_ABOUT_ITEM(showabout, NULL), + GNOMEUIINFO_END +}; + +GnomeUIInfo mainMenu[] = +{ + GNOMEUIINFO_SUBTREE(N_((gchar *) "File"), fileMenu), + GNOMEUIINFO_SUBTREE(N_((gchar *) "Help"), helpMenu), + GNOMEUIINFO_END +}; + +static gint eventDelete(GtkWidget *widget, GdkEvent *event, gpointer data) +{ + closeSample(widget); + + /* indicate that closeapp already destroyed the window */ + return TRUE; +} + +static gint eventConfigure(GtkWidget *widget, GdkEventConfigure *event, Context *context) +{ + if (context->paragraph != NULL) { + context->width = event->width; + context->height = event->height; + + if (context->width > 0 && context->height > 0) { + pf_breakLines(context->paragraph, context->width, context->height); + } + } + + return TRUE; +} + +static gint eventExpose(GtkWidget *widget, GdkEvent *event, Context *context) +{ + if (context->paragraph != NULL) { + gint maxLines = pf_getLineCount(context->paragraph) - 1; + gint firstLine = 0, lastLine = context->height / pf_getLineHeight(context->paragraph); + rs_surface *surface = rs_gnomeRenderingSurfaceOpen(widget); + + pf_draw(context->paragraph, surface, firstLine, (maxLines < lastLine)? maxLines : lastLine); + + rs_gnomeRenderingSurfaceClose(surface); + } + + return TRUE; +} + +GtkWidget *newSample(const gchar *fileName) +{ + Context *context = NEW_ARRAY(Context, 1); + gchar *title; + GtkWidget *app; + GtkWidget *area; + GtkStyle *style; + int i; + + context->width = 600; + context->height = 400; + context->paragraph = pf_factory(fileName, font, guiSupport); + + title = prettyTitle(fileName); + app = gnome_app_new("gnomeLayout", title); + + gtk_object_set_data(GTK_OBJECT(app), "context", context); + + gtk_window_set_default_size(GTK_WINDOW(app), 600 - 24, 400); + + gnome_app_create_menus_with_data(GNOME_APP(app), mainMenu, app); + + gtk_signal_connect(GTK_OBJECT(app), "delete_event", + GTK_SIGNAL_FUNC(eventDelete), NULL); + + area = gtk_drawing_area_new(); + gtk_object_set_data(GTK_OBJECT(app), "area", area); + + style = gtk_style_copy(gtk_widget_get_style(area)); + + for (i = 0; i < 5; i += 1) { + style->fg[i] = style->white; + } + + gtk_widget_set_style(area, style); + + gnome_app_set_contents(GNOME_APP(app), area); + + gtk_signal_connect(GTK_OBJECT(area), + "expose_event", + GTK_SIGNAL_FUNC(eventExpose), + context); + + gtk_signal_connect(GTK_OBJECT(area), + "configure_event", + GTK_SIGNAL_FUNC(eventConfigure), + context); + + appList = g_slist_prepend(appList, app); + + g_free(title); + + return app; +} + +void closeSample(GtkWidget *app) +{ + Context *context = (Context *) gtk_object_get_data(GTK_OBJECT(app), "context"); + + if (context->paragraph != NULL) { + pf_close(context->paragraph); + } + + DELETE_ARRAY(context); + + appList = g_slist_remove(appList, app); + + gtk_widget_destroy(app); + + if (appList == NULL) { + gtk_main_quit(); + } +} + +int main (int argc, char *argv[]) +{ + LEErrorCode fontStatus = LE_NO_ERROR; + poptContext ptctx; + GtkWidget *app; + const char *defaultArgs[] = {"Sample.txt", NULL}; + const char **args; + int i; + + FT_Init_FreeType(&engine); + + gnome_init_with_popt_table("gnomelayout", "0.1", argc, argv, NULL, 0, &ptctx); + + guiSupport = gs_gnomeGuiSupportOpen(); + fontMap = fm_gnomeFontMapOpen(engine, "FontMap.Gnome", 24, guiSupport, &fontStatus); + font = le_scriptCompositeFontOpen(fontMap); + + if (LE_FAILURE(fontStatus)) { + FT_Done_FreeType(engine); + return 1; + } + + args = poptGetArgs(ptctx); + + if (args == NULL) { + args = defaultArgs; + } + + for (i = 0; args[i] != NULL; i += 1) { + app = newSample(args[i]); + + gtk_widget_show_all(app); + } + + poptFreeContext(ptctx); + + gtk_main(); + + le_fontClose(font); + gs_gnomeGuiSupportClose(guiSupport); + + FT_Done_FreeType(engine); + + exit(0); +} diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/clayout.c b/Build/source/libs/icu/icu-xetex/samples/layout/clayout.c new file mode 100644 index 00000000000..701ab8dc09c --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/clayout.c @@ -0,0 +1,363 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2007, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: Layout.cpp + * + * created on: 08/03/2000 + * created by: Eric R. Mader + */ + +#include <windows.h> +#include <stdio.h> + +#include "playout.h" +#include "pflow.h" + +#include "gdiglue.h" +#include "ucreader.h" + +#include "arraymem.h" + +#include "resource.h" + +struct Context +{ + le_int32 width; + le_int32 height; + pf_flow *paragraph; +}; + +typedef struct Context Context; + +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); + +#define APP_NAME "LayoutSample" + +TCHAR szAppName[] = TEXT(APP_NAME); + +void PrettyTitle(HWND hwnd, char *fileName) +{ + char title[MAX_PATH + 64]; + + sprintf(title, "%s - %s", APP_NAME, fileName); + + SetWindowTextA(hwnd, title); +} + +void InitParagraph(HWND hwnd, Context *context) +{ + SCROLLINFO si; + + if (context->paragraph != NULL) { + // FIXME: does it matter what we put in the ScrollInfo + // if the window's been minimized? + if (context->width > 0 && context->height > 0) { + pf_breakLines(context->paragraph, context->width, context->height); + } + + si.cbSize = sizeof si; + si.fMask = SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL; + si.nMin = 0; + si.nMax = pf_getLineCount(context->paragraph) - 1; + si.nPage = context->height / pf_getLineHeight(context->paragraph); + SetScrollInfo(hwnd, SB_VERT, &si, TRUE); + } +} + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) +{ + HWND hwnd; + HACCEL hAccel; + MSG msg; + WNDCLASS wndclass; + LEErrorCode status = LE_NO_ERROR; + + wndclass.style = CS_HREDRAW | CS_VREDRAW; + wndclass.lpfnWndProc = WndProc; + wndclass.cbClsExtra = 0; + wndclass.cbWndExtra = sizeof(LONG); + wndclass.hInstance = hInstance; + wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); + wndclass.lpszMenuName = szAppName; + wndclass.lpszClassName = szAppName; + + if (!RegisterClass(&wndclass)) { + MessageBox(NULL, TEXT("This demo only runs on Windows 2000!"), szAppName, MB_ICONERROR); + + return 0; + } + + hAccel = LoadAccelerators(hInstance, szAppName); + + hwnd = CreateWindow(szAppName, NULL, + WS_OVERLAPPEDWINDOW | WS_VSCROLL, + CW_USEDEFAULT, CW_USEDEFAULT, + 600, 400, + NULL, NULL, hInstance, NULL); + + ShowWindow(hwnd, iCmdShow); + UpdateWindow(hwnd); + + while (GetMessage(&msg, NULL, 0, 0)) { + if (!TranslateAccelerator(hwnd, hAccel, &msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + UnregisterClass(szAppName, hInstance); + return msg.wParam; +} + +LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + Context *context; + static le_int32 windowCount = 0; + static fm_fontMap *fontMap = NULL; + static rs_surface *surface = NULL; + static gs_guiSupport *guiSupport = NULL; + static le_font *font = NULL; + + switch (message) { + case WM_CREATE: + { + LEErrorCode fontStatus = LE_NO_ERROR; + + hdc = GetDC(hwnd); + guiSupport = gs_gdiGuiSupportOpen(); + surface = rs_gdiRenderingSurfaceOpen(hdc); + + fontMap = fm_gdiFontMapOpen(surface, "FontMap.GDI", 24, guiSupport, &fontStatus); + font = le_scriptCompositeFontOpen(fontMap); + + if (LE_FAILURE(fontStatus)) { + ReleaseDC(hwnd, hdc); + return -1; + } + + context = NEW_ARRAY(Context, 1); + + context->width = 600; + context->height = 400; + + context->paragraph = pf_factory("Sample.txt", font, guiSupport); + SetWindowLongPtr(hwnd, 0, (LONG_PTR) context); + + windowCount += 1; + ReleaseDC(hwnd, hdc); + + PrettyTitle(hwnd, "Sample.txt"); + return 0; + } + + case WM_SIZE: + { + context = (Context *) GetWindowLongPtr(hwnd, 0); + context->width = LOWORD(lParam); + context->height = HIWORD(lParam); + + InitParagraph(hwnd, context); + return 0; + } + + case WM_VSCROLL: + { + SCROLLINFO si; + le_int32 vertPos; + + si.cbSize = sizeof si; + si.fMask = SIF_ALL; + GetScrollInfo(hwnd, SB_VERT, &si); + + vertPos = si.nPos; + + switch (LOWORD(wParam)) + { + case SB_TOP: + si.nPos = si.nMin; + break; + + case SB_BOTTOM: + si.nPos = si.nMax; + break; + + case SB_LINEUP: + si.nPos -= 1; + break; + + case SB_LINEDOWN: + si.nPos += 1; + break; + + case SB_PAGEUP: + si.nPos -= si.nPage; + break; + + case SB_PAGEDOWN: + si.nPos += si.nPage; + break; + + case SB_THUMBTRACK: + si.nPos = si.nTrackPos; + break; + + default: + break; + } + + si.fMask = SIF_POS; + SetScrollInfo(hwnd, SB_VERT, &si, TRUE); + GetScrollInfo(hwnd, SB_VERT, &si); + + context = (Context *) GetWindowLongPtr(hwnd, 0); + + if (context->paragraph != NULL && si.nPos != vertPos) { + ScrollWindow(hwnd, 0, pf_getLineHeight(context->paragraph) * (vertPos - si.nPos), NULL, NULL); + UpdateWindow(hwnd); + } + + return 0; + } + + case WM_PAINT: + { + PAINTSTRUCT ps; + SCROLLINFO si; + le_int32 firstLine, lastLine; + + hdc = BeginPaint(hwnd, &ps); + SetBkMode(hdc, TRANSPARENT); + + si.cbSize = sizeof si; + si.fMask = SIF_ALL; + GetScrollInfo(hwnd, SB_VERT, &si); + + firstLine = si.nPos; + + context = (Context *) GetWindowLongPtr(hwnd, 0); + + if (context->paragraph != NULL) { + rs_gdiRenderingSurfaceSetHDC(surface, hdc); + + // NOTE: si.nPos + si.nPage may include a partial line at the bottom + // of the window. We need this because scrolling assumes that the + // partial line has been painted. + lastLine = min (si.nPos + (le_int32) si.nPage, pf_getLineCount(context->paragraph) - 1); + + pf_draw(context->paragraph, surface, firstLine, lastLine); + } + + EndPaint(hwnd, &ps); + return 0; + } + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDM_FILE_OPEN: + { + OPENFILENAMEA ofn; + char szFileName[MAX_PATH], szTitleName[MAX_PATH]; + static char szFilter[] = "Text Files (.txt)\0*.txt\0" + "All Files (*.*)\0*.*\0\0"; + + ofn.lStructSize = sizeof (OPENFILENAMEA); + ofn.hwndOwner = hwnd; + ofn.hInstance = NULL; + ofn.lpstrFilter = szFilter; + ofn.lpstrCustomFilter = NULL; + ofn.nMaxCustFilter = 0; + ofn.nFilterIndex = 0; + ofn.lpstrFile = szFileName; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrFileTitle = szTitleName; + ofn.nMaxFileTitle = MAX_PATH; + ofn.lpstrInitialDir = NULL; + ofn.lpstrTitle = NULL; + ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST; + ofn.nFileOffset = 0; + ofn.nFileExtension = 0; + ofn.lpstrDefExt = "txt"; + ofn.lCustData = 0L; + ofn.lpfnHook = NULL; + ofn.lpTemplateName = NULL; + + szFileName[0] = '\0'; + + if (GetOpenFileNameA(&ofn)) { + pf_flow *newParagraph; + + hdc = GetDC(hwnd); + rs_gdiRenderingSurfaceSetHDC(surface, hdc); + + newParagraph = pf_factory(szFileName, font, guiSupport); + + if (newParagraph != NULL) { + context = (Context *) GetWindowLongPtr(hwnd, 0); + + if (context->paragraph != NULL) { + pf_close(context->paragraph); + } + + context->paragraph = newParagraph; + InitParagraph(hwnd, context); + PrettyTitle(hwnd, szTitleName); + InvalidateRect(hwnd, NULL, TRUE); + + } + } + + //ReleaseDC(hwnd, hdc); + + return 0; + } + + case IDM_FILE_EXIT: + case IDM_FILE_CLOSE: + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 0; + + case IDM_HELP_ABOUTLAYOUTSAMPLE: + MessageBox(hwnd, TEXT("Windows Layout Sample 0.1\n") + TEXT("Copyright (C) 1998-2005 By International Business Machines Corporation and others.\n") + TEXT("Author: Eric Mader"), + szAppName, MB_ICONINFORMATION | MB_OK); + return 0; + + } + break; + + + case WM_DESTROY: + { + context = (Context *) GetWindowLongPtr(hwnd, 0); + + if (context != NULL && context->paragraph != NULL) { + pf_close(context->paragraph); + } + + DELETE_ARRAY(context); + + if (--windowCount <= 0) { + le_fontClose(font); + rs_gdiRenderingSurfaceClose(surface); + gs_gdiGuiSupportClose(guiSupport); + + PostQuitMessage(0); + } + + return 0; + } + + default: + return DefWindowProc(hwnd, message, wParam, lParam); + } + + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/cmaps.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/cmaps.cpp new file mode 100644 index 00000000000..33b5cbb801f --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/cmaps.cpp @@ -0,0 +1,206 @@ +/* + ****************************************************************************** * + * + * Copyright (C) 1999-2003, International Business Machines + * Corporation and others. All Rights Reserved. + * + ****************************************************************************** * + * file name: cmaps.cpp + * + * created on: ??/??/2001 + * created by: Eric R. Mader + */ + +#include "layout/LETypes.h" +#include "layout/LESwaps.h" + +#include "sfnt.h" +#include "cmaps.h" + +#define SWAPU16(code) ((LEUnicode16) SWAPW(code)) +#define SWAPU32(code) ((LEUnicode32) SWAPL(code)) + +// +// Finds the high bit by binary searching +// through the bits in value. +// +le_uint8 highBit(le_uint32 value) +{ + le_uint8 bit = 0; + + if (value >= 1 << 16) { + value >>= 16; + bit += 16; + } + + if (value >= 1 << 8) { + value >>= 8; + bit += 8; + } + + if (value >= 1 << 4) { + value >>= 4; + bit += 4; + } + + if (value >= 1 << 2) { + value >>= 2; + bit += 2; + } + + if (value >= 1 << 1) { + value >>= 1; + bit += 1; + } + + return bit; +} + +CMAPMapper *CMAPMapper::createUnicodeMapper(const CMAPTable *cmap) +{ + le_uint16 i; + le_uint16 nSubtables = SWAPW(cmap->numberSubtables); + const CMAPEncodingSubtable *subtable = NULL; + le_uint32 offset1 = 0, offset10 = 0; + + for (i = 0; i < nSubtables; i += 1) { + const CMAPEncodingSubtableHeader *esh = &cmap->encodingSubtableHeaders[i]; + + if (SWAPW(esh->platformID) == 3) { + switch (SWAPW(esh->platformSpecificID)) { + case 1: + offset1 = SWAPL(esh->encodingOffset); + break; + + case 10: + offset10 = SWAPL(esh->encodingOffset); + break; + } + } + } + + + if (offset10 != 0) + { + subtable = (const CMAPEncodingSubtable *) ((const char *) cmap + offset10); + } else if (offset1 != 0) { + subtable = (const CMAPEncodingSubtable *) ((const char *) cmap + offset1); + } else { + return NULL; + } + + switch (SWAPW(subtable->format)) { + case 4: + return new CMAPFormat4Mapper(cmap, (const CMAPFormat4Encoding *) subtable); + + case 12: + { + const CMAPFormat12Encoding *encoding = (const CMAPFormat12Encoding *) subtable; + + return new CMAPGroupMapper(cmap, encoding->groups, SWAPL(encoding->nGroups)); + } + + default: + break; + } + + return NULL; +} + +CMAPFormat4Mapper::CMAPFormat4Mapper(const CMAPTable *cmap, const CMAPFormat4Encoding *header) + : CMAPMapper(cmap) +{ + le_uint16 segCount = SWAPW(header->segCountX2) / 2; + + fEntrySelector = SWAPW(header->entrySelector); + fRangeShift = SWAPW(header->rangeShift) / 2; + fEndCodes = &header->endCodes[0]; + fStartCodes = &header->endCodes[segCount + 1]; // + 1 for reservedPad... + fIdDelta = &fStartCodes[segCount]; + fIdRangeOffset = &fIdDelta[segCount]; +} + +LEGlyphID CMAPFormat4Mapper::unicodeToGlyph(LEUnicode32 unicode32) const +{ + if (unicode32 >= 0x10000) { + return 0; + } + + LEUnicode16 unicode = (LEUnicode16) unicode32; + le_uint16 index = 0; + le_uint16 probe = 1 << fEntrySelector; + TTGlyphID result = 0; + + if (SWAPU16(fStartCodes[fRangeShift]) <= unicode) { + index = fRangeShift; + } + + while (probe > (1 << 0)) { + probe >>= 1; + + if (SWAPU16(fStartCodes[index + probe]) <= unicode) { + index += probe; + } + } + + if (unicode >= SWAPU16(fStartCodes[index]) && unicode <= SWAPU16(fEndCodes[index])) { + if (fIdRangeOffset[index] == 0) { + result = (TTGlyphID) unicode; + } else { + le_uint16 offset = unicode - SWAPU16(fStartCodes[index]); + le_uint16 rangeOffset = SWAPW(fIdRangeOffset[index]); + le_uint16 *glyphIndexTable = (le_uint16 *) ((char *) &fIdRangeOffset[index] + rangeOffset); + + result = SWAPW(glyphIndexTable[offset]); + } + + result += SWAPW(fIdDelta[index]); + } else { + result = 0; + } + + return LE_SET_GLYPH(0, result); +} + +CMAPFormat4Mapper::~CMAPFormat4Mapper() +{ + // parent destructor does it all +} + +CMAPGroupMapper::CMAPGroupMapper(const CMAPTable *cmap, const CMAPGroup *groups, le_uint32 nGroups) + : CMAPMapper(cmap), fGroups(groups) +{ + le_uint8 bit = highBit(nGroups); + fPower = 1 << bit; + fRangeOffset = nGroups - fPower; +} + +LEGlyphID CMAPGroupMapper::unicodeToGlyph(LEUnicode32 unicode32) const +{ + le_int32 probe = fPower; + le_int32 range = 0; + + if (SWAPU32(fGroups[fRangeOffset].startCharCode) <= unicode32) { + range = fRangeOffset; + } + + while (probe > (1 << 0)) { + probe >>= 1; + + if (SWAPU32(fGroups[range + probe].startCharCode) <= unicode32) { + range += probe; + } + } + + if (SWAPU32(fGroups[range].startCharCode) <= unicode32 && SWAPU32(fGroups[range].endCharCode) >= unicode32) { + return (LEGlyphID) (SWAPU32(fGroups[range].startGlyphCode) + unicode32 - SWAPU32(fGroups[range].startCharCode)); + } + + return 0; +} + +CMAPGroupMapper::~CMAPGroupMapper() +{ + // parent destructor does it all +} + diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/cmaps.h b/Build/source/libs/icu/icu-xetex/samples/layout/cmaps.h new file mode 100644 index 00000000000..868c357b763 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/cmaps.h @@ -0,0 +1,89 @@ +/* + ****************************************************************************** * + * + * Copyright (C) 1999-2003, International Business Machines + * Corporation and others. All Rights Reserved. + * + ****************************************************************************** * + * file name: cmaps.h + * + * created on: ??/??/2001 + * created by: Eric R. Mader + */ + +#ifndef __CMAPS_H +#define __CMAPS_H + +#include "layout/LETypes.h" +#include "sfnt.h" + +class CMAPMapper +{ +public: + virtual LEGlyphID unicodeToGlyph(LEUnicode32 unicode32) const = 0; + + virtual ~CMAPMapper(); + + static CMAPMapper *createUnicodeMapper(const CMAPTable *cmap); + +protected: + CMAPMapper(const CMAPTable *cmap); + + CMAPMapper() {}; + +private: + const CMAPTable *fcmap; +}; + +class CMAPFormat4Mapper : public CMAPMapper +{ +public: + CMAPFormat4Mapper(const CMAPTable *cmap, const CMAPFormat4Encoding *header); + + virtual ~CMAPFormat4Mapper(); + + virtual LEGlyphID unicodeToGlyph(LEUnicode32 unicode32) const; + +protected: + CMAPFormat4Mapper() {}; + +private: + le_uint16 fEntrySelector; + le_uint16 fRangeShift; + const le_uint16 *fEndCodes; + const le_uint16 *fStartCodes; + const le_uint16 *fIdDelta; + const le_uint16 *fIdRangeOffset; +}; + +class CMAPGroupMapper : public CMAPMapper +{ +public: + CMAPGroupMapper(const CMAPTable *cmap, const CMAPGroup *groups, le_uint32 nGroups); + + virtual ~CMAPGroupMapper(); + + virtual LEGlyphID unicodeToGlyph(LEUnicode32 unicode32) const; + +protected: + CMAPGroupMapper() {}; + +private: + le_int32 fPower; + le_int32 fRangeOffset; + const CMAPGroup *fGroups; +}; + +inline CMAPMapper::CMAPMapper(const CMAPTable *cmap) + : fcmap(cmap) +{ + // nothing else to do +} + +inline CMAPMapper::~CMAPMapper() +{ + LE_DELETE_ARRAY(fcmap); +} + +#endif + diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/gdiglue.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/gdiglue.cpp new file mode 100644 index 00000000000..e553c0617b1 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/gdiglue.cpp @@ -0,0 +1,80 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#include <windows.h> + +#include "unicode/utypes.h" +#include "loengine.h" +#include "rsurface.h" +#include "gsupport.h" + +#include "gdiglue.h" + +#include "LETypes.h" +#include "LEFontInstance.h" +#include "GDIGUISupport.h" +#include "GDIFontMap.h" +#include "ScriptCompositeFontInstance.h" + + +U_CDECL_BEGIN + +gs_guiSupport *gs_gdiGuiSupportOpen() +{ + return (gs_guiSupport *) new GDIGUISupport(); +} + +void gs_gdiGuiSupportClose(gs_guiSupport *guiSupport) +{ + GDIGUISupport *gs = (GDIGUISupport *) guiSupport; + + delete gs; +} + +rs_surface *rs_gdiRenderingSurfaceOpen(HDC hdc) +{ + return (rs_surface *) new GDISurface(hdc); +} + +void rs_gdiRenderingSurfaceSetHDC(rs_surface *surface, HDC hdc) +{ + GDISurface *rs = (GDISurface *) surface; + + rs->setHDC(hdc); +} + +void rs_gdiRenderingSurfaceClose(rs_surface *surface) +{ + GDISurface *rs = (GDISurface *) surface; + + delete rs; +} + +fm_fontMap *fm_gdiFontMapOpen(rs_surface *surface, const char *fileName, le_int16 pointSize, gs_guiSupport *guiSupport, LEErrorCode *status) +{ + return (fm_fontMap *) new GDIFontMap((GDISurface *) surface, fileName, pointSize, (GDIGUISupport *) guiSupport, *status); +} + +void fm_fontMapClose(fm_fontMap *fontMap) +{ + GDIFontMap *fm = (GDIFontMap *) fontMap; + + delete fm; +} + +le_font *le_scriptCompositeFontOpen(fm_fontMap *fontMap) +{ + return (le_font *) new ScriptCompositeFontInstance((FontMap *) fontMap); +} + +void le_fontClose(le_font *font) +{ + LEFontInstance *fi = (LEFontInstance *) font; + + delete fi; +} + +U_CDECL_END diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/gdiglue.h b/Build/source/libs/icu/icu-xetex/samples/layout/gdiglue.h new file mode 100644 index 00000000000..bdd8422bb65 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/gdiglue.h @@ -0,0 +1,38 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#ifndef __GDIGLUE_H +#define __GDIGLUE_H + +#include <windows.h> + +#include "unicode/utypes.h" + +#include "LETypes.h" +#include "loengine.h" +#include "gsupport.h" +#include "rsurface.h" + +typedef void fm_fontMap; + +U_CDECL_BEGIN + +gs_guiSupport *gs_gdiGuiSupportOpen(); +void gs_gdiGuiSupportClose(gs_guiSupport *guiSupport); + +rs_surface *rs_gdiRenderingSurfaceOpen(HDC hdc); +void rs_gdiRenderingSurfaceSetHDC(rs_surface *surface, HDC hdc); +void rs_gdiRenderingSurfaceClose(rs_surface *surface); + +fm_fontMap *fm_gdiFontMapOpen(rs_surface *surface, const char *fileName, le_int16 pointSize, gs_guiSupport *guiSupport, LEErrorCode *status); +void fm_fontMapClose(fm_fontMap *fontMap); + +le_font *le_scriptCompositeFontOpen(fm_fontMap *fontMap); +void le_fontClose(le_font *font); + +U_CDECL_END + +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/gnomeglue.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/gnomeglue.cpp new file mode 100644 index 00000000000..a081e0bfcbf --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/gnomeglue.cpp @@ -0,0 +1,76 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#include <gnome.h> +#include <ft2build.h> +#include FT_FREETYPE_H + +#include "unicode/utypes.h" +#include "loengine.h" +#include "rsurface.h" +#include "gsupport.h" + +#include "gnomeglue.h" + +#include "LETypes.h" +#include "LEFontInstance.h" +#include "GnomeGUISupport.h" +#include "GnomeFontMap.h" +#include "GnomeFontInstance.h" +#include "ScriptCompositeFontInstance.h" + + +U_CDECL_BEGIN + +gs_guiSupport *gs_gnomeGuiSupportOpen() +{ + return (gs_guiSupport *) new GnomeGUISupport(); +} + +void gs_gnomeGuiSupportClose(gs_guiSupport *guiSupport) +{ + GnomeGUISupport *gs = (GnomeGUISupport *) guiSupport; + + delete gs; +} + +rs_surface *rs_gnomeRenderingSurfaceOpen(GtkWidget *theWidget) +{ + return (rs_surface *) new GnomeSurface(theWidget); +} + +void rs_gnomeRenderingSurfaceClose(rs_surface *surface) +{ + GnomeSurface *rs = (GnomeSurface *) surface; + + delete rs; +} + +fm_fontMap *fm_gnomeFontMapOpen(FT_Library engine, const char *fileName, le_int16 pointSize, gs_guiSupport *guiSupport, LEErrorCode *status) +{ + return (fm_fontMap *) new GnomeFontMap(engine, fileName, pointSize, (GnomeGUISupport *) guiSupport, *status); +} + +void fm_fontMapClose(fm_fontMap *fontMap) +{ + GnomeFontMap *fm = (GnomeFontMap *) fontMap; + + delete fm; +} + +le_font *le_scriptCompositeFontOpen(fm_fontMap *fontMap) +{ + return (le_font *) new ScriptCompositeFontInstance((FontMap *) fontMap); +} + +void le_fontClose(le_font *font) +{ + LEFontInstance *fi = (LEFontInstance *) font; + + delete fi; +} + +U_CDECL_END diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/gnomeglue.h b/Build/source/libs/icu/icu-xetex/samples/layout/gnomeglue.h new file mode 100644 index 00000000000..78561468eee --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/gnomeglue.h @@ -0,0 +1,39 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#ifndef __GNOMEGLUE_H +#define __GNOMEGLUE_H + +#include <gnome.h> +#include <ft2build.h> +#include FT_FREETYPE_H + +#include "unicode/utypes.h" + +#include "LETypes.h" +#include "loengine.h" +#include "gsupport.h" +#include "rsurface.h" + +typedef void fm_fontMap; + +U_CDECL_BEGIN + +gs_guiSupport *gs_gnomeGuiSupportOpen(); +void gs_gnomeGuiSupportClose(gs_guiSupport *guiSupport); + +rs_surface *rs_gnomeRenderingSurfaceOpen(GtkWidget *theWidget); +void rs_gnomeRenderingSurfaceClose(rs_surface *surface); + +fm_fontMap *fm_gnomeFontMapOpen(FT_Library engine, const char *fileName, le_int16 pointSize, gs_guiSupport *guiSupport, LEErrorCode *status); +void fm_fontMapClose(fm_fontMap *fontMap); + +le_font *le_scriptCompositeFontOpen(fm_fontMap *fontMap); +void le_fontClose(le_font *font); + +U_CDECL_END + +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/gnomelayout.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/gnomelayout.cpp new file mode 100644 index 00000000000..31e25871d45 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/gnomelayout.cpp @@ -0,0 +1,341 @@ + +/* + ****************************************************************************** * + * + * Copyright (C) 1999-2007, International Business Machines + * Corporation and others. All Rights Reserved. + * + ****************************************************************************** * + * file name: gnomelayout.cpp + * + * created on: 09/04/2001 + * created by: Eric R. Mader + */ + +#include <gnome.h> +#include <ft2build.h> +#include FT_FREETYPE_H + +#include "unicode/ustring.h" +#include "unicode/uscript.h" + +#include "GnomeFontInstance.h" + +#include "paragraph.h" + +#include "GnomeGUISupport.h" +#include "GnomeFontMap.h" +#include "UnicodeReader.h" +#include "ScriptCompositeFontInstance.h" + +#define ARRAY_LENGTH(array) (sizeof array / sizeof array[0]) + +struct Context +{ + long width; + long height; + Paragraph *paragraph; +}; + +static FT_Library engine; +static GnomeGUISupport *guiSupport; +static GnomeFontMap *fontMap; +static ScriptCompositeFontInstance *font; + +static GSList *appList = NULL; + +GtkWidget *newSample(const gchar *fileName); +void closeSample(GtkWidget *sample); + +void showabout(GtkWidget */*widget*/, gpointer /*data*/) +{ + GtkWidget *aboutBox; + const gchar *documentedBy[] = {NULL}; + const gchar *writtenBy[] = { + "Eric Mader", + NULL + }; + + aboutBox = gnome_about_new("Gnome Layout Sample", + "0.1", + "Copyright (C) 1998-2006 By International Business Machines Corporation and others. All Rights Reserved.", + "A simple demo of the ICU LayoutEngine.", + writtenBy, + documentedBy, + "", + NULL); + + gtk_widget_show(aboutBox); +} + +void notimpl(GtkObject */*object*/, gpointer /*data*/) +{ + gnome_ok_dialog("Not implemented..."); +} + +gchar *prettyTitle(const gchar *path) +{ + const gchar *name = g_basename(path); + gchar *title = g_strconcat("Gnome Layout Sample - ", name, NULL); + + return title; +} + +void openOK(GtkObject */*object*/, gpointer data) +{ + GtkFileSelection *fileselection = GTK_FILE_SELECTION(data); + GtkWidget *app = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(fileselection), "app")); + Context *context = (Context *) gtk_object_get_data(GTK_OBJECT(app), "context"); + gchar *fileName = g_strdup(gtk_file_selection_get_filename(fileselection)); + Paragraph *newPara; + + gtk_widget_destroy(GTK_WIDGET(fileselection)); + + newPara = Paragraph::paragraphFactory(fileName, font, guiSupport); + + if (newPara != NULL) { + gchar *title = prettyTitle(fileName); + GtkWidget *area = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(app), "area")); + + if (context->paragraph != NULL) { + delete context->paragraph; + } + + context->paragraph = newPara; + gtk_window_set_title(GTK_WINDOW(app), title); + + gtk_widget_hide(area); + context->paragraph->breakLines(context->width, context->height); + gtk_widget_show_all(area); + + g_free(title); + } + + g_free(fileName); +} + +void openfile(GtkObject */*object*/, gpointer data) +{ + GtkWidget *app = GTK_WIDGET(data); + GtkWidget *fileselection; + GtkWidget *okButton; + GtkWidget *cancelButton; + + fileselection = + gtk_file_selection_new("Open File"); + + gtk_object_set_data(GTK_OBJECT(fileselection), "app", app); + + okButton = + GTK_FILE_SELECTION(fileselection)->ok_button; + + cancelButton = + GTK_FILE_SELECTION(fileselection)->cancel_button; + + gtk_signal_connect(GTK_OBJECT(fileselection), "destroy", + GTK_SIGNAL_FUNC(gtk_main_quit), NULL); + + gtk_signal_connect(GTK_OBJECT(okButton), "clicked", + GTK_SIGNAL_FUNC(openOK), fileselection); + + gtk_signal_connect_object(GTK_OBJECT(cancelButton), "clicked", + GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(fileselection)); + + gtk_window_set_modal(GTK_WINDOW(fileselection), TRUE); + gtk_widget_show(fileselection); + gtk_main(); +} + +void newapp(GtkObject */*object*/, gpointer /*data*/) +{ + GtkWidget *app = newSample("Sample.txt"); + + gtk_widget_show_all(app); +} + +void closeapp(GtkWidget */*widget*/, gpointer data) +{ + GtkWidget *app = GTK_WIDGET(data); + + closeSample(app); +} + +void shutdown(GtkObject */*object*/, gpointer /*data*/) +{ + gtk_main_quit(); +} + +GnomeUIInfo fileMenu[] = +{ + GNOMEUIINFO_MENU_NEW_ITEM((gchar *) "_New Sample", + (gchar *) "Create a new Gnome Layout Sample", + newapp, NULL), + + GNOMEUIINFO_MENU_OPEN_ITEM(openfile, NULL), + GNOMEUIINFO_SEPARATOR, + GNOMEUIINFO_MENU_CLOSE_ITEM(closeapp, NULL), + GNOMEUIINFO_MENU_EXIT_ITEM(shutdown, NULL), + GNOMEUIINFO_END +}; + +GnomeUIInfo helpMenu[] = +{ + // GNOMEUIINFO_HELP("gnomelayout"), + GNOMEUIINFO_MENU_ABOUT_ITEM(showabout, NULL), + GNOMEUIINFO_END +}; + +GnomeUIInfo mainMenu[] = +{ + GNOMEUIINFO_SUBTREE(N_((gchar *) "File"), fileMenu), + GNOMEUIINFO_SUBTREE(N_((gchar *) "Help"), helpMenu), + GNOMEUIINFO_END +}; + +gint eventDelete(GtkWidget *widget, GdkEvent */*event*/, gpointer /*data*/) +{ + closeSample(widget); + + // indicate that closeapp already destroyed the window + return TRUE; +} + +gint eventConfigure(GtkWidget */*widget*/, GdkEventConfigure *event, Context *context) +{ + if (context->paragraph != NULL) { + context->width = event->width; + context->height = event->height; + + if (context->width > 0 && context->height > 0) { + context->paragraph->breakLines(context->width, context->height); + } + } + + return TRUE; +} + +gint eventExpose(GtkWidget *widget, GdkEvent */*event*/, Context *context) +{ + if (context->paragraph != NULL) { + gint maxLines = context->paragraph->getLineCount() - 1; + gint firstLine = 0, lastLine = context->height / context->paragraph->getLineHeight(); + GnomeSurface surface(widget); + + context->paragraph->draw(&surface, firstLine, (maxLines < lastLine)? maxLines : lastLine); + } + + return TRUE; +} + +GtkWidget *newSample(const gchar *fileName) +{ + Context *context = new Context(); + + context->width = 600; + context->height = 400; + context->paragraph = Paragraph::paragraphFactory(fileName, font, guiSupport); + + gchar *title = prettyTitle(fileName); + GtkWidget *app = gnome_app_new("gnomeLayout", title); + + gtk_object_set_data(GTK_OBJECT(app), "context", context); + + gtk_window_set_default_size(GTK_WINDOW(app), 600 - 24, 400); + + gnome_app_create_menus_with_data(GNOME_APP(app), mainMenu, app); + + gtk_signal_connect(GTK_OBJECT(app), "delete_event", + GTK_SIGNAL_FUNC(eventDelete), NULL); + + GtkWidget *area = gtk_drawing_area_new(); + gtk_object_set_data(GTK_OBJECT(app), "area", area); + + GtkStyle *style = gtk_style_copy(gtk_widget_get_style(area)); + + for (int i = 0; i < 5; i += 1) { + style->fg[i] = style->white; + } + + gtk_widget_set_style(area, style); + + gnome_app_set_contents(GNOME_APP(app), area); + + gtk_signal_connect(GTK_OBJECT(area), + "expose_event", + GTK_SIGNAL_FUNC(eventExpose), + context); + + gtk_signal_connect(GTK_OBJECT(area), + "configure_event", + GTK_SIGNAL_FUNC(eventConfigure), + context); + + appList = g_slist_prepend(appList, app); + + g_free(title); + + return app; +} + +void closeSample(GtkWidget *app) +{ + Context *context = (Context *) gtk_object_get_data(GTK_OBJECT(app), "context"); + + if (context->paragraph != NULL) { + delete context->paragraph; + } + + delete context; + + appList = g_slist_remove(appList, app); + + gtk_widget_destroy(app); + + if (appList == NULL) { + gtk_main_quit(); + } +} + +int main (int argc, char *argv[]) +{ + LEErrorCode fontStatus = LE_NO_ERROR; + poptContext ptctx; + GtkWidget *app; + + FT_Init_FreeType(&engine); + + gnome_init_with_popt_table("gnomelayout", "0.1", argc, argv, NULL, 0, &ptctx); + + guiSupport = new GnomeGUISupport(); + fontMap = new GnomeFontMap(engine, "FontMap.Gnome", 24, guiSupport, fontStatus); + font = new ScriptCompositeFontInstance(fontMap); + + if (LE_FAILURE(fontStatus)) { + FT_Done_FreeType(engine); + return 1; + } + + const char *defaultArgs[] = {"Sample.txt", NULL}; + const char **args = poptGetArgs(ptctx); + + if (args == NULL) { + args = defaultArgs; + } + + for (int i = 0; args[i] != NULL; i += 1) { + app = newSample(args[i]); + + gtk_widget_show_all(app); + } + + poptFreeContext(ptctx); + + gtk_main(); + + delete font; + delete guiSupport; + + FT_Done_FreeType(engine); + + exit(0); +} diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/gsupport.h b/Build/source/libs/icu/icu-xetex/samples/layout/gsupport.h new file mode 100644 index 00000000000..26f33b4c064 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/gsupport.h @@ -0,0 +1,14 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#ifndef __GSUPPORT_H +#define __GSUPPORT_H + +typedef void gs_guiSupport; + +void gs_postErrorMessage(gs_guiSupport *guiSupport, const char *message, const char *title); + +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/layout.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/layout.cpp new file mode 100644 index 00000000000..8501757edb9 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/layout.cpp @@ -0,0 +1,358 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2007, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: Layout.cpp + * + * created on: 08/03/2000 + * created by: Eric R. Mader + */ + +#include <windows.h> +#include <stdio.h> + +#include "paragraph.h" + +#include "GDIGUISupport.h" +#include "GDIFontMap.h" +#include "UnicodeReader.h" +#include "ScriptCompositeFontInstance.h" + +#include "resource.h" + +#define ARRAY_LENGTH(array) (sizeof array / sizeof array[0]) + +struct Context +{ + le_int32 width; + le_int32 height; + Paragraph *paragraph; +}; + +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); + +#define APP_NAME "LayoutSample" + +TCHAR szAppName[] = TEXT(APP_NAME); + +void PrettyTitle(HWND hwnd, char *fileName) +{ + char title[MAX_PATH + 64]; + + sprintf(title, "%s - %s", APP_NAME, fileName); + + SetWindowTextA(hwnd, title); +} + +void InitParagraph(HWND hwnd, Context *context) +{ + SCROLLINFO si; + + if (context->paragraph != NULL) { + // FIXME: does it matter what we put in the ScrollInfo + // if the window's been minimized? + if (context->width > 0 && context->height > 0) { + context->paragraph->breakLines(context->width, context->height); + } + + si.cbSize = sizeof si; + si.fMask = SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL; + si.nMin = 0; + si.nMax = context->paragraph->getLineCount() - 1; + si.nPage = context->height / context->paragraph->getLineHeight(); + SetScrollInfo(hwnd, SB_VERT, &si, TRUE); + } +} + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) +{ + HWND hwnd; + HACCEL hAccel; + MSG msg; + WNDCLASS wndclass; + LEErrorCode status = LE_NO_ERROR; + + wndclass.style = CS_HREDRAW | CS_VREDRAW; + wndclass.lpfnWndProc = WndProc; + wndclass.cbClsExtra = 0; + wndclass.cbWndExtra = sizeof(LONG); + wndclass.hInstance = hInstance; + wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); + wndclass.lpszMenuName = szAppName; + wndclass.lpszClassName = szAppName; + + if (!RegisterClass(&wndclass)) { + MessageBox(NULL, TEXT("This demo only runs on Windows 2000!"), szAppName, MB_ICONERROR); + + return 0; + } + + hAccel = LoadAccelerators(hInstance, szAppName); + + hwnd = CreateWindow(szAppName, NULL, + WS_OVERLAPPEDWINDOW | WS_VSCROLL, + CW_USEDEFAULT, CW_USEDEFAULT, + 600, 400, + NULL, NULL, hInstance, NULL); + + ShowWindow(hwnd, iCmdShow); + UpdateWindow(hwnd); + + while (GetMessage(&msg, NULL, 0, 0)) { + if (!TranslateAccelerator(hwnd, hAccel, &msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + UnregisterClass(szAppName, hInstance); + return msg.wParam; +} + +LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + Context *context; + static le_int32 windowCount = 0; + static GDIFontMap *fontMap = NULL; + static GDISurface *surface = NULL; + static GDIGUISupport *guiSupport = new GDIGUISupport(); + static ScriptCompositeFontInstance *font = NULL; + + switch (message) { + case WM_CREATE: + { + LEErrorCode fontStatus = LE_NO_ERROR; + + hdc = GetDC(hwnd); + surface = new GDISurface(hdc); + + fontMap = new GDIFontMap(surface, "FontMap.GDI", 24, guiSupport, fontStatus); + font = new ScriptCompositeFontInstance(fontMap); + + if (LE_FAILURE(fontStatus)) { + ReleaseDC(hwnd, hdc); + return -1; + } + + context = new Context(); + + context->width = 600; + context->height = 400; + + context->paragraph = Paragraph::paragraphFactory("Sample.txt", font, guiSupport); + SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) context); + + windowCount += 1; + ReleaseDC(hwnd, hdc); + + PrettyTitle(hwnd, "Sample.txt"); + return 0; + } + + case WM_SIZE: + { + context = (Context *) GetWindowLongPtr(hwnd, GWLP_USERDATA); + context->width = LOWORD(lParam); + context->height = HIWORD(lParam); + + InitParagraph(hwnd, context); + return 0; + } + + case WM_VSCROLL: + { + SCROLLINFO si; + le_int32 vertPos; + + si.cbSize = sizeof si; + si.fMask = SIF_ALL; + GetScrollInfo(hwnd, SB_VERT, &si); + + vertPos = si.nPos; + + switch (LOWORD(wParam)) + { + case SB_TOP: + si.nPos = si.nMin; + break; + + case SB_BOTTOM: + si.nPos = si.nMax; + break; + + case SB_LINEUP: + si.nPos -= 1; + break; + + case SB_LINEDOWN: + si.nPos += 1; + break; + + case SB_PAGEUP: + si.nPos -= si.nPage; + break; + + case SB_PAGEDOWN: + si.nPos += si.nPage; + break; + + case SB_THUMBTRACK: + si.nPos = si.nTrackPos; + break; + + default: + break; + } + + si.fMask = SIF_POS; + SetScrollInfo(hwnd, SB_VERT, &si, TRUE); + GetScrollInfo(hwnd, SB_VERT, &si); + + context = (Context *) GetWindowLongPtr(hwnd, GWLP_USERDATA); + + if (context->paragraph != NULL && si.nPos != vertPos) { + ScrollWindow(hwnd, 0, context->paragraph->getLineHeight() * (vertPos - si.nPos), NULL, NULL); + UpdateWindow(hwnd); + } + + return 0; + } + + case WM_PAINT: + { + PAINTSTRUCT ps; + SCROLLINFO si; + le_int32 firstLine, lastLine; + + hdc = BeginPaint(hwnd, &ps); + SetBkMode(hdc, TRANSPARENT); + + si.cbSize = sizeof si; + si.fMask = SIF_ALL; + GetScrollInfo(hwnd, SB_VERT, &si); + + firstLine = si.nPos; + + context = (Context *) GetWindowLongPtr(hwnd, GWLP_USERDATA); + + if (context->paragraph != NULL) { + surface->setHDC(hdc); + + // NOTE: si.nPos + si.nPage may include a partial line at the bottom + // of the window. We need this because scrolling assumes that the + // partial line has been painted. + lastLine = min (si.nPos + (le_int32) si.nPage, context->paragraph->getLineCount() - 1); + + context->paragraph->draw(surface, firstLine, lastLine); + } + + EndPaint(hwnd, &ps); + return 0; + } + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDM_FILE_OPEN: + { + OPENFILENAMEA ofn; + char szFileName[MAX_PATH], szTitleName[MAX_PATH]; + static char szFilter[] = "Text Files (.txt)\0*.txt\0" + "All Files (*.*)\0*.*\0\0"; + + ofn.lStructSize = sizeof (OPENFILENAMEA); + ofn.hwndOwner = hwnd; + ofn.hInstance = NULL; + ofn.lpstrFilter = szFilter; + ofn.lpstrCustomFilter = NULL; + ofn.nMaxCustFilter = 0; + ofn.nFilterIndex = 0; + ofn.lpstrFile = szFileName; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrFileTitle = szTitleName; + ofn.nMaxFileTitle = MAX_PATH; + ofn.lpstrInitialDir = NULL; + ofn.lpstrTitle = NULL; + ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST; + ofn.nFileOffset = 0; + ofn.nFileExtension = 0; + ofn.lpstrDefExt = "txt"; + ofn.lCustData = 0L; + ofn.lpfnHook = NULL; + ofn.lpTemplateName = NULL; + + szFileName[0] = '\0'; + + if (GetOpenFileNameA(&ofn)) { + hdc = GetDC(hwnd); + surface->setHDC(hdc); + + Paragraph *newParagraph = Paragraph::paragraphFactory(szFileName, font, guiSupport); + + if (newParagraph != NULL) { + context = (Context *) GetWindowLongPtr(hwnd, GWLP_USERDATA); + + if (context->paragraph != NULL) { + delete context->paragraph; + } + + context->paragraph = newParagraph; + InitParagraph(hwnd, context); + PrettyTitle(hwnd, szTitleName); + InvalidateRect(hwnd, NULL, TRUE); + + } + } + + //ReleaseDC(hwnd, hdc); + + return 0; + } + + case IDM_FILE_EXIT: + case IDM_FILE_CLOSE: + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 0; + + case IDM_HELP_ABOUTLAYOUTSAMPLE: + MessageBox(hwnd, TEXT("Windows Layout Sample 0.1\n") + TEXT("Copyright (C) 1998-2005 By International Business Machines Corporation and others.\n") + TEXT("Author: Eric Mader"), + szAppName, MB_ICONINFORMATION | MB_OK); + return 0; + + } + break; + + + case WM_DESTROY: + { + context = (Context *) GetWindowLongPtr(hwnd, GWLP_USERDATA); + + if (context != NULL && context->paragraph != NULL) { + delete context->paragraph; + } + + delete context; + + if (--windowCount <= 0) { + delete font; + delete surface; + + PostQuitMessage(0); + } + + return 0; + } + + default: + return DefWindowProc(hwnd, message, wParam, lParam); + } + + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/layout.sln b/Build/source/libs/icu/icu-xetex/samples/layout/layout.sln new file mode 100644 index 00000000000..1be523e3bd5 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/layout.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "layout", "layout.vcproj", "{497500ED-DE1D-4B20-B529-F41B5A0FBEEB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {497500ED-DE1D-4B20-B529-F41B5A0FBEEB}.Debug|Win32.ActiveCfg = Debug|Win32 + {497500ED-DE1D-4B20-B529-F41B5A0FBEEB}.Debug|Win32.Build.0 = Debug|Win32 + {497500ED-DE1D-4B20-B529-F41B5A0FBEEB}.Release|Win32.ActiveCfg = Release|Win32 + {497500ED-DE1D-4B20-B529-F41B5A0FBEEB}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/layout.vcproj b/Build/source/libs/icu/icu-xetex/samples/layout/layout.vcproj new file mode 100644 index 00000000000..c9c13375254 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/layout.vcproj @@ -0,0 +1,313 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="layout" + ProjectGUID="{497500ED-DE1D-4B20-B529-F41B5A0FBEEB}" + > + <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" + TypeLibraryName=".\Release/layout.tlb" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="..\..\..\include,..\..\..\include\layout,..\..\common" + PreprocessorDefinitions="NDEBUG;_CONSOLE;WIN32;UNICODE;_CRT_SECURE_NO_DEPRECATE;LE_USE_CMEMORY" + StringPooling="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Release/layout.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="..\..\..\lib\iculx.lib ..\..\..\lib\icule.lib ..\..\..\lib\icuuc.lib ..\..\..\lib\icuin.lib odbc32.lib odbccp32.lib" + OutputFile=".\Release/layout.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + ProgramDatabaseFile=".\Release/layout.pdb" + SubSystem="2" + /> + <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" + TypeLibraryName=".\Debug/layout.tlb" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\include,..\..\..\include\layout,..\..\common" + PreprocessorDefinitions="_DEBUG;WIN32;UNICODE;LE_USE_CMEMORY;_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Debug/layout.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="..\..\..\lib\iculxd.lib ..\..\..\lib\iculed.lib ..\..\..\lib\icuucd.lib ..\..\..\lib\icuind.lib odbc32.lib odbccp32.lib" + OutputFile=".\Debug/layout.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/layout.pdb" + SubSystem="2" + /> + <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=".\cmaps.cpp" + > + </File> + <File + RelativePath=".\FontMap.cpp" + > + </File> + <File + RelativePath=".\FontTableCache.cpp" + > + </File> + <File + RelativePath=".\GDIFontInstance.cpp" + > + </File> + <File + RelativePath=".\GDIFontMap.cpp" + > + </File> + <File + RelativePath=".\GDIGUISupport.cpp" + > + </File> + <File + RelativePath=".\layout.cpp" + > + </File> + <File + RelativePath=".\LayoutSample.rc" + > + </File> + <File + RelativePath=".\paragraph.cpp" + > + </File> + <File + RelativePath=".\ScriptCompositeFontInstance.cpp" + > + </File> + <File + RelativePath=".\UnicodeReader.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl" + > + <File + RelativePath=".\cmaps.h" + > + </File> + <File + RelativePath=".\FontMap.h" + > + </File> + <File + RelativePath=".\FontTableCache.h" + > + </File> + <File + RelativePath=".\GDIFontInstance.h" + > + </File> + <File + RelativePath=".\GDIFontMap.h" + > + </File> + <File + RelativePath=".\GDIGUISupport.h" + > + </File> + <File + RelativePath=".\GUISupport.h" + > + </File> + <File + RelativePath=".\paragraph.h" + > + </File> + <File + RelativePath=".\RenderingSurface.h" + > + </File> + <File + RelativePath=".\resource.h" + > + </File> + <File + RelativePath=".\ScriptCompositeFontInstance.h" + > + </File> + <File + RelativePath=".\sfnt.h" + > + </File> + <File + RelativePath=".\UnicodeReader.h" + > + </File> + </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/layout/paragraph.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/paragraph.cpp new file mode 100644 index 00000000000..65d3e368423 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/paragraph.cpp @@ -0,0 +1,278 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2007, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: Paragraph.cpp + * + * created on: 09/06/2000 + * created by: Eric R. Mader + */ + +#include "unicode/utypes.h" +#include "unicode/uchar.h" +#include "unicode/ubidi.h" +#include "unicode/ustring.h" + +#include "layout/ParagraphLayout.h" + +#include "RenderingSurface.h" + +#include "paragraph.h" +#include "UnicodeReader.h" + +#define MARGIN 10 +#define LINE_GROW 32 +#define PARA_GROW 8 + +#define CH_LF 0x000A +#define CH_CR 0x000D +#define CH_LSEP 0x2028 +#define CH_PSEP 0x2029 + +static LEUnicode *skipLineEnd(LEUnicode *ptr) +{ + if (ptr[0] == CH_CR && ptr[1] == CH_LF) { + ptr += 1; + } + + return ptr + 1; +} + +static le_int32 findRun(const RunArray *runArray, le_int32 offset) +{ + le_int32 runCount = runArray->getCount(); + + for (le_int32 run = 0; run < runCount; run += 1) { + if (runArray->getLimit(run) > offset) { + return run; + } + } + + return -1; +} + +static void subsetFontRuns(const FontRuns *fontRuns, le_int32 start, le_int32 limit, FontRuns *sub) +{ + le_int32 startRun = findRun(fontRuns, start); + le_int32 endRun = findRun(fontRuns, limit - 1); + + sub->reset(); + + for (le_int32 run = startRun; run <= endRun; run += 1) { + const LEFontInstance *runFont = fontRuns->getFont(run); + le_int32 runLimit = fontRuns->getLimit(run) - start; + + if (run == endRun) { + runLimit = limit - start; + } + + sub->add(runFont, runLimit); + } +} + +Paragraph::Paragraph(const LEUnicode chars[], int32_t charCount, const FontRuns *fontRuns, LEErrorCode &status) + : fParagraphLayout(NULL), fParagraphCount(0), fParagraphMax(PARA_GROW), fParagraphGrow(PARA_GROW), + fLineCount(0), fLinesMax(LINE_GROW), fLinesGrow(LINE_GROW), fLines(NULL), fChars(NULL), + fLineHeight(-1), fAscent(-1), fWidth(-1), fHeight(-1), fParagraphLevel(UBIDI_DEFAULT_LTR) +{ + static const LEUnicode separators[] = {CH_LF, CH_CR, CH_LSEP, CH_PSEP, 0x0000}; + + if (LE_FAILURE(status)) { + return; + } + + le_int32 ascent = 0; + le_int32 descent = 0; + le_int32 leading = 0; + + LocaleRuns *locales = NULL; + FontRuns fr(0); + + fLines = LE_NEW_ARRAY(const ParagraphLayout::Line *, fLinesMax); + fParagraphLayout = LE_NEW_ARRAY(ParagraphLayout *, fParagraphMax); + + fChars = LE_NEW_ARRAY(LEUnicode, charCount + 1); + LE_ARRAY_COPY(fChars, chars, charCount); + fChars[charCount] = 0; + + LEUnicode *pStart = &fChars[0]; + + while (*pStart != 0) { + LEUnicode *pEnd = u_strpbrk(pStart, separators); + le_int32 pAscent, pDescent, pLeading; + ParagraphLayout *paragraphLayout = NULL; + + if (pEnd == NULL) { + pEnd = &fChars[charCount]; + } + + if (pEnd != pStart) { + subsetFontRuns(fontRuns, pStart - fChars, pEnd - fChars, &fr); + + paragraphLayout = new ParagraphLayout(pStart, pEnd - pStart, &fr, NULL, NULL, locales, fParagraphLevel, FALSE, status); + + if (LE_FAILURE(status)) { + break; // return? something else? + } + + if (fParagraphLevel == UBIDI_DEFAULT_LTR) { + fParagraphLevel = paragraphLayout->getParagraphLevel(); + } + + pAscent = paragraphLayout->getAscent(); + pDescent = paragraphLayout->getDescent(); + pLeading = paragraphLayout->getLeading(); + + if (pAscent > ascent) { + ascent = pAscent; + } + + if (pDescent > descent) { + descent = pDescent; + } + + if (pLeading > leading) { + leading = pLeading; + } + } + + if (fParagraphCount >= fParagraphMax) { + fParagraphLayout = (ParagraphLayout **) LE_GROW_ARRAY(fParagraphLayout, fParagraphMax + fParagraphGrow); + fParagraphMax += fParagraphGrow; + } + + fParagraphLayout[fParagraphCount++] = paragraphLayout; + + if (*pEnd == 0) { + break; + } + + pStart = skipLineEnd(pEnd); + } + + fLineHeight = ascent + descent + leading; + fAscent = ascent; +} + +Paragraph::~Paragraph() +{ + for (le_int32 line = 0; line < fLineCount; line += 1) { + delete /*(LineInfo *)*/ fLines[line]; + } + + LE_DELETE_ARRAY(fLines); + delete fParagraphLayout; + LE_DELETE_ARRAY(fChars); +} + +void Paragraph::addLine(const ParagraphLayout::Line *line) +{ + if (fLineCount >= fLinesMax) { + fLines = (const ParagraphLayout::Line **) LE_GROW_ARRAY(fLines, fLinesMax + fLinesGrow); + fLinesMax += fLinesGrow; + } + + fLines[fLineCount++] = line; +} + +void Paragraph::breakLines(le_int32 width, le_int32 height) +{ + fHeight = height; + + // don't re-break if the width hasn't changed + if (fWidth == width) { + return; + } + + fWidth = width; + + float lineWidth = (float) (width - 2 * MARGIN); + const ParagraphLayout::Line *line; + + // Free the old LineInfo's... + for (le_int32 li = 0; li < fLineCount; li += 1) { + delete fLines[li]; + } + + fLineCount = 0; + + for (le_int32 p = 0; p < fParagraphCount; p += 1) { + ParagraphLayout *paragraphLayout = fParagraphLayout[p]; + + if (paragraphLayout != NULL) { + paragraphLayout->reflow(); + while ((line = paragraphLayout->nextLine(lineWidth)) != NULL) { + addLine(line); + } + } else { + addLine(NULL); + } + } +} + +void Paragraph::draw(RenderingSurface *surface, le_int32 firstLine, le_int32 lastLine) +{ + le_int32 li, x, y; + + x = MARGIN; + y = fAscent; + + for (li = firstLine; li <= lastLine; li += 1) { + const ParagraphLayout::Line *line = fLines[li]; + + if (line != NULL) { + le_int32 runCount = line->countRuns(); + le_int32 run; + + if (fParagraphLevel == UBIDI_RTL) { + le_int32 lastX = line->getWidth(); + + x = (fWidth - lastX - MARGIN); + } + + + for (run = 0; run < runCount; run += 1) { + const ParagraphLayout::VisualRun *visualRun = line->getVisualRun(run); + le_int32 glyphCount = visualRun->getGlyphCount(); + const LEFontInstance *font = visualRun->getFont(); + const LEGlyphID *glyphs = visualRun->getGlyphs(); + const float *positions = visualRun->getPositions(); + + surface->drawGlyphs(font, glyphs, glyphCount, positions, x, y, fWidth, fHeight); + } + } + + y += fLineHeight; + } +} + +Paragraph *Paragraph::paragraphFactory(const char *fileName, const LEFontInstance *font, GUISupport *guiSupport) +{ + LEErrorCode status = LE_NO_ERROR; + le_int32 charCount; + const UChar *text = UnicodeReader::readFile(fileName, guiSupport, charCount); + Paragraph *result = NULL; + + if (text == NULL) { + return NULL; + } + + FontRuns fontRuns(0); + + fontRuns.add(font, charCount); + + result = new Paragraph(text, charCount, &fontRuns, status); + + if (LE_FAILURE(status)) { + delete result; + result = NULL; + } + + LE_DELETE_ARRAY(text); + + return result; +} + diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/paragraph.h b/Build/source/libs/icu/icu-xetex/samples/layout/paragraph.h new file mode 100644 index 00000000000..c51c9f41ef2 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/paragraph.h @@ -0,0 +1,88 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2007, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: Paragraph.h + * + * created on: 09/06/2000 + * created by: Eric R. Mader + */ +#ifndef __PARAGRAPH_H +#define __PARAGRAPH_H + +#include "unicode/utypes.h" +#include "unicode/ubidi.h" + +#include "layout/LEFontInstance.h" +#include "layout/ParagraphLayout.h" + +#include "GUISupport.h" +#include "RenderingSurface.h" + +U_NAMESPACE_USE + +#define MARGIN 10 + +#if 0 +class LineInfo; +#endif + +class Paragraph +{ +public: + Paragraph(const LEUnicode chars[], le_int32 charCount, const FontRuns *fontRuns, LEErrorCode &status); + + ~Paragraph(); + + le_int32 getAscent(); + le_int32 getLineHeight(); + le_int32 getLineCount(); + void breakLines(le_int32 width, le_int32 height); + void draw(RenderingSurface *surface, le_int32 firstLine, le_int32 lastLine); + + static Paragraph *paragraphFactory(const char *fileName, const LEFontInstance *font, GUISupport *guiSupport); + +private: + void addLine(const ParagraphLayout::Line *line); + + ParagraphLayout **fParagraphLayout; + + le_int32 fParagraphCount; + le_int32 fParagraphMax; + le_int32 fParagraphGrow; + + le_int32 fLineCount; + le_int32 fLinesMax; + le_int32 fLinesGrow; + + const ParagraphLayout::Line **fLines; + LEUnicode *fChars; + + le_int32 fLineHeight; + le_int32 fAscent; + le_int32 fWidth; + le_int32 fHeight; + UBiDiLevel fParagraphLevel; +}; + +inline le_int32 Paragraph::getLineHeight() +{ + return fLineHeight; +} + +inline le_int32 Paragraph::getLineCount() +{ + return fLineCount; +} + +inline le_int32 Paragraph::getAscent() +{ + return fAscent; +} + +#endif + + diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/pflow.c b/Build/source/libs/icu/icu-xetex/samples/layout/pflow.c new file mode 100644 index 00000000000..80450ad20be --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/pflow.c @@ -0,0 +1,381 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#include "unicode/utypes.h" +#include "unicode/uchar.h" +#include "unicode/ubidi.h" +#include "unicode/ustring.h" + +#include "layout/LETypes.h" + +#include "layout/loengine.h" +#include "layout/playout.h" +#include "layout/plruns.h" + +#include "pflow.h" + +#include "arraymem.h" +#include "ucreader.h" + +/* + * Move the line below out of this comment + * to add a locale run to the pl_paragraphs + * that are created. +#define TEST_LOCALE "zh_TW" + */ + +#define MARGIN 10 +#define LINE_GROW 32 +#define PARA_GROW 8 + +#define CH_LF 0x000A +#define CH_CR 0x000D +#define CH_LSEP 0x2028 +#define CH_PSEP 0x2029 + +struct pf_object +{ + pl_paragraph **fParagraphLayout; + + le_int32 fParagraphCount; + le_int32 fParagraphMax; + le_int32 fParagraphGrow; + + le_int32 fLineCount; + le_int32 fLinesMax; + le_int32 fLinesGrow; + + pl_line **fLines; + + LEUnicode *fChars; + + le_int32 fLineHeight; + le_int32 fAscent; + le_int32 fWidth; + le_int32 fHeight; + UBiDiLevel fParagraphLevel; +}; + +typedef struct pf_object pf_object; + + +static LEUnicode *skipLineEnd(LEUnicode *ptr) +{ + if (ptr[0] == CH_CR && ptr[1] == CH_LF) { + ptr += 1; + } + + return ptr + 1; +} + +static le_int32 findFontRun(const pl_fontRuns *fontRuns, le_int32 offset) +{ + le_int32 runCount = pl_getFontRunCount(fontRuns); + le_int32 run; + + for (run = 0; run < runCount; run += 1) { + if (pl_getFontRunLimit(fontRuns, run) > offset) { + return run; + } + } + + return -1; +} + +static void subsetFontRuns(const pl_fontRuns *fontRuns, le_int32 start, le_int32 limit, pl_fontRuns *sub) +{ + le_int32 startRun = findFontRun(fontRuns, start); + le_int32 endRun = findFontRun(fontRuns, limit - 1); + le_int32 run; + + pl_resetFontRuns(sub); + + for (run = startRun; run <= endRun; run += 1) { + const le_font *runFont = pl_getFontRunFont(fontRuns, run); + le_int32 runLimit = pl_getFontRunLimit(fontRuns, run) - start; + + if (run == endRun) { + runLimit = limit - start; + } + + pl_addFontRun(sub, runFont, runLimit); + } +} + +pf_flow *pf_create(const LEUnicode chars[], le_int32 charCount, const pl_fontRuns *fontRuns, LEErrorCode *status) +{ + pf_object *flow; + le_int32 ascent = 0; + le_int32 descent = 0; + le_int32 leading = 0; + pl_localeRuns *locales = NULL; + pl_fontRuns *fr; + LEUnicode *pStart; + static const LEUnicode separators[] = {CH_LF, CH_CR, CH_LSEP, CH_PSEP, 0x0000}; + + if (LE_FAILURE(*status)) { + return NULL; + } + + flow = NEW_ARRAY(pf_object, 1); + + flow->fParagraphLayout = NULL; + flow->fParagraphCount = 0; + flow->fParagraphMax = PARA_GROW; + flow->fParagraphGrow = PARA_GROW; + flow->fLineCount = 0; + flow->fLinesMax = LINE_GROW; + flow->fLinesGrow = LINE_GROW; + flow->fLines = NULL; + flow->fChars = NULL; + flow->fLineHeight = -1; + flow->fAscent = -1; + flow->fWidth = -1; + flow->fHeight = -1; + flow->fParagraphLevel = UBIDI_DEFAULT_LTR; + + fr = pl_openEmptyFontRuns(0); + +#ifdef TEST_LOCALE + locales = pl_openEmptyLocaleRuns(0); +#endif + + flow->fLines = NEW_ARRAY(pl_line *, flow->fLinesMax); + flow->fParagraphLayout = NEW_ARRAY(pl_paragraph *, flow->fParagraphMax); + + flow->fChars = NEW_ARRAY(LEUnicode, charCount + 1); + LE_ARRAY_COPY(flow->fChars, chars, charCount); + flow->fChars[charCount] = 0; + + pStart = &flow->fChars[0]; + + while (*pStart != 0) { + LEUnicode *pEnd = u_strpbrk(pStart, separators); + le_int32 pAscent, pDescent, pLeading; + pl_paragraph *paragraphLayout = NULL; + + if (pEnd == NULL) { + pEnd = &flow->fChars[charCount]; + } + + if (pEnd != pStart) { + subsetFontRuns(fontRuns, pStart - flow->fChars, pEnd - flow->fChars, fr); + +#ifdef TEST_LOCALE + pl_resetLocaleRuns(locales); + pl_addLocaleRun(locales, TEST_LOCALE, pEnd - pStart); +#endif + + paragraphLayout = pl_create(pStart, pEnd - pStart, fr, NULL, NULL, locales, flow->fParagraphLevel, FALSE, status); + + if (LE_FAILURE(*status)) { + break; /* return? something else? */ + } + + if (flow->fParagraphLevel == UBIDI_DEFAULT_LTR) { + flow->fParagraphLevel = pl_getParagraphLevel(paragraphLayout); + } + + pAscent = pl_getAscent(paragraphLayout); + pDescent = pl_getDescent(paragraphLayout); + pLeading = pl_getLeading(paragraphLayout); + + if (pAscent > ascent) { + ascent = pAscent; + } + + if (pDescent > descent) { + descent = pDescent; + } + + if (pLeading > leading) { + leading = pLeading; + } + } + + if (flow->fParagraphCount >= flow->fParagraphMax) { + flow->fParagraphLayout = (pl_paragraph **) GROW_ARRAY(flow->fParagraphLayout, flow->fParagraphMax + flow->fParagraphGrow); + flow->fParagraphMax += flow->fParagraphGrow; + } + + flow->fParagraphLayout[flow->fParagraphCount++] = paragraphLayout; + + if (*pEnd == 0) { + break; + } + + pStart = skipLineEnd(pEnd); + } + + flow->fLineHeight = ascent + descent + leading; + flow->fAscent = ascent; + + pl_closeLocaleRuns(locales); + pl_closeFontRuns(fr); + + return (pf_flow *) flow; +} + +void pf_close(pf_flow *flow) +{ + pf_object *obj = (pf_object *) flow; + le_int32 i; + + for (i = 0; i < obj->fLineCount; i += 1) { + DELETE_ARRAY(obj->fLines[i]); + } + + DELETE_ARRAY(obj->fLines); + + for (i = 0; i < obj->fParagraphCount; i += 1) { + pl_close(obj->fParagraphLayout[i]); + } + + DELETE_ARRAY(obj->fParagraphLayout); + + DELETE_ARRAY(obj->fChars); + + DELETE_ARRAY(obj); +} + + +le_int32 pf_getAscent(pf_flow *flow) +{ + pf_object *obj = (pf_object *) flow; + + return obj->fAscent; +} + +le_int32 pf_getLineHeight(pf_flow *flow) +{ + pf_object *obj = (pf_object *) flow; + + return obj->fLineHeight; +} + +le_int32 pf_getLineCount(pf_flow *flow) +{ + pf_object *obj = (pf_object *) flow; + + return obj->fLineCount; +} + +static void addLine(pf_object *obj, pl_line *line) +{ + if (obj->fLineCount >= obj->fLinesMax) { + obj->fLines = (pl_line **) GROW_ARRAY(obj->fLines, obj->fLinesMax + obj->fLinesGrow); + obj->fLinesMax += obj->fLinesGrow; + } + + obj->fLines[obj->fLineCount++] = line; +} + +void pf_breakLines(pf_flow *flow, le_int32 width, le_int32 height) +{ + pf_object *obj = (pf_object *) flow; + le_int32 li, p; + float lineWidth; + pl_line *line; + + obj->fHeight = height; + + /* don't re-break if the width hasn't changed */ + if (obj->fWidth == width) { + return; + } + + obj->fWidth = width; + + lineWidth = (float) (width - 2 * MARGIN); + + /* Free the old Lines... */ + for (li = 0; li < obj->fLineCount; li += 1) { + pl_closeLine(obj->fLines[li]); + } + + obj->fLineCount = 0; + + for (p = 0; p < obj->fParagraphCount; p += 1) { + pl_paragraph *paragraphLayout = obj->fParagraphLayout[p]; + + if (paragraphLayout != NULL) { + pl_reflow(paragraphLayout); + while ((line = pl_nextLine(paragraphLayout, lineWidth)) != NULL) { + addLine(obj, line); + } + } else { + addLine(obj, NULL); + } + } +} + +void pf_draw(pf_flow *flow, rs_surface *surface, le_int32 firstLine, le_int32 lastLine) +{ + pf_object *obj = (pf_object *) flow; + le_int32 li, x, y; + + x = MARGIN; + y = obj->fAscent; + + for (li = firstLine; li <= lastLine; li += 1) { + const pl_line *line = obj->fLines[li]; + + if (line != NULL) { + le_int32 runCount = pl_countLineRuns(line); + le_int32 run; + + if (obj->fParagraphLevel == UBIDI_RTL) { + le_int32 lastX = pl_getLineWidth(line); + + x = (obj->fWidth - lastX - MARGIN); + } + + + for (run = 0; run < runCount; run += 1) { + const pl_visualRun *visualRun = pl_getLineVisualRun(line, run); + le_int32 glyphCount = pl_getVisualRunGlyphCount(visualRun); + const le_font *font = pl_getVisualRunFont(visualRun); + const LEGlyphID *glyphs = pl_getVisualRunGlyphs(visualRun); + const float *positions = pl_getVisualRunPositions(visualRun); + + rs_drawGlyphs(surface, font, glyphs, glyphCount, positions, x, y, obj->fWidth, obj->fHeight); + } + } + + y += obj->fLineHeight; + } +} + +pf_flow *pf_factory(const char *fileName, const le_font *font, gs_guiSupport *guiSupport) +{ + LEErrorCode status = LE_NO_ERROR; + le_int32 charCount; + const UChar *text = uc_readFile(fileName, guiSupport, &charCount); + pl_fontRuns *fontRuns; + pf_flow *result = NULL; + + if (text == NULL) { + return NULL; + } + + fontRuns = pl_openEmptyFontRuns(0); + + pl_addFontRun(fontRuns, font, charCount); + + result = pf_create(text, charCount, fontRuns, &status); + + if (LE_FAILURE(status)) { + pf_close(result); + result = NULL; + } + + pl_closeFontRuns(fontRuns); + + DELETE_ARRAY(text); + + return result; +} + diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/pflow.h b/Build/source/libs/icu/icu-xetex/samples/layout/pflow.h new file mode 100644 index 00000000000..7e0b7f313d8 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/pflow.h @@ -0,0 +1,33 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#ifndef __PFLOW_H +#define __PFLOW_H + +#include "unicode/utypes.h" +#include "layout/LETypes.h" + +#include "layout/plruns.h" +#include "layout/playout.h" + +#include "gsupport.h" +#include "rsurface.h" + +typedef void pf_flow; + +pf_flow *pf_create(const LEUnicode chars[], le_int32 charCount, const pl_fontRuns *fontRuns, LEErrorCode *status); + +void pf_close(pf_flow *flow); + +le_int32 pf_getAscent(pf_flow *flow); +le_int32 pf_getLineHeight(pf_flow *flow); +le_int32 pf_getLineCount(pf_flow *flow); +void pf_breakLines(pf_flow *flow, le_int32 width, le_int32 height); +void pf_draw(pf_flow *flow, rs_surface *surface, le_int32 firstLine, le_int32 lastLine); + +pf_flow *pf_factory(const char *fileName, const le_font *font, gs_guiSupport *guiSupport); + +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/readme.html b/Build/source/libs/icu/icu-xetex/samples/layout/readme.html new file mode 100644 index 00000000000..79a700519b9 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/readme.html @@ -0,0 +1,157 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" /> + <meta name="COPYRIGHT" content= + "Copyright (c) 2001-2006 IBM Corporation and others. All Rights Reserved." /> + <meta name="Author" content="Eric Mader" /> + + <title>Readme file for the ICU LayoutEngine demo</title> +</head> + +<body> + <h2>What is the layout demo?</h2> + + <p>The layout demo displays a paragraph of text that is laid out using the + LayoutEngine. There are two versions of this demo, "layout.exe" which runs on + Windows 2000, and "gnomelayout" which runs on Linux. Both programs read a + file containing the Unicode text to display, and a file that says which font + to use to display each script.</p> + + <h2>How do I build the layout demo?</h2>First, you need to build ICU, + including the LayoutEngine. + + <p>On Windows, the layout project should be listed as a dependency of all, so + layout will build when you build all. If it doesn't for some reason, just + select the layout project in the project toolbar and build it.</p> + + <p>On Linux systems, you need to add the "--enable-layout=yes" option when + you invoke the runConfigureICU script. When you've done that, layout should + build when you do "make all install"</p> + + <p>To build the demo on Windows, just open the layout project in + <icu>\source\samples\layout and build it.</p> + + <p>On Linux systems, connect to <top-build-dir>/samples/layout and do + "make all". To build the layout demo on Linux, you'll need the + gnome-libs-devel and freetype-devel packages, which should be part of your + Linux distribution. The demo uses the FreeType 1 library, and the make files + assume that the FreeType header files are in /usr/include/freetype1, and that + the freetype library is /usr/lib/libttf.so. This is how RedHat Linux 7.2 + installs FreeType 1. If your system is different, you may need to add sym + links to where the files are stored on your system, or modify + <top-src-dir>/samples/layout/Makefile.in to reference the files + correctly for your system.</p> + + <h2>How do I run the demo?</h2> + + <p>Before you can run the demo, you'll need to get the fonts it uses. For + legal reasons, we can't include these fonts with ICU, but you can download + them from the web. To do this, you'll need access to a computer running + Windows. Here's how to get the fonts:</p> + + <p>First, download the Thai font. Go to <a href= + "http://www.into-asia.com/thai_language/thaifont/">into-asia.com</a> and + click on the link for the Angsana font. This will download a .ZIP file. + Extract the font file, angsd___.ttf On Windows, copy this font file to your + Fonts folder, on Linux, copy this font file to the directory from which + you'll run the layout demo.</p> + + <p>Next is the Hindi font. Go to the NCST site and download <a href= + "http://rohini.ncst.ernet.in/indix/download/font/raghu.ttf">raghu.ttf</a>. Be + sure to look at the <a href= + "http://rohini.ncst.ernet.in/indix/download/font/README">README</a> file + before you download the font. On Linux, you can download raghu.ttf into the + directory from which you'll run the layout demo. On Windows, you'll need to + install it in your Fonts folder.</p> + + <p>There's still one more font to get, the Code2000 Unicode font. Go to James + Kass' <a href="http://www.code2000.net/">Unicode Support In Your + Browser</a> page and click on the link that says "Click Here to download + Code2000 shareware demo Unicode font." This will download a .ZIP file which + contains CODE2000.TTF and CODE2000.HTM. Expand this .ZIP file. If you're + going to run the layout demo on Linux, put the CODE2000.TTF file in the + directory from which you'll run the demo. On Windows, copy the font to your + fonts folder.</p> + + <p><strong>Note:</strong> The Code2000 font is shareware. If you want to use + it for longer than a trial period, you should send a shareware fee to James. + Directions for how to do this are in CODE2000.HTM.</p> + + <p>That's it! Now all you have to do is run letest (CTRL+F5 in Visual C++, or + "./gnomelayout" in Linux)</p> + + <h2>How can I customize the layout demo?</h2> + + <p>The text that the layout demo displays is read from the file "Sample.txt." + You can change the text by editing this file using a Unicode-aware text + editor. (it is in UTF8 format with a BOM as the first character; the demo can + also read UTF16 and UTF32 format files) Remember that the text will be + displayed in a single paragraph; you can include CR and LF characters in the + text, but they will be ignored.</p> + + <p>If you add scripts to the text other than Arabic, Devanagari, Latin or + Thai, you'll need to find a font which contains the characters in that + script, and add an entry to the FontMap file ("FontMap.GDI" on Windows, + "FontMap.Gnome" on Linux) This file contains a single entry per line. Each + entry contains a script name followed by a colon, and then a font name.</p> + + <p>Here is the list of legal script names:</p> + + <blockquote> + <tt>ARABIC</tt><br /> + <tt>ARMENIAN</tt><br /> + <tt>BENGALI</tt><br /> + <tt>BOPOMOFO</tt><br /> + <span style="font-family: monospace;">BUHID</span><br /> + <tt>CANADIAN_ABORIGINAL</tt><br /> + <tt>CHEROKEE</tt><br /> + <tt>CYRILLIC</tt><br /> + <tt>DESERET</tt><br /> + <tt>DEVANAGARI</tt><br /> + <tt>ETHIOPIC</tt><br /> + <tt>GEORGIAN</tt><br /> + <tt>GOTHIC</tt><br /> + <tt>GREEK</tt><br /> + <tt>GUJARATI</tt><br /> + <tt>GURMUKHI</tt><br /> + <tt>HAN</tt><br /> + <tt>HANGUL</tt><br /> + <span style="font-family: monospace;">HANUNOO</span><br /> + <tt>HEBREW</tt><br /> + <tt>HIRAGANA</tt><br /> + <tt>KANNADA</tt><br /> + <tt>KATAKANA</tt><br /> + <tt>KHMER</tt><br /> + <tt>LATIN</tt><br /> + <tt>MALAYALAM</tt><br /> + <tt>MONGOLIAN</tt><br /> + <tt>MYANMAR</tt><br /> + <tt>OGHAM</tt><br /> + <tt>OLD_ITALIC</tt><br /> + <tt>ORIYA</tt><br /> + <tt>RUNIC</tt><br /> + <tt>SINHALA</tt><br /> + <tt>SYRIAC</tt><br /> + <span style="font-family: monospace;">TAGALOG<br /> + TAGBANWA</span><br /> + <tt>TAMIL</tt><br /> + <tt>TELUGU</tt><br /> + <tt>THAANA</tt><br /> + <tt>THAI</tt><br /> + <tt>TIBETAN</tt><br /> + <tt>YI<br /></tt> + </blockquote> + + <p>You can also use the script name "DEFAULT" to represent all scripts which + you don't explicitly list in the FontMap file.</p> + + <p>On Windows use the full name of the font as it appears in the Windows + Fonts folder (eg. "Times New Roman") On Linux, use the file name of the font + file (e.g. "Times.TTF") If you're running on Windows, you'll need to install + the new fonts in your Fonts folder. If you're running on Linux, put them in + the directory from which you'll run the demo.</p><br /> +</body> +</html> diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/resource.h b/Build/source/libs/icu/icu-xetex/samples/layout/resource.h new file mode 100644 index 00000000000..f582d8ebbac --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/resource.h @@ -0,0 +1,22 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Copyright (c) 2001-2003 International Business Machines +// Corporation and others. All Rights Reserved. +// Used by LayoutSample.rc +// +#define IDM_FILE_NEWSAMPLE 40001 +#define IDM_FILE_OPEN 40002 +#define IDM_FILE_CLOSE 40003 +#define IDM_FILE_EXIT 40004 +#define IDM_HELP_ABOUTLAYOUTSAMPLE 40005 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 104 +#define _APS_NEXT_COMMAND_VALUE 40006 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/rsurface.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/rsurface.cpp new file mode 100644 index 00000000000..f383aa7dd56 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/rsurface.cpp @@ -0,0 +1,24 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#include "loengine.h" +#include "rsurface.h" + +#include "LETypes.h" +#include "LEFontInstance.h" +#include "RenderingSurface.h" + +U_CDECL_BEGIN + +void rs_drawGlyphs(rs_surface *surface, const le_font *font, const LEGlyphID *glyphs, le_int32 count, + const float *positions, le_int32 x, le_int32 y, le_int32 width, le_int32 height) +{ + RenderingSurface *rs = (RenderingSurface *) surface; + + rs->drawGlyphs((const LEFontInstance *) font, glyphs, count, positions, x, y, width, height); +} + +U_CDECL_END diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/rsurface.h b/Build/source/libs/icu/icu-xetex/samples/layout/rsurface.h new file mode 100644 index 00000000000..c58194e5f94 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/rsurface.h @@ -0,0 +1,21 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#ifndef __RSURFACE_H +#define __RSURFACE_H + +#include "loengine.h" + +typedef void rs_surface; + +U_CDECL_BEGIN + +void rs_drawGlyphs(rs_surface *surface, const le_font *font, const LEGlyphID *glyphs, le_int32 count, + const float *positions, le_int32 x, le_int32 y, le_int32 width, le_int32 height); + +U_CDECL_END + +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/sfnt.h b/Build/source/libs/icu/icu-xetex/samples/layout/sfnt.h new file mode 100644 index 00000000000..3b3d991adcc --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/sfnt.h @@ -0,0 +1,219 @@ +/* + ****************************************************************************** * + * + * Copyright (C) 1999-2001, International Business Machines + * Corporation and others. All Rights Reserved. + * + ****************************************************************************** * + * file name: sfnt.h + * + * created on: ??/??/2001 + * created by: Eric R. Mader + */ + +#ifndef __SFNT_H +#define __SFNT_H + +#include "LETypes.h" + + +#ifndef ANY_NUMBER +#define ANY_NUMBER 1 +#endif + +struct DirectoryEntry +{ + le_uint32 tag; + le_uint32 checksum; + le_uint32 offset; + le_uint32 length; +}; + +struct SFNTDirectory +{ + le_uint32 scalerType; + le_uint16 numTables; + le_uint16 searchRange; + le_uint16 entrySelector; + le_uint16 rangeShift; + DirectoryEntry tableDirectory[ANY_NUMBER]; +}; + + +struct CMAPEncodingSubtableHeader +{ + le_uint16 platformID; + le_uint16 platformSpecificID; + le_uint32 encodingOffset; +}; + +struct CMAPTable +{ + le_uint16 version; + le_uint16 numberSubtables; + CMAPEncodingSubtableHeader encodingSubtableHeaders[ANY_NUMBER]; +}; + +struct CMAPEncodingSubtable +{ + le_uint16 format; + le_uint16 length; + le_uint16 language; +}; + +struct CMAPFormat0Encoding : CMAPEncodingSubtable +{ + le_uint8 glyphIndexArray[256]; +}; + +struct CMAPFormat2Subheader +{ + le_uint16 firstCode; + le_uint16 entryCount; + le_int16 idDelta; + le_uint16 idRangeOffset; +}; + +struct CMAPFormat2Encoding : CMAPEncodingSubtable +{ + le_uint16 subHeadKeys[256]; + CMAPFormat2Subheader subheaders[ANY_NUMBER]; +}; + +struct CMAPFormat4Encoding : CMAPEncodingSubtable +{ + le_uint16 segCountX2; + le_uint16 searchRange; + le_uint16 entrySelector; + le_uint16 rangeShift; + le_uint16 endCodes[ANY_NUMBER]; +// le_uint16 reservedPad; +// le_uint16 startCodes[ANY_NUMBER]; +// le_uint16 idDelta[ANY_NUMBER]; +// le_uint16 idRangeOffset[ANY_NUMBER]; +// le_uint16 glyphIndexArray[ANY_NUMBER]; +}; + +struct CMAPFormat6Encoding : CMAPEncodingSubtable +{ + le_uint16 firstCode; + le_uint16 entryCount; + le_uint16 glyphIndexArray[ANY_NUMBER]; +}; + +struct CMAPEncodingSubtable32 +{ + le_uint32 format; + le_uint32 length; + le_uint32 language; +}; + +struct CMAPGroup +{ + le_uint32 startCharCode; + le_uint32 endCharCode; + le_uint32 startGlyphCode; +}; + +struct CMAPFormat8Encoding : CMAPEncodingSubtable32 +{ + le_uint32 is32[65536/32]; + le_uint32 nGroups; + CMAPGroup groups[ANY_NUMBER]; +}; + +struct CMAPFormat10Encoding : CMAPEncodingSubtable32 +{ + le_uint32 startCharCode; + le_uint32 numCharCodes; + le_uint16 glyphs[ANY_NUMBER]; +}; + +struct CMAPFormat12Encoding : CMAPEncodingSubtable32 +{ + le_uint32 nGroups; + CMAPGroup groups[ANY_NUMBER]; +}; + +typedef le_int32 fixed; + +struct BigDate +{ + le_uint32 bc; + le_uint32 ad; +}; + +struct HEADTable +{ + fixed version; + fixed fontRevision; + le_uint32 checksumAdjustment; + le_uint32 magicNumber; + le_uint16 flags; + le_uint16 unitsPerEm; + BigDate created; + BigDate modified; + le_int16 xMin; + le_int16 yMin; + le_int16 xMax; + le_int16 yMax; + le_int16 lowestRecPPEM; + le_int16 fontDirectionHint; + le_int16 indexToLocFormat; + le_int16 glyphDataFormat; +}; + +struct MAXPTable +{ + fixed version; + le_uint16 numGlyphs; + le_uint16 maxPoints; + le_uint16 maxContours; + le_uint16 maxComponentPoints; + le_uint16 maxComponentContours; + le_uint16 maxZones; + le_uint16 maxTwilightPoints; + le_uint16 maxStorage; + le_uint16 maxFunctionDefs; + le_uint16 maxInstructionDefs; + le_uint16 maxStackElements; + le_uint16 maxSizeOfInstructions; + le_uint16 maxComponentElements; + le_uint16 maxComponentDepth; +}; + +struct HHEATable +{ + fixed version; + le_int16 ascent; + le_int16 descent; + le_int16 lineGap; + le_uint16 advanceWidthMax; + le_int16 minLeftSideBearing; + le_int16 minRightSideBearing; + le_int16 xMaxExtent; + le_int16 caretSlopeRise; + le_int16 caretSlopeRun; + le_int16 caretOffset; + le_int16 reserved1; + le_int16 reserved2; + le_int16 reserved3; + le_int16 reserved4; + le_int16 metricDataFormat; + le_uint16 numOfLongHorMetrics; +}; + +struct LongHorMetric +{ + le_uint16 advanceWidth; + le_int16 leftSideBearing; +}; + +struct HMTXTable +{ + LongHorMetric hMetrics[ANY_NUMBER]; // ANY_NUMBER = numOfLongHorMetrics from hhea table +// le_int16 leftSideBearing[ANY_NUMBER]; // ANY_NUMBER = numGlyphs - numOfLongHorMetrics +}; + +#endif + diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/ucreader.cpp b/Build/source/libs/icu/icu-xetex/samples/layout/ucreader.cpp new file mode 100644 index 00000000000..bc928417aef --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/ucreader.cpp @@ -0,0 +1,20 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#include "unicode/utypes.h" + +#include "ucreader.h" +#include "gsupport.h" +#include "UnicodeReader.h" + +U_CDECL_BEGIN + +const UChar *uc_readFile(const char *fileName, gs_guiSupport *guiSupport, int32_t *charCount) +{ + return UnicodeReader::readFile(fileName, (GUISupport *) guiSupport, *charCount); +} + +U_CDECL_END diff --git a/Build/source/libs/icu/icu-xetex/samples/layout/ucreader.h b/Build/source/libs/icu/icu-xetex/samples/layout/ucreader.h new file mode 100644 index 00000000000..948db14deed --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/layout/ucreader.h @@ -0,0 +1,19 @@ +/* + * + * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved + * + */ + +#ifndef __UCREADER_H +#define __UCREADER_H + +#include "unicode/utypes.h" +#include "gsupport.h" + +U_CDECL_BEGIN + +const UChar *uc_readFile(const char *fileName, gs_guiSupport *guiSupport, int32_t *charCount); + +U_CDECL_END + +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/legacy/Makefile b/Build/source/libs/icu/icu-xetex/samples/legacy/Makefile new file mode 100644 index 00000000000..f47c300ca94 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/legacy/Makefile @@ -0,0 +1,85 @@ +# Copyright (c) 2001-2004 IBM, Inc. and others +# conversion sample code + + +# Usage: +# - configure and build ICU [see the docs] .. use "--prefix=" something +# (I used --prefix=/home/srl/III ) +# +# - do 'make install' of icu +# +# - 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 + +LEGACY_INCLUDE = $(ICU_LEGACY)/include + +ICU_INC=$(ICU_PREFIX)/lib/icu/Makefile.inc +ICUPATH= + +-include $(ICU_INC) + +# Name of your target +TARGET=legacy + +# All object files (C or C++) +OBJECTS=legacy.o newcol.o oldcol.o + +CLEANFILES=*~ $(TARGET).out + +DEPS=$(OBJECTS:.o=.d) + +# turn on super warnings +#CPPFLAGS += -Wall + +all: $(TARGET) $(ICU_INC) + +.PHONY: all clean distclean check report + +oldcol.o : oldcol.cpp $(LEGACY_INCLUDE)/unicode/ucol.h + $(CXX) -I$(LEGACY_INCLUDE) $(DEFS) $(CPPFLAGS) $(CXXFLAGS) -c oldcol.cpp + +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) $(ICU_PREFIX)/lib/libicuuc.so.18 $(ICU_PREFIX)/lib/libicui18n.so.18 + +# 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 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 diff --git a/Build/source/libs/icu/icu-xetex/samples/legacy/README b/Build/source/libs/icu/icu-xetex/samples/legacy/README new file mode 100644 index 00000000000..3dcf5563382 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/legacy/README @@ -0,0 +1,41 @@ +Copyright (c) 2002, International Business Machines Corporation and others. All Rights Reserved. +This example demonstrates running an instance of ICU 1.8.1. together with a current version of ICU. It only tests u_getVersion and several collation APIs. + +Generally, one should be able to simultaneously use one or more versions of ICU 2.0 or higher and one version of ICU 1.8.1 or lower. + +What is it all about: Let's say you have a 10 Tb database indexed using ICU 1.8.1. sortkeys. New ICU comes out, with neat new features you would like to use, but also with new sortkeys and you don't care to reindex your 10 Tb database. What to do then??? You can use ICU 1.8.1. in one of your compilation units and current version in all the others. So, you can use old collation until you decide to reindex. + +You cannot mix two versions of ICU in the same compilation unit. You cannot automatically use more than one legacy version of ICU. + +In order to make the compilation unit use old version of ICU, you have to do a couple of things: +1) change it's include path so that it includes header files from the old versions +2) explicitly add old libraries to the linker. +3) make sure old data can be found (if legacy code needs data). + +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)/). 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. + +Run make check. You should get two different libraries running at the same time. + +Win32: +Build both current ICU and ICU 1.8.1. Take icuuc18.dll, icuin18.dll and icudt18l.dll and put them somewhere in PATH (a sane place would be wherever current dlls go). + +Edit the include directory for oldcol.cpp so that it points to the include directory of ICU 1.8.1. +Edit the two library entries with path so that they point to .lib files for your version of ICU. + +Hit F7, followed by ctrl-F5. + +Troubleshooting (all platforms): +Sample won't compile: this is quite unlikely, but the most probable reason is that include files cannot be found. +Sample won't link: The path for 1.8.1. libraries is broken. Edit it so that it reflects the path to your libraries. +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. + diff --git a/Build/source/libs/icu/icu-xetex/samples/legacy/legacy.cpp b/Build/source/libs/icu/icu-xetex/samples/legacy/legacy.cpp new file mode 100644 index 00000000000..85fc0e660b4 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/legacy/legacy.cpp @@ -0,0 +1,110 @@ +/* +******************************************************************************* +* +* Copyright (C) 2001 - 2005, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +* file name: main.cpp +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:4 +* +* created on: 2001jul24 +* created by: Vladimir Weinstein +*/ + +/****************************************************************************** + * main program demonstrating using two versions of ICU in the same project + ******************************************************************************/ + +#include <stdio.h> +#include "unicode/utypes.h" +#include "unicode/ustring.h" + +extern "C" void test_current(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) { + while(*str != 0) { + if(*str > 0x1F && *str < 0x80) { + fprintf(stdout, "%c", (*str) & 0xFF); + } else { + fprintf(stdout, "\\u%04X", *str); + } + str++; + } +} + +void printArray(const char* const comment, const UChar UArray[][5], int32_t arraySize) { + fprintf (stdout, "%s\n", comment); + int32_t i = 0; + for(i = 0; i<arraySize; i++) { + fprintf(stdout, "%d ", i); + printZTUChar(UArray[i]); + fprintf(stdout, "\n"); + } +} + +void printKeys(const char *comment, uint8_t keys[][32], int32_t keySize) { + int32_t i = 0; + uint8_t *currentKey = NULL; + fprintf(stdout, "%s\n", comment); + for(i = 0; i<keySize; i++) { + currentKey = keys[i]; + while(*currentKey != 0) { + if(*currentKey == 1) { + fprintf(stdout, "01 "); + } else { + fprintf(stdout, "%02X", *currentKey); + } + currentKey++; + } + fprintf(stdout, " 00\n"); + } +} + + +//int main(int argc, const char * const argv[]) { +int main(int, const char * const *) { + static const char* test[4] = { + "\\u304D\\u3085\\u3046\\u0000", + "\\u30AD\\u30E6\\u30A6\\u0000", + "\\u304D\\u3086\\u3046\\u0000", + "\\u30AD\\u30E5\\u30A6\\u0000" + }; + +#if 0 + static const char* test2[4] = { + "dbc\\u0000", + "cbc\\u0000", + "bbc\\u0000", + "abc\\u0000" + }; +#endif + + static UChar uTest[4][5]; + + static uint8_t keys[4][32]; + + uint32_t i = 0; + + for(i = 0; i<4; i++) { + u_unescape(test[i], uTest[i], 5); + } + printArray("Before current", uTest, 4); + test_current(uTest, 4, 5, keys); + printArray("After current", uTest, 4); + printKeys("Current keys", keys, 4); + + for(i = 0; i<4; i++) { + u_unescape(test[i], uTest[i], 5); + } + printArray("Before legacy", uTest, 4); + test_legacy(uTest, 4, 5, keys); + printArray("After legacy", uTest, 4); + printKeys("Legacy keys", keys, 4); + + + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/legacy/legacy.sln b/Build/source/libs/icu/icu-xetex/samples/legacy/legacy.sln new file mode 100644 index 00000000000..1c65feb9a8a --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/legacy/legacy.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "legacy", "legacy.vcproj", "{57F56795-1802-4605-88A0-013AAE9998F6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {57F56795-1802-4605-88A0-013AAE9998F6}.Debug|Win32.ActiveCfg = Debug|Win32 + {57F56795-1802-4605-88A0-013AAE9998F6}.Debug|Win32.Build.0 = Debug|Win32 + {57F56795-1802-4605-88A0-013AAE9998F6}.Release|Win32.ActiveCfg = Release|Win32 + {57F56795-1802-4605-88A0-013AAE9998F6}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/legacy/legacy.vcproj b/Build/source/libs/icu/icu-xetex/samples/legacy/legacy.vcproj new file mode 100644 index 00000000000..8004935f6f9 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/legacy/legacy.vcproj @@ -0,0 +1,247 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="legacy" + ProjectGUID="{57F56795-1802-4605-88A0-013AAE9998F6}" + > + <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" + TypeLibraryName=".\Release/legacy.tlb" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="../../../include" + PreprocessorDefinitions="WIN32,NDEBUG,_CONSOLE" + StringPooling="true" + RuntimeLibrary="0" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Release/legacy.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 ../../../../icu-1-8-1/lib/icuuc.lib ../../../../icu-1-8-1/lib/icuin.lib" + OutputFile=".\Release/legacy.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib" + ProgramDatabaseFile=".\Release/legacy.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" + TypeLibraryName=".\Debug/legacy.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/legacy.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 ../../../../icu-1-8-1/lib/icuucd.lib ../../../../icu-1-8-1/lib/icuind.lib" + OutputFile=".\Debug/legacy.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/legacy.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=".\legacy.cpp" + > + </File> + <File + RelativePath=".\newcol.cpp" + > + </File> + <File + RelativePath=".\oldcol.cpp" + > + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="../../../include;../../../../icu-1-8-1/include;$(NoInherit)" + /> + </FileConfiguration> + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="../../../include;../../../../icu-1-8-1/include;$(NoInherit)" + /> + </FileConfiguration> + </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/legacy/newcol.cpp b/Build/source/libs/icu/icu-xetex/samples/legacy/newcol.cpp new file mode 100644 index 00000000000..195a8acdb48 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/legacy/newcol.cpp @@ -0,0 +1,90 @@ +/* +******************************************************************************* +* +* Copyright (C) 2001 - 2005, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +* file name: newcol.cpp +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:4 +* +* created on: 2001jul24 +* created by: Vladimir Weinstein +*/ + +/****************************************************************************** + * This is the module that uses new collation + ******************************************************************************/ + +#include <stdio.h> +#include <stdlib.h> +#include "unicode/ucol.h" + +// Very simple example code - sticks a sortkey in the buffer +// Not much error checking +int32_t getSortKey_current(const char *locale, const UChar *string, int32_t sLen, uint8_t *buffer, int32_t bLen) { + UErrorCode status = U_ZERO_ERROR; + UCollator *coll = ucol_open(locale, &status); + if(U_FAILURE(status)) { + return -1; + } + int32_t result = ucol_getSortKey(coll, string, sLen, buffer, bLen); + ucol_close(coll); + return result; +} + +// This one can be used for passing to qsort function +// Not thread safe or anything +static UCollator *compareCollator = NULL; + +int compare_current(const void *string1, const void *string2) { + if(compareCollator != NULL) { + UCollationResult res = ucol_strcoll(compareCollator, (UChar *) string1, -1, (UChar *) string2, -1); + if(res == UCOL_LESS) { + return -1; + } else if(res == UCOL_GREATER) { + return 1; + } else { + return 0; + } + } else { + return 0; + } +} + +void initCollator_current(const char *locale) { + UErrorCode status = U_ZERO_ERROR; + compareCollator = ucol_open(locale, &status); +} + +void closeCollator_current(void) { + ucol_close(compareCollator); + compareCollator = NULL; +} + + +extern "C" void test_current(UChar data[][5], uint32_t size, uint32_t maxlen, uint8_t keys[][32]) { + uint32_t i = 0; + int32_t keySize = 0; + UVersionInfo uvi; + + u_getVersion(uvi); + fprintf(stderr, "Entered current, version: [%d.%d.%d.%d]\nMoving to sortkeys\n", uvi[0], uvi[1], uvi[2], uvi[3]); + + for(i = 0; i<size; i++) { + keySize = getSortKey_current("ja", data[i], -1, keys[i], 32); + fprintf(stderr, "For i=%d, size of sortkey is %d\n", i, keySize); + } + + fprintf(stderr, "Done sortkeys, doing qsort test\n"); + + initCollator_current("ja"); + qsort(data, size, maxlen*sizeof(UChar), compare_current); + closeCollator_current(); + + fprintf(stderr, "Done current!\n"); +} + + diff --git a/Build/source/libs/icu/icu-xetex/samples/legacy/oldcol.cpp b/Build/source/libs/icu/icu-xetex/samples/legacy/oldcol.cpp new file mode 100644 index 00000000000..c56ff2fcf6a --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/legacy/oldcol.cpp @@ -0,0 +1,107 @@ +/* + ******************************************************************************* + * + * Copyright (C) 2001-2005, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: oldcol.cpp + * encoding: US-ASCII + * tab size: 8 (not used) + * indentation:4 + * + * created on: 2001jul24 + * created by: Vladimir Weinstein + */ + +/****************************************************************************** + * This is the module that uses old collation + ******************************************************************************/ + +#include <stdio.h> +#include <stdlib.h> +#include <unicode/putil.h> +#include <unicode/ucol.h> + +// Very simple example code - sticks a sortkey in the buffer +// Not much error checking +int32_t getSortKey_legacy(const char *locale, const UChar *string, int32_t sLen, uint8_t *buffer, int32_t bLen) { + UErrorCode status = U_ZERO_ERROR; + UCollator *coll = ucol_open(locale, &status); + if(U_FAILURE(status)) { + return -1; + } + int32_t result = ucol_getSortKey(coll, string, sLen, buffer, bLen); + ucol_close(coll); + return result; +} + +// This one can be used for passing to qsort function +// Not thread safe or anything +static UCollator *compareCollator = NULL; + +int compare_legacy(const void *string1, const void *string2) { + if(compareCollator != NULL) { + UCollationResult res = ucol_strcoll(compareCollator, (UChar *) string1, -1, (UChar *) string2, -1); + if(res == UCOL_LESS) { + return -1; + } else if(res == UCOL_GREATER) { + return 1; + } else { + return 0; + } + } else { + return 0; + } +} + +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) { + if(compareCollator != NULL) + { + ucol_close(compareCollator); + } + else + { + fprintf(stderr, "closeCollator_legacy(): collator was already NULL!\n"); + } + compareCollator = NULL; +} + + +extern "C" void test_legacy(UChar data[][5], uint32_t size, uint32_t maxlen, uint8_t keys[4][32]) { + uint32_t i = 0; + int32_t keySize = 0; + + UVersionInfo uvi; + + u_getVersion(uvi); + fprintf(stderr, "Entered legacy, version: [%d.%d.%d.%d]\nMoving to sortkeys\n", uvi[0], uvi[1], uvi[2], uvi[3]); + + for(i = 0; i<size; i++) { + keySize = getSortKey_legacy("ja", data[i], -1, keys[i], 32); + fprintf(stderr, "For i=%d, size of sortkey is %d\n", i, keySize); + } + + fprintf(stderr, "Done sortkeys, doing qsort test\n"); + + initCollator_legacy("ja"); + qsort(data, size, maxlen*sizeof(UChar), compare_legacy); + closeCollator_legacy(); + + fprintf(stderr, "Done legacy!\n"); +} + + diff --git a/Build/source/libs/icu/icu-xetex/samples/msgfmt/Makefile b/Build/source/libs/icu/icu-xetex/samples/msgfmt/Makefile new file mode 100644 index 00000000000..010618b661a --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/msgfmt/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=msgfmt + +# All object files (C or C++) +OBJECTS=main.o util.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/msgfmt/README.TXT b/Build/source/libs/icu/icu-xetex/samples/msgfmt/README.TXT new file mode 100644 index 00000000000..c1c23c0db80 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/msgfmt/README.TXT @@ -0,0 +1,88 @@ +Copyright (c) 2002-2007, International Business Machines Corporation and others. All Rights Reserved. +This is an exercise for the ICU Workshop (September 2000). + + http://www.icu-project.org/docs/workshop_2000/agenda.html + + Day 2: September 12th 2000 + 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 + http://www.icu-project.org/userguide/. + + #Date/Time/Number Formatting Support + 9:30am - 10:30am + Alan Liu + + Topics: + 1. What is the date/time support in ICU? + 2. What is the timezone support in ICU? + 3. What kind of formatting and parsing support is available in ICU, i.e. + NumberFormat, DateFormat, MessageFormat? + + +INSTRUCTIONS +------------ + + +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. + + MSVC: + Open the file "msgfmt.sln" 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 +-------- + +Problem 0: + + Set up the program, build it, and run it. To start with, the + program prints out the word "Message". + +Problem 1: Basic Message Formatting (Easy) + + Use a MessageFormat to create a message that prints out "Received + <n> argument(s) on <d>.", where n is the number of command line + arguments (use argc-1), and d is the date (use Calendar::getNow()). + + HINT: Your message pattern should have a "number" element and a + "date" element, and you will need to use Formattable. + +Problem 2: ChoiceFormat (Medium) + + We can do better than "argument(s)". Instead, we can display more + idiomatic strings, such as "no arguments", "one argument", "two + arguments", and for higher values, we can use a number format. + + This kind of value-based switching is done using a ChoiceFormat. + However, you seldom needs to create a ChoiceFormat by itself. + Instead, most of the time you will supply the ChoiceFormat pattern + within a MessageFormat pattern. + + Use a ChoiceFormat pattern within the MessageFormat pattern, instead + of the "number" element, to display more idiomatic strings. + + EXTRA: Embed a number element within the choice element to handle + values greater than two. + + +ANSWERS +------- + +The exercise includes answers. These are in the "answers" directory, +and are numbered 1, 2, etc. + +If you get stuck and you want to move to the next step, copy the +answers file into the main directory in order to proceed. E.g., +"main_1.cpp" contains the original "main.cpp" file. "main_2.cpp" +contains the "main.cpp" file after problem 1. Etc. + + +Have fun! diff --git a/Build/source/libs/icu/icu-xetex/samples/msgfmt/answers/main_0.cpp b/Build/source/libs/icu/icu-xetex/samples/msgfmt/answers/main_0.cpp new file mode 100644 index 00000000000..112bd5a05e6 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/msgfmt/answers/main_0.cpp @@ -0,0 +1,26 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2003, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include "unicode/msgfmt.h" +#include "unicode/uclean.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" + +int main(int argc, char **argv) { + + UErrorCode status = U_ZERO_ERROR; + UnicodeString str; + + printf("Message: "); + uprintf(str); + printf("\n"); + + u_cleanup(); + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/msgfmt/answers/main_1.cpp b/Build/source/libs/icu/icu-xetex/samples/msgfmt/answers/main_1.cpp new file mode 100644 index 00000000000..d075d54c7bd --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/msgfmt/answers/main_1.cpp @@ -0,0 +1,24 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include "unicode/msgfmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" + +int main(int argc, char **argv) { + + UErrorCode status = U_ZERO_ERROR; + UnicodeString str; + + printf("Message: "); + uprintf(str); + printf("\n"); + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/msgfmt/answers/main_2.cpp b/Build/source/libs/icu/icu-xetex/samples/msgfmt/answers/main_2.cpp new file mode 100644 index 00000000000..de027787ac4 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/msgfmt/answers/main_2.cpp @@ -0,0 +1,46 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include "unicode/msgfmt.h" +#include "unicode/calendar.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" + +// The message format pattern. It takes a single argument, an integer, +// and formats it as "no", "one", or a number, using a NumberFormat. +static UnicodeString PATTERN( + "Received {0,choice,0#no|1#one|1& {0,number,integer}} arguments" + " on {1,date,long}." +); + +int main(int argc, char **argv) { + + UErrorCode status = U_ZERO_ERROR; + UnicodeString str; + FieldPosition pos; + + // Create a message format + MessageFormat msg(PATTERN, status); + check(status, "MessageFormat::ct"); + + // Create the argument list + Formattable msgArgs[2]; + msgArgs[0].setLong(argc-1); + msgArgs[1].setDate(Calendar::getNow()); + + // Format the arguments + msg.format(msgArgs, 2, str, pos, status); + check(status, "MessageFormat::format"); + + printf("Message: "); + uprintf(str); + printf("\n"); + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/msgfmt/answers/main_3.cpp b/Build/source/libs/icu/icu-xetex/samples/msgfmt/answers/main_3.cpp new file mode 100644 index 00000000000..202ad2706bc --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/msgfmt/answers/main_3.cpp @@ -0,0 +1,46 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include "unicode/msgfmt.h" +#include "unicode/calendar.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" + +// The message format pattern. It takes a single argument, an integer, +// and formats it as "no", "one", or a number, using a NumberFormat. +static UnicodeString PATTERN( + "Received {0,choice,0#no arguments|1#one argument|2#{0,number,integer} arguments}" + " on {1,date,long}." +); + +int main(int argc, char **argv) { + + UErrorCode status = U_ZERO_ERROR; + UnicodeString str; + FieldPosition pos; + + // Create a message format + MessageFormat msg(PATTERN, status); + check(status, "MessageFormat::ct"); + + // Create the argument list + Formattable msgArgs[2]; + msgArgs[0].setLong(argc-1); + msgArgs[1].setDate(Calendar::getNow()); + + // Format the arguments + msg.format(msgArgs, 2, str, pos, status); + check(status, "MessageFormat::format"); + + printf("Message: "); + uprintf(str); + printf("\n"); + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/msgfmt/main.cpp b/Build/source/libs/icu/icu-xetex/samples/msgfmt/main.cpp new file mode 100644 index 00000000000..e92db51789b --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/msgfmt/main.cpp @@ -0,0 +1,46 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2003, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include "unicode/msgfmt.h" +#include "unicode/calendar.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" + +// The message format pattern. It takes a single argument, an integer, +// and formats it as "no", "one", or a number, using a NumberFormat. +static UnicodeString PATTERN( + "Received {0,choice,0#no arguments|1#one argument|2#{0,number,integer} arguments}" + " on {1,date,long}." +); + +int main(int argc, char **argv) { + + UErrorCode status = U_ZERO_ERROR; + UnicodeString str; + FieldPosition pos; + + // Create a message format + MessageFormat msg(PATTERN, status); + check(status, "MessageFormat::ct"); + + // Create the argument list + Formattable msgArgs[2]; + msgArgs[0].setLong(argc-1); + msgArgs[1].setDate(Calendar::getNow()); + + // Format the arguments + msg.format(msgArgs, 2, str, pos, status); + check(status, "MessageFormat::format"); + + printf("Message: "); + uprintf(str); + printf("\n"); + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/msgfmt/msgfmt.sln b/Build/source/libs/icu/icu-xetex/samples/msgfmt/msgfmt.sln new file mode 100644 index 00000000000..9c22b2e14f9 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/msgfmt/msgfmt.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msgfmt", "msgfmt.vcproj", "{5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}.Debug|Win32.ActiveCfg = Debug|Win32 + {5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}.Debug|Win32.Build.0 = Debug|Win32 + {5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}.Release|Win32.ActiveCfg = Release|Win32 + {5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/msgfmt/msgfmt.vcproj b/Build/source/libs/icu/icu-xetex/samples/msgfmt/msgfmt.vcproj new file mode 100644 index 00000000000..5f40d509eb3 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/msgfmt/msgfmt.vcproj @@ -0,0 +1,227 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="msgfmt" + ProjectGUID="{5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}" + > + <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" + TypeLibraryName=".\Release/msgfmt.tlb" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE" + StringPooling="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Release/msgfmt.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/msgfmt.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + ProgramDatabaseFile=".\Release/msgfmt.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" + TypeLibraryName=".\Debug/msgfmt.tlb" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Debug/msgfmt.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 odbc32.lib odbccp32.lib" + OutputFile=".\Debug/msgfmt.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/msgfmt.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=".\main.cpp" + > + </File> + <File + RelativePath=".\util.cpp" + > + </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/msgfmt/util.cpp b/Build/source/libs/icu/icu-xetex/samples/msgfmt/util.cpp new file mode 100644 index 00000000000..25a8f0224d4 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/msgfmt/util.cpp @@ -0,0 +1,63 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include <stdio.h> +#include <stdlib.h> + +// Verify that a UErrorCode is successful; exit(1) if not +void check(UErrorCode& status, const char* msg) { + if (U_FAILURE(status)) { + printf("ERROR: %s (%s)\n", u_errorName(status), msg); + exit(1); + } + // printf("Ok: %s\n", msg); +} + +// Append a hex string to the target +static UnicodeString& appendHex(uint32_t number, + int8_t digits, + UnicodeString& target) { + static const UnicodeString DIGIT_STRING("0123456789ABCDEF"); + while (digits > 0) { + target += DIGIT_STRING[(number >> ((--digits) * 4)) & 0xF]; + } + return target; +} + +// Replace nonprintable characters with unicode escapes +UnicodeString escape(const UnicodeString &source) { + int32_t i; + UnicodeString target; + target += "\""; + for (i=0; i<source.length(); ++i) { + UChar ch = source[i]; + if (ch < 0x09 || (ch > 0x0A && ch < 0x20) || ch > 0x7E) { + target += "\\u"; + appendHex(ch, 4, target); + } else { + target += ch; + } + } + target += "\""; + return target; +} + +// Print the given string to stdout +void uprintf(const UnicodeString &str) { + char *buf = 0; + int32_t len = str.length(); + // int32_t bufLen = str.extract(0, len, buf); // Preflight + /* Preflighting seems to be broken now, so assume 1-1 conversion, + plus some slop. */ + int32_t bufLen = len + 16; + int32_t actualLen; + buf = new char[bufLen + 1]; + actualLen = str.extract(0, len, buf/*, bufLen*/); // Default codepage conversion + buf[actualLen] = 0; + printf("%s", buf); + delete buf; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/msgfmt/util.h b/Build/source/libs/icu/icu-xetex/samples/msgfmt/util.h new file mode 100644 index 00000000000..2d9c4c724e2 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/msgfmt/util.h @@ -0,0 +1,16 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" + +// Verify that a UErrorCode is successful; exit(1) if not +void check(UErrorCode& status, const char* msg); + +// Replace nonprintable characters with unicode escapes +UnicodeString escape(const UnicodeString &source); + +// Print the given string to stdout +void uprintf(const UnicodeString &str); diff --git a/Build/source/libs/icu/icu-xetex/samples/numfmt/Makefile b/Build/source/libs/icu/icu-xetex/samples/numfmt/Makefile new file mode 100644 index 00000000000..eca17b21692 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/numfmt/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=numfmt + +# All object files (C or C++) +OBJECTS=main.o util.o capi.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/numfmt/capi.c b/Build/source/libs/icu/icu-xetex/samples/numfmt/capi.c new file mode 100644 index 00000000000..9b8a1117b12 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/numfmt/capi.c @@ -0,0 +1,77 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unum.h" +#include "unicode/ustring.h" +#include <stdio.h> +#include <stdlib.h> + +static void uprintf(const UChar* str) { + char buf[256]; + u_austrcpy(buf, str); + printf("%s", buf); +} + +void capi() { + UNumberFormat *fmt; + UErrorCode status = U_ZERO_ERROR; + /* The string "987654321.123" as UChars */ + UChar str[] = { 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, + 0x32, 0x31, 0x30, 0x2E, 0x31, 0x32, 0x33, 0 }; + UChar buf[256]; + int32_t needed; + double a; + + /* Create a formatter for the US locale */ + fmt = unum_open( + UNUM_DECIMAL, /* style */ + 0, /* pattern */ + 0, /* patternLength */ + "en_US", /* locale */ + 0, /* parseErr */ + &status); + if (U_FAILURE(status)) { + printf("FAIL: unum_open\n"); + exit(1); + } + + /* Use the formatter to parse a number. When using the C API, + we have to specify whether we want a double or a long in advance. + + We pass in NULL for the position pointer in order to get the + default behavior which is to parse from the start. */ + a = unum_parseDouble(fmt, str, u_strlen(str), NULL, &status); + if (U_FAILURE(status)) { + printf("FAIL: unum_parseDouble\n"); + exit(1); + } + + /* Show the result */ + printf("unum_parseDouble(\""); + uprintf(str); + printf("\") => %g\n", a); + + /* Use the formatter to format the same number back into a string + in the US locale. The return value is the buffer size needed. + We're pretty sure we have enough space, but in a production + application one would check this value. + + We pass in NULL for the UFieldPosition pointer because we don't + care to receive that data. */ + needed = unum_formatDouble(fmt, a, buf, 256, NULL, &status); + if (U_FAILURE(status)) { + printf("FAIL: format_parseDouble\n"); + exit(1); + } + + /* Show the result */ + printf("unum_formatDouble(%g) => \"", a); + uprintf(buf); + printf("\"\n"); + + /* Release the storage used by the formatter */ + unum_close(fmt); +} diff --git a/Build/source/libs/icu/icu-xetex/samples/numfmt/main.cpp b/Build/source/libs/icu/icu-xetex/samples/numfmt/main.cpp new file mode 100644 index 00000000000..1ebd4948c37 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/numfmt/main.cpp @@ -0,0 +1,274 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2004, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/utypes.h" +#include "unicode/unistr.h" +#include "unicode/numfmt.h" +#include "unicode/dcfmtsym.h" +#include "unicode/decimfmt.h" +#include "unicode/locid.h" +#include "unicode/uclean.h" +#include "util.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) + +extern "C" void capi(); +void cppapi(); + +static void +showCurrencyFormatting(UBool useICU26API); + +int main(int argc, char **argv) { + printf("%s output is in UTF-8\n", argv[0]); + + printf("C++ API\n"); + cppapi(); + + printf("C API\n"); + capi(); + + showCurrencyFormatting(FALSE); + showCurrencyFormatting(TRUE); + + u_cleanup(); // Release any additional storage held by ICU. + + printf("Exiting successfully\n"); + return 0; +} + +/** + * Sample code for the C++ API to NumberFormat. + */ +void cppapi() { + Locale us("en", "US"); + UErrorCode status = U_ZERO_ERROR; + + // Create a number formatter for the US locale + NumberFormat *fmt = NumberFormat::createInstance(us, status); + check(status, "NumberFormat::createInstance"); + + // Parse a string. The string uses the digits '0' through '9' + // and the decimal separator '.', standard in the US locale + UnicodeString str("9876543210.123"); + Formattable result; + fmt->parse(str, result, status); + check(status, "NumberFormat::parse"); + + printf("NumberFormat::parse(\""); // Display the result + uprintf(str); + printf("\") => "); + uprintf(formattableToString(result)); + printf("\n"); + + // Take the number parsed above, and use the formatter to + // format it. + str.remove(); // format() will APPEND to this string + fmt->format(result, str, status); + check(status, "NumberFormat::format"); + + printf("NumberFormat::format("); // Display the result + uprintf(formattableToString(result)); + printf(") => \""); + uprintf(str); + printf("\"\n"); + + delete fmt; // Release the storage used by the formatter + +} + +// currency formatting ----------------------------------------------------- *** + +/* + * Set a currency on a NumberFormat with pre-ICU 2.6 APIs. + * This is a "hack" that will not work properly for all cases because + * only ICU 2.6 introduced a more complete framework and data for this. + * + * @param nf The NumberFormat on which to set the currency; takes effect on + * currency-formatting NumberFormat instances. + * This must actually be a DecimalFormat instance. + * The display style of the output is controlled by nf (its pattern, + * usually from the display locale ID used to create this instance) + * while the currency symbol and number of decimals are set for + * the currency. + * @param currency The 3-letter ISO 4217 currency code, NUL-terminated. + * @param errorCode ICU error code, must pass U_SUCCESS() on input. + */ +static void +setNumberFormatCurrency_2_4(NumberFormat &nf, const char *currency, UErrorCode &errorCode) { + // argument checking + if(U_FAILURE(errorCode)) { + return; + } + if(currency==NULL || strlen(currency)!=3) { + errorCode=U_ILLEGAL_ARGUMENT_ERROR; + return; + } + + // check that the formatter is a DecimalFormat instance + // necessary because we will cast to the DecimalFormat subclass to set + // the currency symbol + if(nf.getDynamicClassID()!=DecimalFormat::getStaticClassID()) { + errorCode=U_ILLEGAL_ARGUMENT_ERROR; + return; + } + + // map the currency code to a locale ID + // only the currencies in this array are supported + // it would be possible to map to a locale ID, instantiate a currency + // formatter for that and copy its values, but that would be slower, + // and we have to hardcode something here anyway + static const struct { + // ISO currency ID + const char *currency; + + // fractionDigits==minimumFractionDigits==maximumFractionDigits + // for these currencies + int32_t fractionDigits; + + /* + * Set the rounding increment to 0 if it is implied with the number of + * fraction digits. Setting an explicit rounding increment makes + * number formatting slower. + * In other words, set it to something other than 0 only for unusual + * cases like "nickel rounding" (0.05) when the increment differs from + * 10^(-maximumFractionDigits). + */ + double roundingIncrement; + + // Unicode string with the desired currency display symbol or name + UChar symbol[16]; + } currencyMap[]={ + { "USD", 2, 0.0, { 0x24, 0 } }, + { "GBP", 2, 0.0, { 0xa3, 0 } }, + { "EUR", 2, 0.0, { 0x20ac, 0 } }, + { "JPY", 0, 0.0, { 0xa5, 0 } } + }; + + int32_t i; + + for(i=0; i<LENGTHOF(currencyMap); ++i) { + if(strcmp(currency, currencyMap[i].currency)==0) { + break; + } + } + if(i==LENGTHOF(currencyMap)) { + // a more specific error code would be useful in a real application + errorCode=U_UNSUPPORTED_ERROR; + return; + } + + // set the currency-related data into the caller's formatter + + nf.setMinimumFractionDigits(currencyMap[i].fractionDigits); + nf.setMaximumFractionDigits(currencyMap[i].fractionDigits); + + DecimalFormat &dnf=(DecimalFormat &)nf; + dnf.setRoundingIncrement(currencyMap[i].roundingIncrement); + + DecimalFormatSymbols symbols(*dnf.getDecimalFormatSymbols()); + symbols.setSymbol(DecimalFormatSymbols::kCurrencySymbol, currencyMap[i].symbol); + dnf.setDecimalFormatSymbols(symbols); // do not adopt symbols: Jitterbug 2889 +} + +/* + * Set a currency on a NumberFormat with ICU 2.6 APIs. + * + * @param nf The NumberFormat on which to set the currency; takes effect on + * currency-formatting NumberFormat instances. + * The display style of the output is controlled by nf (its pattern, + * usually from the display locale ID used to create this instance) + * while the currency symbol and number of decimals are set for + * the currency. + * @param currency The 3-letter ISO 4217 currency code, NUL-terminated. + * @param errorCode ICU error code, must pass U_SUCCESS() on input. + */ +static void +setNumberFormatCurrency_2_6(NumberFormat &nf, const char *currency, UErrorCode &errorCode) { + if(U_FAILURE(errorCode)) { + return; + } + if(currency==NULL || strlen(currency)!=3) { + errorCode=U_ILLEGAL_ARGUMENT_ERROR; + return; + } + + // invariant-character conversion to UChars (see utypes.h and putil.h) + UChar uCurrency[4]; + u_charsToUChars(currency, uCurrency, 4); + + // set the currency + // in ICU 3.0 this API (which was @draft ICU 2.6) gained a UErrorCode& argument +#if (U_ICU_VERSION_MAJOR_NUM < 3) + nf.setCurrency(uCurrency); +#else + nf.setCurrency(uCurrency, errorCode); +#endif +} + +static const char *const +sampleLocaleIDs[]={ + // use locale IDs complete with country code to be sure to + // pick up number/currency format patterns + "en_US", "en_GB", "de_DE", "ja_JP", "fr_FR", "hi_IN" +}; + +static const char *const +sampleCurrencies[]={ + "USD", "GBP", "EUR", "JPY" +}; + +static void +showCurrencyFormatting(UBool useICU26API) { + NumberFormat *nf; + int32_t i, j; + + UnicodeString output; + + UErrorCode errorCode; + + // TODO: Using printf() here assumes that the runtime encoding is ASCII-friendly + // and can therefore be mixed with UTF-8 + + for(i=0; i<LENGTHOF(sampleLocaleIDs); ++i) { + printf("show currency formatting (method for %s) in the locale \"%s\"\n", + useICU26API ? "ICU 2.6" : "before ICU 2.6", + sampleLocaleIDs[i]); + + // get a currency formatter for this locale ID + errorCode=U_ZERO_ERROR; + nf=NumberFormat::createCurrencyInstance(sampleLocaleIDs[i], errorCode); + if(U_FAILURE(errorCode)) { + printf("NumberFormat::createCurrencyInstance(%s) failed - %s\n", + sampleLocaleIDs[i], u_errorName(errorCode)); + continue; + } + + for(j=0; j<LENGTHOF(sampleCurrencies); ++j) { + printf(" - format currency \"%s\": ", sampleCurrencies[j]); + + // set the actual currency to be formatted + if(useICU26API) { + setNumberFormatCurrency_2_6(*nf, sampleCurrencies[j], errorCode); + } else { + setNumberFormatCurrency_2_4(*nf, sampleCurrencies[j], errorCode); + } + if(U_FAILURE(errorCode)) { + printf("setNumberFormatCurrency(%s) failed - %s\n", + sampleCurrencies[j], u_errorName(errorCode)); + continue; + } + + // output=formatted currency value + output.remove(); + nf->format(12345678.93, output); + output+=(UChar)0x0a; // '\n' + uprintf(output); + } + } +} diff --git a/Build/source/libs/icu/icu-xetex/samples/numfmt/numfmt.sln b/Build/source/libs/icu/icu-xetex/samples/numfmt/numfmt.sln new file mode 100644 index 00000000000..c8d8ed7509f --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/numfmt/numfmt.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "numfmt", "numfmt.vcproj", "{721FBD47-E458-4C35-90DA-FF192907D5E2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {721FBD47-E458-4C35-90DA-FF192907D5E2}.Debug|Win32.ActiveCfg = Debug|Win32 + {721FBD47-E458-4C35-90DA-FF192907D5E2}.Debug|Win32.Build.0 = Debug|Win32 + {721FBD47-E458-4C35-90DA-FF192907D5E2}.Release|Win32.ActiveCfg = Release|Win32 + {721FBD47-E458-4C35-90DA-FF192907D5E2}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/numfmt/numfmt.vcproj b/Build/source/libs/icu/icu-xetex/samples/numfmt/numfmt.vcproj new file mode 100644 index 00000000000..af787cb4b89 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/numfmt/numfmt.vcproj @@ -0,0 +1,235 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="numfmt" + ProjectGUID="{721FBD47-E458-4C35-90DA-FF192907D5E2}" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <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" + TypeLibraryName=".\Debug/numfmt.tlb" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="../../../include" + PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Debug/numfmt.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/numfmt.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/numfmt.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="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" + TypeLibraryName=".\Release/numfmt.tlb" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="../../../include" + PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE" + StringPooling="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Release/numfmt.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/numfmt.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib" + ProgramDatabaseFile=".\Release/numfmt.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=".\capi.c" + > + </File> + <File + RelativePath=".\main.cpp" + > + </File> + <File + RelativePath=".\util.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl" + > + <File + RelativePath=".\util.h" + > + </File> + </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/numfmt/readme.txt b/Build/source/libs/icu/icu-xetex/samples/numfmt/readme.txt new file mode 100644 index 00000000000..d652d9b6b57 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/numfmt/readme.txt @@ -0,0 +1,61 @@ +Copyright (c) 2002-2005, International Business Machines Corporation and others. All Rights Reserved. +numfmt: a sample program which displays number formatting in C and C++ + +This sample demonstrates + Formatting a number + Outputting text in the default codepage to the console + +Files: + main.cpp Main source file in C++ + capi.c C version + util.cpp formatted output convenience implementation + util.h formatted output convenience header + numfmt.sln Windows MSVC workspace. Double-click this to get started. + numfmt.vcproj Windows MSVC project file + +To Build on Windows + 1. Install and build ICU + 2. In MSVC, open the workspace file icu\samples\numfmt\numfmt.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 numfmt directory, e.g. + cd c:\icu\source\samples\numfmt\debug + 4. Run it + numfmt + +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/numfmt + gmake ICU_PREFIX=<icu install directory) + + To Run on Unixes + cd <icu directory>/source/samples/numfmt + + gmake ICU_PREFIX=<icu install directory> check + -or- + + 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 + for Linux and Solaris. + diff --git a/Build/source/libs/icu/icu-xetex/samples/numfmt/util.cpp b/Build/source/libs/icu/icu-xetex/samples/numfmt/util.cpp new file mode 100644 index 00000000000..b4025444991 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/numfmt/util.cpp @@ -0,0 +1,117 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2003, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include "unicode/fmtable.h" +#include <stdio.h> +#include <stdlib.h> + +enum { + U_SPACE=0x20, + U_DQUOTE=0x22, + U_COMMA=0x2c, + U_LEFT_SQUARE_BRACKET=0x5b, + U_BACKSLASH=0x5c, + U_RIGHT_SQUARE_BRACKET=0x5d, + U_SMALL_U=0x75 +}; + +// Verify that a UErrorCode is successful; exit(1) if not +void check(UErrorCode& status, const char* msg) { + if (U_FAILURE(status)) { + printf("ERROR: %s (%s)\n", u_errorName(status), msg); + exit(1); + } + // printf("Ok: %s\n", msg); +} + +// Append a hex string to the target +static UnicodeString& appendHex(uint32_t number, + int8_t digits, + UnicodeString& target) { + uint32_t digit; + while (digits > 0) { + digit = (number >> ((--digits) * 4)) & 0xF; + target += (UChar)(digit < 10 ? 0x30 + digit : 0x41 - 10 + digit); + } + return target; +} + +// Replace nonprintable characters with unicode escapes +UnicodeString escape(const UnicodeString &source) { + int32_t i; + UnicodeString target; + target += (UChar)U_DQUOTE; + for (i=0; i<source.length(); ++i) { + UChar ch = source[i]; + if (ch < 0x09 || (ch > 0x0D && ch < 0x20) || ch > 0x7E) { + (target += (UChar)U_BACKSLASH) += (UChar)U_SMALL_U; + appendHex(ch, 4, target); + } else { + target += ch; + } + } + target += (UChar)U_DQUOTE; + return target; +} + +// Print the given string to stdout using the UTF-8 converter +void uprintf(const UnicodeString &str) { + char stackBuffer[100]; + char *buf = 0; + + int32_t bufLen = str.extract(0, 0x7fffffff, stackBuffer, sizeof(stackBuffer), "UTF-8"); + if(bufLen < sizeof(stackBuffer)) { + buf = stackBuffer; + } else { + buf = new char[bufLen + 1]; + bufLen = str.extract(0, 0x7fffffff, buf, bufLen + 1, "UTF-8"); + } + printf("%s", buf); + if(buf != stackBuffer) { + delete buf; + } +} + +// Create a display string for a formattable +UnicodeString formattableToString(const Formattable& f) { + switch (f.getType()) { + case Formattable::kDate: + // TODO: Finish implementing this + return UNICODE_STRING_SIMPLE("Formattable_DATE_TBD"); + case Formattable::kDouble: + { + char buf[256]; + sprintf(buf, "%gD", f.getDouble()); + return UnicodeString(buf, ""); + } + case Formattable::kLong: + case Formattable::kInt64: + { + char buf[256]; + sprintf(buf, "%ldL", f.getLong()); + return UnicodeString(buf, ""); + } + case Formattable::kString: + return UnicodeString((UChar)U_DQUOTE).append(f.getString()).append((UChar)U_DQUOTE); + case Formattable::kArray: + { + int32_t i, count; + const Formattable* array = f.getArray(count); + UnicodeString result((UChar)U_LEFT_SQUARE_BRACKET); + for (i=0; i<count; ++i) { + if (i > 0) { + (result += (UChar)U_COMMA) += (UChar)U_SPACE; + } + result += formattableToString(array[i]); + } + result += (UChar)U_RIGHT_SQUARE_BRACKET; + return result; + } + default: + return UNICODE_STRING_SIMPLE("INVALID_Formattable"); + } +} diff --git a/Build/source/libs/icu/icu-xetex/samples/numfmt/util.h b/Build/source/libs/icu/icu-xetex/samples/numfmt/util.h new file mode 100644 index 00000000000..e50ef7aae2c --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/numfmt/util.h @@ -0,0 +1,20 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include "unicode/fmtable.h" + +// Verify that a UErrorCode is successful; exit(1) if not +void check(UErrorCode& status, const char* msg); + +// Replace nonprintable characters with unicode escapes +UnicodeString escape(const UnicodeString &source); + +// Print the given string to stdout +void uprintf(const UnicodeString &str); + +// Create a display string for a formattable +UnicodeString formattableToString(const Formattable& f); diff --git a/Build/source/libs/icu/icu-xetex/samples/props/Makefile b/Build/source/libs/icu/icu-xetex/samples/props/Makefile new file mode 100644 index 00000000000..6d0a60b22dc --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/props/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=props + +# All object files (C or C++) +OBJECTS=props.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/props/props.cpp b/Build/source/libs/icu/icu-xetex/samples/props/props.cpp new file mode 100644 index 00000000000..f60f26a63fd --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/props/props.cpp @@ -0,0 +1,65 @@ +/* +******************************************************************************* +* +* Copyright (C) 2000, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +* file name: props.cpp +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:4 +* +* created on: 2000sep22 +* created by: Markus W. Scherer +* +* This file contains sample code that illustrates the use of the ICU APIs +* for Unicode character properties. +*/ + +#include <stdio.h> +#include "unicode/utypes.h" +#include "unicode/uchar.h" +#include "unicode/uclean.h" + +static void +printProps(UChar32 codePoint) { + char buffer[100]; + UErrorCode errorCode; + + /* get the character name */ + errorCode=U_ZERO_ERROR; + u_charName(codePoint, U_UNICODE_CHAR_NAME, buffer, sizeof(buffer), &errorCode); + + /* print the code point and the character name */ + printf("U+%04lx\t%s\n", codePoint, buffer); + + /* print some properties */ + printf(" general category (numeric enum value): %u\n", u_charType(codePoint)); + + /* note: these APIs do not provide the data from SpecialCasing.txt */ + printf(" is lowercase: %d uppercase: U+%04lx\n", u_islower(codePoint), u_toupper(codePoint)); + + printf(" is digit: %d decimal digit value: %d\n", u_isdigit(codePoint), u_charDigitValue(codePoint)); + + printf(" BiDi directional category (numeric enum value): %u\n", u_charDirection(codePoint)); +} + +/* Note: In ICU 2.0, the Unicode class is deprecated - it is a pure wrapper around the C APIs above. */ + +extern int +main(int argc, const char *argv[]) { + static const UChar32 + codePoints[]={ + 0xd, 0x20, 0x2d, 0x35, 0x65, 0x284, 0x665, 0x5678, 0x23456, 0x10317, 0x1D01F, 0x10fffd + }; + int i; + + for(i=0; i<sizeof(codePoints)/sizeof(codePoints[0]); ++i) { + printProps(codePoints[i]); + puts(""); + } + + u_cleanup(); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/props/props.sln b/Build/source/libs/icu/icu-xetex/samples/props/props.sln new file mode 100644 index 00000000000..843fc74f3ff --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/props/props.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "props", "props.vcproj", "{ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}.Debug|Win32.ActiveCfg = Debug|Win32 + {ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}.Debug|Win32.Build.0 = Debug|Win32 + {ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}.Release|Win32.ActiveCfg = Release|Win32 + {ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/props/props.vcproj b/Build/source/libs/icu/icu-xetex/samples/props/props.vcproj new file mode 100644 index 00000000000..2d3d50ac2ec --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/props/props.vcproj @@ -0,0 +1,223 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="props" + ProjectGUID="{ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}" + > + <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" + TypeLibraryName=".\Release/props.tlb" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE" + StringPooling="true" + RuntimeLibrary="3" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Release/props.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 odbc32.lib odbccp32.lib" + OutputFile=".\Release/props.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + ProgramDatabaseFile=".\Release/props.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" + TypeLibraryName=".\Debug/props.tlb" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Debug/props.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 odbc32.lib odbccp32.lib" + OutputFile=".\Debug/props.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/props.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=".\props.cpp" + > + </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/props/readme.txt b/Build/source/libs/icu/icu-xetex/samples/props/readme.txt new file mode 100644 index 00000000000..b80aa2575a4 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/props/readme.txt @@ -0,0 +1,59 @@ +Copyright (c) 2002-2005, International Business Machines Corporation and others. All Rights Reserved. +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.sln Windows MSVC workspace. Double-click this to get started. + props.vcproj 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.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 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. + diff --git a/Build/source/libs/icu/icu-xetex/samples/readme.txt b/Build/source/libs/icu/icu-xetex/samples/readme.txt new file mode 100644 index 00000000000..3e4eda7a1b0 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/readme.txt @@ -0,0 +1,71 @@ +## Copyright (c) 2002-2005, 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. + +break - demonstrates how to use BreakIterators in C and C++. + +cal - prints out a calendar. + +case - demonstrates how to do Unicode case conversion in C and C++. + +date - prints out the current date, localized. + +datefmt - an exercise using the date formatting API + +layout - demonstrates the ICU LayoutEngine + +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 + +strsrch - demonstrates how to search for patterns in Unicode text using the usearch interface. + +translit - demonstrates the use of ICU transliteration + +uciter8.c - demonstrates how to leniently read 8-bit Unicode text. + +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 + +ugrep - demonstrates ICU Regular Expressions. + +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://dev.icu-project.org/cgi-bin/viewcvs.cgi/icuapps/ + +== +* How do I build the samples? + + - See the Readme in each subdirectory + + To build all samples at once: + + Unix: - build and install (make install) ICU + - be sure 'icu-config' is accessible from the PATH + - type 'make all-samples' from this directory + (other targets: clean-samples, check-samples) + Note: 'make all-samples' won't work correctly in out of source builds. + + - legacy and layout are not included in these lists, + please see their individual readmes. diff --git a/Build/source/libs/icu/icu-xetex/samples/rules.mk b/Build/source/libs/icu/icu-xetex/samples/rules.mk new file mode 100644 index 00000000000..5d39b7c7eae --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/rules.mk @@ -0,0 +1,38 @@ +# Copyright (c) 2002-2006 IBM, Inc. and others +# sample code rules for a single-target simple sample + +# list of targets that aren't actually created +.PHONY: all clean distclean check report + +all: $(ALL_SUBDIR) $(RESTARGET) $(TARGET) + +$(TARGET): $(OBJECTS) + $(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ $(XTRALIBS) + +$(RESTARGET): $(RESFILES) + $(PKGDATA) --name $(RESNAME) --mode $(RESMODE) $(PKGDATAOPTS) $(RESLIST) + +res-install: $(RESTARGET) + $(PKGDATA) --name $(RESNAME) --mode $(RESMODE) $(PKGDATAOPTS) $(RESLIST) --install $(shell icu-config --libdir) + +# clean out files +distclean clean: $(CLEAN_SUBDIR) + -test -z "$(CLEANFILES)" || rm -rf $(CLEANFILES) + -rm -rf $(OBJECTS) $(TARGET) $(RESTARGET) $(RESFILES) + +# Make check: simply runs the sample, logged to a file +check: $(TARGET) + $(INVOKE) $(CHECK_VARS) ./$(TARGET) $(CHECK_ARGS) | tee $(TARGET).out + +## resources +%.res: %.txt + @echo "generating $@" + $(GENRB) $(GENRBOPT) $^ + +$(RESNAME)/%.res: %.txt + @echo "generating $@" + $(GENRB) $(GENRBOPT) $^ + +## Some platforms don't have .cpp as a default suffix, so add the rule here +%.o: %.cpp + $(COMPILE.cc) $< $(OUTPUT_OPTION) diff --git a/Build/source/libs/icu/icu-xetex/samples/strsrch/Makefile b/Build/source/libs/icu/icu-xetex/samples/strsrch/Makefile new file mode 100644 index 00000000000..ffd211c061c --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/strsrch/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=strsrch + +# All object files (C or C++) +OBJECTS=strsrch.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/strsrch/readme.txt b/Build/source/libs/icu/icu-xetex/samples/strsrch/readme.txt new file mode 100644 index 00000000000..589c7adf83b --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/strsrch/readme.txt @@ -0,0 +1,55 @@ +Copyright (c) 2002-2005, International Business Machines Corporation and others. All Rights Reserved. +strsrch: a sample program which finds the occurrences of a pattern string in a source string, using user-defined collation rules. + +This sample demonstrates + Creating a user-defined string search mechanism. + Finding all occurrences of a pattern string in a given source string. + +Files: + strsrch.c Main source file + strsrch.sln Windows MSVC workspace. Double-click this to get started. + strsrch.vcproj Windows MSVC project file + +To Build strsrch on Windows + 1. Install and build ICU + 2. In MSVC, open the workspace file icu\samples\strsrch\strsrch.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 strsrch directory, e.g. + cd c:\icu\source\samples\strsrch\debug + 4. Run it + strsrch [options*] -source source_string -pattern pattern_string + +To Build on Unixes + 1. Build ICU. strsrch 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/strsrch + + 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. + diff --git a/Build/source/libs/icu/icu-xetex/samples/strsrch/strsrch.cpp b/Build/source/libs/icu/icu-xetex/samples/strsrch/strsrch.cpp new file mode 100644 index 00000000000..5054ceebdaf --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/strsrch/strsrch.cpp @@ -0,0 +1,301 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (C) 2002-2006 IBM, Inc. All Rights Reserved. + * + ********************************************************************/ + +/** + * This program demos string collation + */ + +const char gHelpString[] = + "usage: strsrch [options*] -source source_string -pattern pattern_string\n" + "-help Display this message.\n" + "-locale name ICU locale to use. Default is en_US\n" + "-rules rule Collation rules file (overrides locale)\n" + "-french French accent ordering\n" + "-norm Normalizing mode on\n" + "-shifted Shifted mode\n" + "-lower Lower case first\n" + "-upper Upper case first\n" + "-case Enable separate case level\n" + "-level n Sort level, 1 to 5, for Primary, Secndary, Tertiary, Quaternary, Identical\n" + "-source string Source string\n" + "-pattern string Pattern string to look for in source\n" + "-overlap Enable searching to be done on overlapping patterns\n" + "-canonical Enable searching to be done matching canonical equivalent patterns" + "Example strsrch -rules \\u0026b\\u003ca -source a\\u0020b\\u0020bc -pattern b\n" + "The format \\uXXXX is supported for the rules and comparison strings\n" + ; + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include <unicode/utypes.h> +#include <unicode/ucol.h> +#include <unicode/usearch.h> +#include <unicode/ustring.h> + +/** + * Command line option variables + * These global variables are set according to the options specified + * on the command line by the user. + */ +char * opt_locale = "en_US"; +char * opt_rules = 0; +UBool opt_help = FALSE; +UBool opt_norm = FALSE; +UBool opt_french = FALSE; +UBool opt_shifted = FALSE; +UBool opt_lower = FALSE; +UBool opt_upper = FALSE; +UBool opt_case = FALSE; +UBool opt_overlap = FALSE; +UBool opt_canonical = FALSE; +int opt_level = 0; +char * opt_source = "International Components for Unicode"; +char * opt_pattern = "Unicode"; +UCollator * collator = 0; +UStringSearch * search = 0; +UChar rules[100]; +UChar source[100]; +UChar pattern[100]; + +/** + * Definitions for the command line options + */ +struct OptSpec { + const char *name; + enum {FLAG, NUM, STRING} type; + void *pVar; +}; + +OptSpec opts[] = { + {"-locale", OptSpec::STRING, &opt_locale}, + {"-rules", OptSpec::STRING, &opt_rules}, + {"-source", OptSpec::STRING, &opt_source}, + {"-pattern", OptSpec::STRING, &opt_pattern}, + {"-norm", OptSpec::FLAG, &opt_norm}, + {"-french", OptSpec::FLAG, &opt_french}, + {"-shifted", OptSpec::FLAG, &opt_shifted}, + {"-lower", OptSpec::FLAG, &opt_lower}, + {"-upper", OptSpec::FLAG, &opt_upper}, + {"-case", OptSpec::FLAG, &opt_case}, + {"-level", OptSpec::NUM, &opt_level}, + {"-overlap", OptSpec::FLAG, &opt_overlap}, + {"-canonical", OptSpec::FLAG, &opt_canonical}, + {"-help", OptSpec::FLAG, &opt_help}, + {"-?", OptSpec::FLAG, &opt_help}, + {0, OptSpec::FLAG, 0} +}; + +/** + * processOptions() Function to read the command line options. + */ +UBool processOptions(int argc, const char **argv, OptSpec opts[]) +{ + for (int argNum = 1; argNum < argc; argNum ++) { + const char *pArgName = argv[argNum]; + OptSpec *pOpt; + for (pOpt = opts; pOpt->name != 0; pOpt ++) { + if (strcmp(pOpt->name, pArgName) == 0) { + switch (pOpt->type) { + case OptSpec::FLAG: + *(UBool *)(pOpt->pVar) = TRUE; + break; + case OptSpec::STRING: + argNum ++; + if (argNum >= argc) { + fprintf(stderr, "value expected for \"%s\" option.\n", + pOpt->name); + return FALSE; + } + *(const char **)(pOpt->pVar) = argv[argNum]; + break; + case OptSpec::NUM: + argNum ++; + if (argNum >= argc) { + fprintf(stderr, "value expected for \"%s\" option.\n", + pOpt->name); + return FALSE; + } + char *endp; + int i = strtol(argv[argNum], &endp, 0); + if (endp == argv[argNum]) { + fprintf(stderr, + "integer value expected for \"%s\" option.\n", + pOpt->name); + return FALSE; + } + *(int *)(pOpt->pVar) = i; + } + break; + } + } + if (pOpt->name == 0) + { + fprintf(stderr, "Unrecognized option \"%s\"\n", pArgName); + return FALSE; + } + } + return TRUE; +} + +/** + * Creates a collator + */ +UBool processCollator() +{ + // Set up an ICU collator + UErrorCode status = U_ZERO_ERROR; + + if (opt_rules != 0) { + u_unescape(opt_rules, rules, 100); + collator = ucol_openRules(rules, -1, UCOL_OFF, UCOL_TERTIARY, + NULL, &status); + } + else { + collator = ucol_open(opt_locale, &status); + } + if (U_FAILURE(status)) { + fprintf(stderr, "Collator creation failed.: %d\n", status); + return FALSE; + } + if (status == U_USING_DEFAULT_WARNING) { + fprintf(stderr, "Warning, U_USING_DEFAULT_WARNING for %s\n", + opt_locale); + } + if (status == U_USING_FALLBACK_WARNING) { + fprintf(stderr, "Warning, U_USING_FALLBACK_ERROR for %s\n", + opt_locale); + } + if (opt_norm) { + ucol_setAttribute(collator, UCOL_NORMALIZATION_MODE, UCOL_ON, &status); + } + if (opt_french) { + ucol_setAttribute(collator, UCOL_FRENCH_COLLATION, UCOL_ON, &status); + } + if (opt_lower) { + ucol_setAttribute(collator, UCOL_CASE_FIRST, UCOL_LOWER_FIRST, + &status); + } + if (opt_upper) { + ucol_setAttribute(collator, UCOL_CASE_FIRST, UCOL_UPPER_FIRST, + &status); + } + if (opt_case) { + ucol_setAttribute(collator, UCOL_CASE_LEVEL, UCOL_ON, &status); + } + if (opt_shifted) { + ucol_setAttribute(collator, UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, + &status); + } + if (opt_level != 0) { + switch (opt_level) { + case 1: + ucol_setAttribute(collator, UCOL_STRENGTH, UCOL_PRIMARY, &status); + break; + case 2: + ucol_setAttribute(collator, UCOL_STRENGTH, UCOL_SECONDARY, + &status); + break; + case 3: + ucol_setAttribute(collator, UCOL_STRENGTH, UCOL_TERTIARY, &status); + break; + case 4: + ucol_setAttribute(collator, UCOL_STRENGTH, UCOL_QUATERNARY, + &status); + break; + case 5: + ucol_setAttribute(collator, UCOL_STRENGTH, UCOL_IDENTICAL, + &status); + break; + default: + fprintf(stderr, "-level param must be between 1 and 5\n"); + return FALSE; + } + } + if (U_FAILURE(status)) { + fprintf(stderr, "Collator attribute setting failed.: %d\n", status); + return FALSE; + } + return TRUE; +} + +/** + * Creates a string search + */ +UBool processStringSearch() +{ + u_unescape(opt_source, source, 100); + u_unescape(opt_pattern, pattern, 100); + UErrorCode status = U_ZERO_ERROR; + search = usearch_openFromCollator(pattern, -1, source, -1, collator, NULL, + &status); + if (U_FAILURE(status)) { + return FALSE; + } + if (opt_overlap == TRUE) { + usearch_setAttribute(search, USEARCH_OVERLAP, USEARCH_ON, &status); + } + if (opt_canonical == TRUE) { + usearch_setAttribute(search, USEARCH_CANONICAL_MATCH, USEARCH_ON, + &status); + } + if (U_FAILURE(status)) { + fprintf(stderr, "Error setting search attributes\n"); + return FALSE; + } + return TRUE; +} + +UBool findPattern() +{ + UErrorCode status = U_ZERO_ERROR; + int32_t offset = usearch_next(search, &status); + if (offset == USEARCH_DONE) { + fprintf(stdout, "Pattern not found in source\n"); + } + while (offset != USEARCH_DONE) { + fprintf(stdout, "Pattern found at offset %d size %d\n", offset, + usearch_getMatchedLength(search)); + offset = usearch_next(search, &status); + } + if (U_FAILURE(status)) { + fprintf(stderr, "Error in searching for pattern %d\n", status); + return FALSE; + } + fprintf(stdout, "End of search\n"); + return TRUE; +} + +/** + * Main -- process command line, read in and pre-process the test file, + * call other functions to do the actual tests. + */ +int main(int argc, const char** argv) +{ + if (processOptions(argc, argv, opts) != TRUE || opt_help) { + printf(gHelpString); + return -1; + } + + if (processCollator() != TRUE) { + fprintf(stderr, "Error creating collator\n"); + return -1; + } + + if (processStringSearch() != TRUE) { + fprintf(stderr, "Error creating string search\n"); + return -1; + } + + fprintf(stdout, "Finding pattern %s in source %s\n", opt_pattern, + opt_source); + + findPattern(); + ucol_close(collator); + usearch_close(search); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/strsrch/strsrch.sln b/Build/source/libs/icu/icu-xetex/samples/strsrch/strsrch.sln new file mode 100644 index 00000000000..89a7bfba5eb --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/strsrch/strsrch.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "strsrch", "strsrch.vcproj", "{E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}.Debug|Win32.ActiveCfg = Debug|Win32 + {E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}.Debug|Win32.Build.0 = Debug|Win32 + {E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}.Release|Win32.ActiveCfg = Release|Win32 + {E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/strsrch/strsrch.vcproj b/Build/source/libs/icu/icu-xetex/samples/strsrch/strsrch.vcproj new file mode 100644 index 00000000000..4bfec78d752 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/strsrch/strsrch.vcproj @@ -0,0 +1,224 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="strsrch" + ProjectGUID="{E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <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" + TypeLibraryName=".\Debug/strsrch.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/strsrch.pch" + AssemblerListingLocation=".\Debug/" + ObjectFile=".\Debug/" + ProgramDataBaseFileName=".\Debug/" + BrowseInformation="1" + 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="icuind.lib icuucd.lib" + OutputFile=".\Debug/strsrch.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/strsrch.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="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" + TypeLibraryName=".\Release/strsrch.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/strsrch.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="icuin.lib icuuc.lib" + OutputFile=".\Release/strsrch.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + ProgramDatabaseFile=".\Release/strsrch.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=".\strsrch.cpp" + > + </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/translit/Makefile b/Build/source/libs/icu/icu-xetex/samples/translit/Makefile new file mode 100644 index 00000000000..d7d2baf97e1 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/translit/Makefile @@ -0,0 +1,22 @@ +# Copyright (c) 2000-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=translit + +# All object files (C or C++) +OBJECTS=main.o unaccent.o util.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/translit/README.TXT b/Build/source/libs/icu/icu-xetex/samples/translit/README.TXT new file mode 100644 index 00000000000..a7c44e6008c --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/translit/README.TXT @@ -0,0 +1,101 @@ +Copyright (c) 2002-2007, International Business Machines Corporation and others. All Rights Reserved. +This is an exercise for the ICU Workshop (September 2000). + http://www.icu-project.org/docs/workshop_2000/agenda.html + + Day 2: September 12th 2000 + Pre-requisite: + 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 + http://www.icu-project.org/userguide/. + + #Transformation Support + 10:45am - 12:00pm + Alan Liu + + Topics: + 1. What is the Unicode normalization? + 2. What kind of case mapping support is available in ICU? + 3. What is Transliteration and how do I use a Transliterator on a document? + 4. How do I add my own Transliterator? + + +INSTRUCTIONS +------------ + +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. + + MSVC: + Open the file "translit.sln" 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 +-------- + +Problem 0: + + To start with, the program prints out a series of dates formatted in + Greek. Set up the program, build it, and run it. + +Problem 1: Basic Transliterator (Easy) + + The Greek text shows up almost entirely as Unicode escapes. These + are unreadable on a US machine. Use an existing system + transliterator to transliterate the Greek text to Latin so it can be + phonetically read on a US machine. If you don't know the names of + the system transliterators, use Transliterator::getAvailableID() and + Transliterator::countAvailableIDs(), or look directly in the index + table icu/data/translit_index.txt. + +Problem 2: RuleBasedTransliterator (Medium) + + Some of the text is still unreadable and shows up as Unicode escape + sequences. Create a RuleBasedTransliterator to change the + unreadable characters to close ASCII equivalents. For example, the + rule "\u00C0 > A;" will change an 'A' with a grave accent to a plain + 'A'. + + To save typing, use UnicodeSets to handle ranges of characters. + + See the included file "U0080.pdf" for a table of the U+00C0 to U+00FF + Unicode block. + +Problem 3: Transliterator subclassing; Normalizer (Difficult) + + The rule-based approach is flexible and, in most cases, the best + choice for creating a new transliterator. Sometimes, however, a + more elegant algorithmic solution is available. Instead of typing + in a list of rules, you can write C++ code to accomplish the desired + transliteration. + + Use a Normalizer to remove accents from characters. You will need + to convert each character to a sequence of base and combining + characters by applying a canonical denormalization transformation. + Then discard the combining characters (the accents etc.) leaving the + base character. Wrap this all up in a subclass of the + Transliterator class that overrides the pure virtual + handleTransliterate() method. + + +ANSWERS +------- + +The exercise includes answers. These are in the "answers" directory, +and are numbered 1, 2, etc. In some cases new files that the user +needs to create are included in the answers directory. + +If you get stuck and you want to move to the next step, copy the +answers file into the main directory in order to proceed. E.g., +"main_1.cpp" contains the original "main.cpp" file. "main_2.cpp" +contains the "main.cpp" file after problem 1. Etc. + + +Have fun! diff --git a/Build/source/libs/icu/icu-xetex/samples/translit/answers/main_1.cpp b/Build/source/libs/icu/icu-xetex/samples/translit/answers/main_1.cpp new file mode 100644 index 00000000000..ba526eb675b --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/translit/answers/main_1.cpp @@ -0,0 +1,70 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/translit.h" +#include "unicode/rbt.h" +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" +#include "unaccent.h" + +int main(int argc, char **argv) { + + Calendar *cal; + DateFormat *fmt; + DateFormat *defFmt; + UErrorCode status = U_ZERO_ERROR; + Locale greece("el", "GR"); + UnicodeString str, str2; + + // Create a calendar in the Greek locale + cal = Calendar::createInstance(greece, status); + check(status, "Calendar::createInstance"); + + // Create a formatter + fmt = DateFormat::createDateInstance(DateFormat::kFull, greece); + fmt->setCalendar(*cal); + + // Create a default formatter + defFmt = DateFormat::createDateInstance(DateFormat::kFull); + defFmt->setCalendar(*cal); + + // Loop over various months + for (int32_t month = Calendar::JANUARY; + month <= Calendar::DECEMBER; + ++month) { + + // Set the calendar to a date + cal->clear(); + cal->set(1999, month, 4); + + // Format the date in default locale + str.remove(); + defFmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Date: "); + uprintf(escape(str)); + printf("\n"); + + // Format the date for Greece + str.remove(); + fmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Greek formatted date: "); + uprintf(escape(str)); + printf("\n\n"); + } + + // Clean up + delete fmt; + delete cal; + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/translit/answers/main_2.cpp b/Build/source/libs/icu/icu-xetex/samples/translit/answers/main_2.cpp new file mode 100644 index 00000000000..bf392d105a6 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/translit/answers/main_2.cpp @@ -0,0 +1,85 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/translit.h" +#include "unicode/rbt.h" +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" +#include "unaccent.h" + +int main(int argc, char **argv) { + + Calendar *cal; + DateFormat *fmt; + DateFormat *defFmt; + Transliterator *greek_latin; + UErrorCode status = U_ZERO_ERROR; + Locale greece("el", "GR"); + UnicodeString str, str2; + + // Create a calendar in the Greek locale + cal = Calendar::createInstance(greece, status); + check(status, "Calendar::createInstance"); + + // Create a formatter + fmt = DateFormat::createDateInstance(DateFormat::kFull, greece); + fmt->setCalendar(*cal); + + // Create a default formatter + defFmt = DateFormat::createDateInstance(DateFormat::kFull); + defFmt->setCalendar(*cal); + + // Create a Greek-Latin Transliterator + greek_latin = Transliterator::createInstance("Greek-Latin"); + if (greek_latin == 0) { + printf("ERROR: Transliterator::createInstance() failed\n"); + exit(1); + } + + // Loop over various months + for (int32_t month = Calendar::JANUARY; + month <= Calendar::DECEMBER; + ++month) { + + // Set the calendar to a date + cal->clear(); + cal->set(1999, month, 4); + + // Format the date in default locale + str.remove(); + defFmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Date: "); + uprintf(escape(str)); + printf("\n"); + + // Format the date for Greece + str.remove(); + fmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Greek formatted date: "); + uprintf(escape(str)); + printf("\n"); + + // Transliterate result + greek_latin->transliterate(str); + printf("Transliterated via Greek-Latin: "); + uprintf(escape(str)); + printf("\n\n"); + } + + // Clean up + delete fmt; + delete cal; + delete greek_latin; + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/translit/answers/main_3.cpp b/Build/source/libs/icu/icu-xetex/samples/translit/answers/main_3.cpp new file mode 100644 index 00000000000..93065a252a0 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/translit/answers/main_3.cpp @@ -0,0 +1,112 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/translit.h" +#include "unicode/rbt.h" +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" +#include "unaccent.h" + +// RuleBasedTransliterator rules to remove accents from characters +// so they can be displayed as ASCIIx +UnicodeString UNACCENT_RULES( + "[\\u00C0-\\u00C5] > A;" + "[\\u00C8-\\u00CB] > E;" + "[\\u00CC-\\u00CF] > I;" + "[\\u00E0-\\u00E5] > a;" + "[\\u00E8-\\u00EB] > e;" + "[\\u00EC-\\u00EF] > i;" + ); + +int main(int argc, char **argv) { + + Calendar *cal; + DateFormat *fmt; + DateFormat *defFmt; + Transliterator *greek_latin; + Transliterator *rbtUnaccent; + UErrorCode status = U_ZERO_ERROR; + Locale greece("el", "GR"); + UnicodeString str, str2; + + // Create a calendar in the Greek locale + cal = Calendar::createInstance(greece, status); + check(status, "Calendar::createInstance"); + + // Create a formatter + fmt = DateFormat::createDateInstance(DateFormat::kFull, greece); + fmt->setCalendar(*cal); + + // Create a default formatter + defFmt = DateFormat::createDateInstance(DateFormat::kFull); + defFmt->setCalendar(*cal); + + // Create a Greek-Latin Transliterator + greek_latin = Transliterator::createInstance("Greek-Latin"); + if (greek_latin == 0) { + printf("ERROR: Transliterator::createInstance() failed\n"); + exit(1); + } + + // Create a custom Transliterator + rbtUnaccent = new RuleBasedTransliterator("RBTUnaccent", + UNACCENT_RULES, + UTRANS_FORWARD, + status); + check(status, "RuleBasedTransliterator::ct"); + + // Loop over various months + for (int32_t month = Calendar::JANUARY; + month <= Calendar::DECEMBER; + ++month) { + + // Set the calendar to a date + cal->clear(); + cal->set(1999, month, 4); + + // Format the date in default locale + str.remove(); + defFmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Date: "); + uprintf(escape(str)); + printf("\n"); + + // Format the date for Greece + str.remove(); + fmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Greek formatted date: "); + uprintf(escape(str)); + printf("\n"); + + // Transliterate result + greek_latin->transliterate(str); + printf("Transliterated via Greek-Latin: "); + uprintf(escape(str)); + printf("\n"); + + // Transliterate result + str2 = str; + rbtUnaccent->transliterate(str); + printf("Transliterated via RBT unaccent: "); + uprintf(escape(str)); + printf("\n\n"); + } + + // Clean up + delete fmt; + delete cal; + delete greek_latin; + delete rbtUnaccent; + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/translit/answers/main_4.cpp b/Build/source/libs/icu/icu-xetex/samples/translit/answers/main_4.cpp new file mode 100644 index 00000000000..5b51cb5672c --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/translit/answers/main_4.cpp @@ -0,0 +1,122 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/translit.h" +#include "unicode/rbt.h" +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" +#include "unaccent.h" + +// RuleBasedTransliterator rules to remove accents from characters +// so they can be displayed as ASCIIx +UnicodeString UNACCENT_RULES( + "[\\u00C0-\\u00C5] > A;" + "[\\u00C8-\\u00CB] > E;" + "[\\u00CC-\\u00CF] > I;" + "[\\u00E0-\\u00E5] > a;" + "[\\u00E8-\\u00EB] > e;" + "[\\u00EC-\\u00EF] > i;" + ); + +int main(int argc, char **argv) { + + Calendar *cal; + DateFormat *fmt; + DateFormat *defFmt; + Transliterator *greek_latin; + Transliterator *rbtUnaccent; + Transliterator *unaccent; + UErrorCode status = U_ZERO_ERROR; + Locale greece("el", "GR"); + UnicodeString str, str2; + + // Create a calendar in the Greek locale + cal = Calendar::createInstance(greece, status); + check(status, "Calendar::createInstance"); + + // Create a formatter + fmt = DateFormat::createDateInstance(DateFormat::kFull, greece); + fmt->setCalendar(*cal); + + // Create a default formatter + defFmt = DateFormat::createDateInstance(DateFormat::kFull); + defFmt->setCalendar(*cal); + + // Create a Greek-Latin Transliterator + greek_latin = Transliterator::createInstance("Greek-Latin"); + if (greek_latin == 0) { + printf("ERROR: Transliterator::createInstance() failed\n"); + exit(1); + } + + // Create a custom Transliterator + rbtUnaccent = new RuleBasedTransliterator("RBTUnaccent", + UNACCENT_RULES, + UTRANS_FORWARD, + status); + check(status, "RuleBasedTransliterator::ct"); + + // Create a custom Transliterator + unaccent = new UnaccentTransliterator(); + + // Loop over various months + for (int32_t month = Calendar::JANUARY; + month <= Calendar::DECEMBER; + ++month) { + + // Set the calendar to a date + cal->clear(); + cal->set(1999, month, 4); + + // Format the date in default locale + str.remove(); + defFmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Date: "); + uprintf(escape(str)); + printf("\n"); + + // Format the date for Greece + str.remove(); + fmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Greek formatted date: "); + uprintf(escape(str)); + printf("\n"); + + // Transliterate result + greek_latin->transliterate(str); + printf("Transliterated via Greek-Latin: "); + uprintf(escape(str)); + printf("\n"); + + // Transliterate result + str2 = str; + rbtUnaccent->transliterate(str); + printf("Transliterated via RBT unaccent: "); + uprintf(escape(str)); + printf("\n"); + + unaccent->transliterate(str2); + printf("Transliterated via normalizer unaccent: "); + uprintf(escape(str2)); + printf("\n\n"); + } + + // Clean up + delete fmt; + delete cal; + delete greek_latin; + delete unaccent; + delete rbtUnaccent; + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/translit/answers/unaccent.cpp b/Build/source/libs/icu/icu-xetex/samples/translit/answers/unaccent.cpp new file mode 100644 index 00000000000..8b9832d79b6 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/translit/answers/unaccent.cpp @@ -0,0 +1,54 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unaccent.h" + +/** + * Constructor + */ +UnaccentTransliterator::UnaccentTransliterator() : + normalizer("", Normalizer::DECOMP), + Transliterator("Unaccent", 0) { +} + +/** + * Destructor + */ +UnaccentTransliterator::~UnaccentTransliterator() { +} + +/** + * Remove accents from a character using Normalizer. + */ +UChar UnaccentTransliterator::unaccent(UChar c) const { + UnicodeString str(c); + UErrorCode status = U_ZERO_ERROR; + UnaccentTransliterator* t = (UnaccentTransliterator*)this; + + t->normalizer.setText(str, status); + if (U_FAILURE(status)) { + return c; + } + return (UChar) t->normalizer.next(); +} + +/** + * Implement Transliterator API + */ +void UnaccentTransliterator::handleTransliterate(Replaceable& text, + UTransPosition& index, + UBool incremental) const { + UnicodeString str("a"); + while (index.start < index.limit) { + UChar c = text.charAt(index.start); + UChar d = unaccent(c); + if (c != d) { + str.setCharAt(0, d); + text.handleReplaceBetween(index.start, index.start+1, str); + } + index.start++; + } +} diff --git a/Build/source/libs/icu/icu-xetex/samples/translit/answers/unaccent.h b/Build/source/libs/icu/icu-xetex/samples/translit/answers/unaccent.h new file mode 100644 index 00000000000..4cda092d58f --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/translit/answers/unaccent.h @@ -0,0 +1,41 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/translit.h" +#include "unicode/normlzr.h" + +class UnaccentTransliterator : public Transliterator { + + public: + + /** + * Constructor + */ + UnaccentTransliterator(); + + /** + * Destructor + */ + virtual ~UnaccentTransliterator(); + + protected: + + /** + * Implement Transliterator API + */ + virtual void handleTransliterate(Replaceable& text, + UTransPosition& index, + UBool incremental) const; + + private: + + /** + * Unaccent a single character using normalizer. + */ + UChar unaccent(UChar c) const; + + Normalizer normalizer; +}; diff --git a/Build/source/libs/icu/icu-xetex/samples/translit/main.cpp b/Build/source/libs/icu/icu-xetex/samples/translit/main.cpp new file mode 100644 index 00000000000..5bf46717ff1 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/translit/main.cpp @@ -0,0 +1,124 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2003, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/translit.h" +//#include "unicode/rbt.h" +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" +#include "unaccent.h" + +// RuleBasedTransliterator rules to remove accents from characters +// so they can be displayed as ASCIIx +UnicodeString UNACCENT_RULES( + "[\\u00C0-\\u00C5] > A;" + "[\\u00C8-\\u00CB] > E;" + "[\\u00CC-\\u00CF] > I;" + "[\\u00E0-\\u00E5] > a;" + "[\\u00E8-\\u00EB] > e;" + "[\\u00EC-\\u00EF] > i;" + ); + +int main(int argc, char **argv) { + + Calendar *cal; + DateFormat *fmt; + DateFormat *defFmt; + Transliterator *greek_latin; + Transliterator *rbtUnaccent; + Transliterator *unaccent; + UParseError pError; + UErrorCode status = U_ZERO_ERROR; + Locale greece("el", "GR"); + UnicodeString str, str2; + + // Create a calendar in the Greek locale + cal = Calendar::createInstance(greece, status); + check(status, "Calendar::createInstance"); + + // Create a formatter + fmt = DateFormat::createDateInstance(DateFormat::kFull, greece); + fmt->setCalendar(*cal); + + // Create a default formatter + defFmt = DateFormat::createDateInstance(DateFormat::kFull); + defFmt->setCalendar(*cal); + + // Create a Greek-Latin Transliterator + greek_latin = Transliterator::createInstance("Greek-Latin", UTRANS_FORWARD, status); + if (greek_latin == 0) { + printf("ERROR: Transliterator::createInstance() failed\n"); + exit(1); + } + + // Create a custom Transliterator + rbtUnaccent = Transliterator::createFromRules("RBTUnaccent", + UNACCENT_RULES, + UTRANS_FORWARD, + pError, + status); + check(status, "Transliterator::createFromRules"); + + // Create a custom Transliterator + unaccent = new UnaccentTransliterator(); + + // Loop over various months + for (int32_t month = Calendar::JANUARY; + month <= Calendar::DECEMBER; + ++month) { + + // Set the calendar to a date + cal->clear(); + cal->set(1999, month, 4); + + // Format the date in default locale + str.remove(); + defFmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Date: "); + uprintf(escape(str)); + printf("\n"); + + // Format the date for Greece + str.remove(); + fmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Greek formatted date: "); + uprintf(escape(str)); + printf("\n"); + + // Transliterate result + greek_latin->transliterate(str); + printf("Transliterated via Greek-Latin: "); + uprintf(escape(str)); + printf("\n"); + + // Transliterate result + str2 = str; + rbtUnaccent->transliterate(str); + printf("Transliterated via RBT unaccent: "); + uprintf(escape(str)); + printf("\n"); + + unaccent->transliterate(str2); + printf("Transliterated via normalizer unaccent: "); + uprintf(escape(str2)); + printf("\n\n"); + } + + // Clean up + delete fmt; + delete cal; + delete greek_latin; + delete unaccent; + delete rbtUnaccent; + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/translit/translit.sln b/Build/source/libs/icu/icu-xetex/samples/translit/translit.sln new file mode 100644 index 00000000000..1addab69a9b --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/translit/translit.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translit", "translit.vcproj", "{D1BEC124-303A-4F44-BA70-55769B8FE96A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Debug|Win32.ActiveCfg = Debug|Win32 + {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Debug|Win32.Build.0 = Debug|Win32 + {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Release|Win32.ActiveCfg = Release|Win32 + {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/translit/translit.vcproj b/Build/source/libs/icu/icu-xetex/samples/translit/translit.vcproj new file mode 100644 index 00000000000..fb3904ee67a --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/translit/translit.vcproj @@ -0,0 +1,235 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="translit" + ProjectGUID="{D1BEC124-303A-4F44-BA70-55769B8FE96A}" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <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" + TypeLibraryName=".\Debug/translit.tlb" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Debug/translit.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/translit.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/translit.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="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" + TypeLibraryName=".\Release/translit.tlb" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE" + StringPooling="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Release/translit.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/translit.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + ProgramDatabaseFile=".\Release/translit.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=".\main.cpp" + > + </File> + <File + RelativePath=".\unaccent.cpp" + > + </File> + <File + RelativePath=".\util.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl" + > + <File + RelativePath=".\unaccent.h" + > + </File> + </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/translit/unaccent.cpp b/Build/source/libs/icu/icu-xetex/samples/translit/unaccent.cpp new file mode 100644 index 00000000000..d3af7f35df7 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/translit/unaccent.cpp @@ -0,0 +1,56 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2003, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unaccent.h" + +const char UnaccentTransliterator::fgClassID = 0; + +/** + * Constructor + */ +UnaccentTransliterator::UnaccentTransliterator() : + normalizer("", UNORM_NFD), + Transliterator("Unaccent", 0) { +} + +/** + * Destructor + */ +UnaccentTransliterator::~UnaccentTransliterator() { +} + +/** + * Remove accents from a character using Normalizer. + */ +UChar UnaccentTransliterator::unaccent(UChar c) const { + UnicodeString str(c); + UErrorCode status = U_ZERO_ERROR; + UnaccentTransliterator* t = (UnaccentTransliterator*)this; + + t->normalizer.setText(str, status); + if (U_FAILURE(status)) { + return c; + } + return (UChar) t->normalizer.next(); +} + +/** + * Implement Transliterator API + */ +void UnaccentTransliterator::handleTransliterate(Replaceable& text, + UTransPosition& index, + UBool incremental) const { + UnicodeString str("a"); + while (index.start < index.limit) { + UChar c = text.charAt(index.start); + UChar d = unaccent(c); + if (c != d) { + str.setCharAt(0, d); + text.handleReplaceBetween(index.start, index.start+1, str); + } + index.start++; + } +} diff --git a/Build/source/libs/icu/icu-xetex/samples/translit/unaccent.h b/Build/source/libs/icu/icu-xetex/samples/translit/unaccent.h new file mode 100644 index 00000000000..10ee9d9096b --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/translit/unaccent.h @@ -0,0 +1,89 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2003, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/translit.h" +#include "unicode/normlzr.h" + +class UnaccentTransliterator : public Transliterator { + + public: + + /** + * Constructor + */ + UnaccentTransliterator(); + + /** + * Destructor + */ + virtual ~UnaccentTransliterator(); + + protected: + + /** + * Implement Transliterator API + */ + virtual void handleTransliterate(Replaceable& text, + UTransPosition& index, + UBool incremental) const; + + private: + + /** + * Unaccent a single character using normalizer. + */ + UChar unaccent(UChar c) const; + + Normalizer normalizer; + +public: + + /** + * Return the class ID for this class. This is useful only for + * comparing to a return value from getDynamicClassID(). For example: + * <pre> + * . Base* polymorphic_pointer = createPolymorphicObject(); + * . if (polymorphic_pointer->getDynamicClassID() == + * . Derived::getStaticClassID()) ... + * </pre> + * @return The class ID for all objects of this class. + * @stable ICU 2.0 + */ + static inline UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }; + + /** + * Returns a unique class ID <b>polymorphically</b>. This method + * is to implement a simple version of RTTI, since not all C++ + * compilers support genuine RTTI. Polymorphic operator==() and + * clone() methods call this method. + * + * <p>Concrete subclasses of Transliterator that wish clients to + * be able to identify them should implement getDynamicClassID() + * and also a static method and data member: + * + * <pre> + * static UClassID getStaticClassID() { return (UClassID)&fgClassID; } + * static char fgClassID; + * </pre> + * + * Subclasses that do not implement this method will have a + * dynamic class ID of Transliterator::getStatisClassID(). + * + * @return The class ID for this object. All objects of a given + * class have the same class ID. Objects of other classes have + * different class IDs. + * @stable ICU 2.0 + */ + virtual UClassID getDynamicClassID(void) const { return getStaticClassID(); }; + +private: + + /** + * Class identifier for subclasses of Transliterator that do not + * define their class (anonymous subclasses). + */ + static const char fgClassID; +}; diff --git a/Build/source/libs/icu/icu-xetex/samples/translit/util.cpp b/Build/source/libs/icu/icu-xetex/samples/translit/util.cpp new file mode 100644 index 00000000000..25a8f0224d4 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/translit/util.cpp @@ -0,0 +1,63 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include <stdio.h> +#include <stdlib.h> + +// Verify that a UErrorCode is successful; exit(1) if not +void check(UErrorCode& status, const char* msg) { + if (U_FAILURE(status)) { + printf("ERROR: %s (%s)\n", u_errorName(status), msg); + exit(1); + } + // printf("Ok: %s\n", msg); +} + +// Append a hex string to the target +static UnicodeString& appendHex(uint32_t number, + int8_t digits, + UnicodeString& target) { + static const UnicodeString DIGIT_STRING("0123456789ABCDEF"); + while (digits > 0) { + target += DIGIT_STRING[(number >> ((--digits) * 4)) & 0xF]; + } + return target; +} + +// Replace nonprintable characters with unicode escapes +UnicodeString escape(const UnicodeString &source) { + int32_t i; + UnicodeString target; + target += "\""; + for (i=0; i<source.length(); ++i) { + UChar ch = source[i]; + if (ch < 0x09 || (ch > 0x0A && ch < 0x20) || ch > 0x7E) { + target += "\\u"; + appendHex(ch, 4, target); + } else { + target += ch; + } + } + target += "\""; + return target; +} + +// Print the given string to stdout +void uprintf(const UnicodeString &str) { + char *buf = 0; + int32_t len = str.length(); + // int32_t bufLen = str.extract(0, len, buf); // Preflight + /* Preflighting seems to be broken now, so assume 1-1 conversion, + plus some slop. */ + int32_t bufLen = len + 16; + int32_t actualLen; + buf = new char[bufLen + 1]; + actualLen = str.extract(0, len, buf/*, bufLen*/); // Default codepage conversion + buf[actualLen] = 0; + printf("%s", buf); + delete buf; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/translit/util.h b/Build/source/libs/icu/icu-xetex/samples/translit/util.h new file mode 100644 index 00000000000..2d9c4c724e2 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/translit/util.h @@ -0,0 +1,16 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" + +// Verify that a UErrorCode is successful; exit(1) if not +void check(UErrorCode& status, const char* msg); + +// Replace nonprintable characters with unicode escapes +UnicodeString escape(const UnicodeString &source); + +// Print the given string to stdout +void uprintf(const UnicodeString &str); diff --git a/Build/source/libs/icu/icu-xetex/samples/uciter8/Makefile b/Build/source/libs/icu/icu-xetex/samples/uciter8/Makefile new file mode 100644 index 00000000000..d89eee2cc58 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/uciter8/Makefile @@ -0,0 +1,20 @@ +# 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 + +# Name of your target +TARGET=uciter8 + +# All object files (C or C++) +OBJECTS=uciter8.o uit_len8.o + +# 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/uciter8/readme.txt b/Build/source/libs/icu/icu-xetex/samples/uciter8/readme.txt new file mode 100644 index 00000000000..320154a2881 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/uciter8/readme.txt @@ -0,0 +1,73 @@ +Copyright (c) 2003-2005, International Business Machines Corporation and others. All Rights Reserved. +uciter8: Lenient reading of 8-bit Unicode with a UCharIterator + +This sample demonstrates reading +8-bit Unicode text leniently, accepting a mix of UTF-8 and CESU-8 +and also accepting single surrogates. +UTF-8-style macros are defined as well as a UCharIterator. +The macros are incomplete (do not assemble code points from pairs of surrogates) +but sufficient for the iterator. + +If you wish to use the lenient-UTF/CESU-8 UCharIterator in a context outside of +this sample, then copy the uit_len8.c file, +as well as either the uit_len8.h header or just the prototype that it contains. + +*** Warning: *** +This UCharIterator reads an arbitrary mix of UTF-8 and CESU-8 text. +It does not conform to any one Unicode charset specification, +and its use may lead to security risks. + + +Files: + uciter8.c Main source file in C + uit_len8.c Lenient-UTF/CESU-8 UCharIterator implementation + uit_len8.h Header file with the prototoype for the lenient-UTF/CESU-8 UCharIterator + uciter8.sln Windows MSVC workspace. Double-click this to get started. + uciter8.vcproj Windows MSVC project file + +To Build uciter8 on Windows + 1. Install and build ICU + 2. In MSVC, open the workspace file icu\samples\uciter8\uciter8.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 uciter8 directory, e.g. + cd c:\icu\source\samples\uciter8\debug + 4. Run it + uciter8 + +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/uciter8 + gmake ICU_PREFIX=<icu install directory) + +To Run on Unixes + cd <icu directory>/source/samples/uciter8 + + gmake ICU_PREFIX=<icu install directory> check + -or- + + export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH + uciter8 + + + 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/uciter8/uciter8.c b/Build/source/libs/icu/icu-xetex/samples/uciter8/uciter8.c new file mode 100644 index 00000000000..6c705538f64 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/uciter8/uciter8.c @@ -0,0 +1,356 @@ +/* +******************************************************************************* +* +* Copyright (C) 2003-2007, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +* file name: uciter8.c +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:4 +* +* created on: 2003jan10 +* created by: Markus W. Scherer +* +* This file contains sample code that illustrates reading +* 8-bit Unicode text leniently, accepting a mix of UTF-8 and CESU-8 +* and also accepting single surrogates. +*/ + +#include <stdio.h> +#include <string.h> +#include "unicode/utypes.h" +#include "unicode/uiter.h" +#include "uit_len8.h" + +#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0])) + +#define log_err printf + +/* UCharIterator test ------------------------------------------------------- */ + +/* + * The following code is a copy of the UCharIterator test code in + * source/test/cintltst/custrtst.c, + * testing the lenient-8 iterator instead of the UTF-8 one. + */ + +/* + * Compare results from two iterators, should be same. + * Assume that the text is not empty and that + * iteration start==0 and iteration limit==length. + */ +static void +compareIterators(UCharIterator *iter1, const char *n1, + UCharIterator *iter2, const char *n2) { + int32_t i, pos1, pos2, middle, length; + UChar32 c1, c2; + + /* compare lengths */ + length=iter1->getIndex(iter1, UITER_LENGTH); + pos2=iter2->getIndex(iter2, UITER_LENGTH); + if(length!=pos2) { + log_err("%s->getIndex(length)=%d != %d=%s->getIndex(length)\n", n1, length, pos2, n2); + return; + } + + /* set into the middle */ + middle=length/2; + + pos1=iter1->move(iter1, middle, UITER_ZERO); + if(pos1!=middle) { + log_err("%s->move(from 0 to middle %d)=%d does not move to the middle\n", n1, middle, pos1); + return; + } + + pos2=iter2->move(iter2, middle, UITER_ZERO); + if(pos2!=middle) { + log_err("%s->move(from 0 to middle %d)=%d does not move to the middle\n", n2, middle, pos2); + return; + } + + /* test current() */ + c1=iter1->current(iter1); + c2=iter2->current(iter2); + if(c1!=c2) { + log_err("%s->current()=U+%04x != U+%04x=%s->current() at middle=%d\n", n1, c1, c2, n2, middle); + return; + } + + /* move forward 3 UChars */ + for(i=0; i<3; ++i) { + c1=iter1->next(iter1); + c2=iter2->next(iter2); + if(c1!=c2) { + log_err("%s->next()=U+%04x != U+%04x=%s->next() at %d (started in middle)\n", n1, c1, c2, n2, iter1->getIndex(iter1, UITER_CURRENT)); + return; + } + } + + /* move backward 5 UChars */ + for(i=0; i<5; ++i) { + c1=iter1->previous(iter1); + c2=iter2->previous(iter2); + if(c1!=c2) { + log_err("%s->previous()=U+%04x != U+%04x=%s->previous() at %d (started in middle)\n", n1, c1, c2, n2, iter1->getIndex(iter1, UITER_CURRENT)); + return; + } + } + + /* iterate forward from the beginning */ + pos1=iter1->move(iter1, 0, UITER_START); + if(pos1<0) { + log_err("%s->move(start) failed\n", n1); + return; + } + if(!iter1->hasNext(iter1)) { + log_err("%s->hasNext() at the start returns FALSE\n", n1); + return; + } + + pos2=iter2->move(iter2, 0, UITER_START); + if(pos2<0) { + log_err("%s->move(start) failed\n", n2); + return; + } + if(!iter2->hasNext(iter2)) { + log_err("%s->hasNext() at the start returns FALSE\n", n2); + return; + } + + do { + c1=iter1->next(iter1); + c2=iter2->next(iter2); + if(c1!=c2) { + log_err("%s->next()=U+%04x != U+%04x=%s->next() at %d\n", n1, c1, c2, n2, iter1->getIndex(iter1, UITER_CURRENT)); + return; + } + } while(c1>=0); + + if(iter1->hasNext(iter1)) { + log_err("%s->hasNext() at the end returns TRUE\n", n1); + return; + } + if(iter2->hasNext(iter2)) { + log_err("%s->hasNext() at the end returns TRUE\n", n2); + return; + } + + /* back to the middle */ + pos1=iter1->move(iter1, middle, UITER_ZERO); + if(pos1!=middle) { + log_err("%s->move(from end to middle %d)=%d does not move to the middle\n", n1, middle, pos1); + return; + } + + pos2=iter2->move(iter2, middle, UITER_ZERO); + if(pos2!=middle) { + log_err("%s->move(from end to middle %d)=%d does not move to the middle\n", n2, middle, pos2); + return; + } + + /* move to index 1 */ + pos1=iter1->move(iter1, 1, UITER_ZERO); + if(pos1!=1) { + log_err("%s->move(from middle %d to 1)=%d does not move to 1\n", n1, middle, pos1); + return; + } + + pos2=iter2->move(iter2, 1, UITER_ZERO); + if(pos2!=1) { + log_err("%s->move(from middle %d to 1)=%d does not move to 1\n", n2, middle, pos2); + return; + } + + /* iterate backward from the end */ + pos1=iter1->move(iter1, 0, UITER_LIMIT); + if(pos1<0) { + log_err("%s->move(limit) failed\n", n1); + return; + } + if(!iter1->hasPrevious(iter1)) { + log_err("%s->hasPrevious() at the end returns FALSE\n", n1); + return; + } + + pos2=iter2->move(iter2, 0, UITER_LIMIT); + if(pos2<0) { + log_err("%s->move(limit) failed\n", n2); + return; + } + if(!iter2->hasPrevious(iter2)) { + log_err("%s->hasPrevious() at the end returns FALSE\n", n2); + return; + } + + do { + c1=iter1->previous(iter1); + c2=iter2->previous(iter2); + if(c1!=c2) { + log_err("%s->previous()=U+%04x != U+%04x=%s->previous() at %d\n", n1, c1, c2, n2, iter1->getIndex(iter1, UITER_CURRENT)); + return; + } + } while(c1>=0); + + if(iter1->hasPrevious(iter1)) { + log_err("%s->hasPrevious() at the start returns TRUE\n", n1); + return; + } + if(iter2->hasPrevious(iter2)) { + log_err("%s->hasPrevious() at the start returns TRUE\n", n2); + return; + } +} + +/* + * Test the iterator's getState() and setState() functions. + * iter1 and iter2 must be set up for the same iterator type and the same string + * but may be physically different structs (different addresses). + * + * Assume that the text is not empty and that + * iteration start==0 and iteration limit==length. + * It must be 2<=middle<=length-2. + */ +static void +testIteratorState(UCharIterator *iter1, UCharIterator *iter2, const char *n, int32_t middle) { + UChar32 u[4]; + + UErrorCode errorCode; + UChar32 c; + uint32_t state; + int32_t i, j; + + /* get four UChars from the middle of the string */ + iter1->move(iter1, middle-2, UITER_ZERO); + for(i=0; i<4; ++i) { + c=iter1->next(iter1); + if(c<0) { + /* the test violates the assumptions, see comment above */ + log_err("test error: %s[%d]=%d\n", n, middle-2+i, c); + return; + } + u[i]=c; + } + + /* move to the middle and get the state */ + iter1->move(iter1, -2, UITER_CURRENT); + state=uiter_getState(iter1); + + /* set the state into the second iterator and compare the results */ + errorCode=U_ZERO_ERROR; + uiter_setState(iter2, state, &errorCode); + if(U_FAILURE(errorCode)) { + log_err("%s->setState(0x%x) failed: %s\n", n, state, u_errorName(errorCode)); + return; + } + + c=iter2->current(iter2); + if(c!=u[2]) { + log_err("%s->current(at %d)=U+%04x!=U+%04x\n", n, middle, c, u[2]); + } + + c=iter2->previous(iter2); + if(c!=u[1]) { + log_err("%s->previous(at %d)=U+%04x!=U+%04x\n", n, middle-1, c, u[1]); + } + + iter2->move(iter2, 2, UITER_CURRENT); + c=iter2->next(iter2); + if(c!=u[3]) { + log_err("%s->next(at %d)=U+%04x!=U+%04x\n", n, middle+1, c, u[3]); + } + + iter2->move(iter2, -3, UITER_CURRENT); + c=iter2->previous(iter2); + if(c!=u[0]) { + log_err("%s->previous(at %d)=U+%04x!=U+%04x\n", n, middle-2, c, u[0]); + } + + /* move the second iterator back to the middle */ + iter2->move(iter2, 1, UITER_CURRENT); + iter2->next(iter2); + + /* check that both are in the middle */ + i=iter1->getIndex(iter1, UITER_CURRENT); + j=iter2->getIndex(iter2, UITER_CURRENT); + if(i!=middle) { + log_err("%s->getIndex(current)=%d!=%d as expected\n", n, i, middle); + } + if(i!=j) { + log_err("%s->getIndex(current)=%d!=%d after setState()\n", n, j, i); + } + + /* compare lengths */ + i=iter1->getIndex(iter1, UITER_LENGTH); + j=iter2->getIndex(iter2, UITER_LENGTH); + if(i!=j) { + log_err("%s->getIndex(length)=%d!=%d before/after setState()\n", n, i, j); + } +} + +static void +TestLenient8Iterator() { + static const UChar text[]={ + 0x61, 0x62, 0x63, + /* dffd 107fd d801 dffd - in UTF-16, U+107fd=<d801 dffd> */ + 0xdffd, 0xd801, 0xdffd, 0xd801, 0xdffd, + 0x78, 0x79, 0x7a, 0 + }; + static const uint8_t bytes[]={ + 0x61, 0x62, 0x63, + /* dffd 107fd d801 dffd - mixture */ + 0xed, 0xbf, 0xbd, 0xf0, 0x90, 0x9f, 0xbd, 0xed, 0xa0, 0x81, 0xed, 0xbf, 0xbd, + 0x78, 0x79, 0x7a, 0 + }; + + UCharIterator iter1, iter2; + UChar32 c1, c2; + int32_t length; + + puts("test a UCharIterator for lenient 8-bit Unicode (accept single surrogates)"); + + /* compare the same string between UTF-16 and lenient-8 UCharIterators */ + uiter_setString(&iter1, text, -1); + uiter_setLenient8(&iter2, (const char *)bytes, sizeof(bytes)-1); + compareIterators(&iter1, "UTF16Iterator", &iter2, "Lenient8Iterator"); + + /* try again with length=-1 */ + uiter_setLenient8(&iter2, (const char *)bytes, -1); + compareIterators(&iter1, "UTF16Iterator", &iter2, "Lenient8Iterator_1"); + + /* test get/set state */ + length=LENGTHOF(text)-1; + uiter_setLenient8(&iter1, (const char*)bytes, -1); + testIteratorState(&iter1, &iter2, "Lenient8IteratorState", length/2); + testIteratorState(&iter1, &iter2, "Lenient8IteratorStatePlus1", length/2+1); + + /* ---------------------------------------------------------------------- */ + + puts("no output so far means that the lenient-8 iterator works fine"); + + puts("iterate forward:\nUTF-16\tlenient-8"); + uiter_setString(&iter1, text, -1); + iter1.move(&iter1, 0, UITER_START); + iter2.move(&iter2, 0, UITER_START); + for(;;) { + c1=iter1.next(&iter1); + c2=iter2.next(&iter2); + if(c1<0 && c2<0) { + break; + } + if(c1<0) { + printf("\t%04x\n", c2); + } else if(c2<0) { + printf("%04x\n", c1); + } else { + printf("%04x\t%04x\n", c1, c2); + } + } +} + +extern int +main(int argc, const char *argv[]) { + TestLenient8Iterator(); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/uciter8/uciter8.sln b/Build/source/libs/icu/icu-xetex/samples/uciter8/uciter8.sln new file mode 100644 index 00000000000..8ea4dc279c4 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/uciter8/uciter8.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uciter8", "uciter8.vcproj", "{94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}.Debug|Win32.ActiveCfg = Debug|Win32 + {94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}.Debug|Win32.Build.0 = Debug|Win32 + {94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}.Release|Win32.ActiveCfg = Release|Win32 + {94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/uciter8/uciter8.vcproj b/Build/source/libs/icu/icu-xetex/samples/uciter8/uciter8.vcproj new file mode 100644 index 00000000000..0957f8009af --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/uciter8/uciter8.vcproj @@ -0,0 +1,231 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="uciter8" + ProjectGUID="{94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <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" + TypeLibraryName=".\Debug/uciter8.tlb" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Debug/uciter8.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" + OutputFile=".\Debug/uciter8.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/uciter8.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="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" + TypeLibraryName=".\Release/uciter8.tlb" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE" + StringPooling="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Release/uciter8.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" + OutputFile=".\Release/uciter8.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + ProgramDatabaseFile=".\Release/uciter8.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=".\uciter8.c" + > + </File> + <File + RelativePath=".\uit_len8.c" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl" + > + <File + RelativePath=".\uit_len8.h" + > + </File> + </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/uciter8/uit_len8.c b/Build/source/libs/icu/icu-xetex/samples/uciter8/uit_len8.c new file mode 100644 index 00000000000..16fa487c642 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/uciter8/uit_len8.c @@ -0,0 +1,556 @@ +/* +******************************************************************************* +* +* Copyright (C) 2003-2006, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +* file name: uit_len8.c +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:4 +* +* created on: 2003feb10 +* created by: Markus W. Scherer +* +* This file contains the implementation of the "lenient UTF-8" UCharIterator +* as used in the uciter8 sample code. +* UTF-8-style macros are defined as well as the UCharIterator. +* The macros are incomplete (do not assemble code points from pairs of +* surrogates, see comment below) +* but sufficient for the iterator. +*/ + +#include <string.h> +#include "unicode/utypes.h" +#include "unicode/uiter.h" + +/* lenient UTF-8/CESU-8 macros ---------------------------------------------- */ + +/* + * This code leniently reads 8-bit Unicode strings, + * which could contain a mix of UTF-8 and CESU-8. + * More precisely: + * - supplementary code points may be encoded with dedicated 4-byte sequences + * (UTF-8 style) + * - supplementary code points may be encoded with + * pairs of 3-byte sequences, one for each surrogate of the UTF-16 form + * (CESU-8 style) + * - single surrogates are allowed, encoded with their "natural" 3-byte sequences + * + * Limitation: + * Right now, the macros do not attempt to assemble code points from pairs of + * separately encoded surrogates. + * This would not be sufficient for processing based on these macros, + * but it is sufficient for a UCharIterator that returns only UChars anyway. + * + * The code is copied and modified from utf_impl.c and utf8.h. + * + * Change 2006feb08: Much of the implementation code is replaced by calling + * the utf_impl.c functions which accept a new "strict" parameter value + * of -2 implementing exactly this leniency. + */ + +#define L8_NEXT(s, i, length, c) { \ + (c)=(uint8_t)(s)[(i)++]; \ + if((c)>=0x80) { \ + if(U8_IS_LEAD(c)) { \ + (c)=utf8_nextCharSafeBody((const uint8_t *)s, &(i), (int32_t)(length), c, -2); \ + } else { \ + (c)=U_SENTINEL; \ + } \ + } \ +} + +#define L8_PREV(s, start, i, c) { \ + (c)=(uint8_t)(s)[--(i)]; \ + if((c)>=0x80) { \ + if((c)<=0xbf) { \ + (c)=utf8_prevCharSafeBody((const uint8_t *)s, start, &(i), c, -2); \ + } else { \ + (c)=U_SENTINEL; \ + } \ + } \ +} + +/* lenient-8 UCharIterator -------------------------------------------------- */ + +/* + * This is a copy of the UTF-8 UCharIterator in uiter.cpp, + * except that it uses the lenient-8-bit-Unicode macros above. + */ + +/* + * Minimal implementation: + * Maintain a single-UChar buffer for an additional surrogate. + * The caller must not modify start and limit because they are used internally. + * + * Use UCharIterator fields as follows: + * context pointer to UTF-8 string + * length UTF-16 length of the string; -1 until lazy evaluation + * start current UTF-8 index + * index current UTF-16 index; may be -1="unknown" after setState() + * limit UTF-8 length of the string + * reservedField supplementary code point + * + * Since UCharIterator delivers 16-bit code units, the iteration can be + * currently in the middle of the byte sequence for a supplementary code point. + * In this case, reservedField will contain that code point and start will + * point to after the corresponding byte sequence. The UTF-16 index will be + * one less than what it would otherwise be corresponding to the UTF-8 index. + * Otherwise, reservedField will be 0. + */ + +/* + * Possible optimization for NUL-terminated UTF-8 and UTF-16 strings: + * Add implementations that do not call strlen() for iteration but check for NUL. + */ + +static int32_t U_CALLCONV +lenient8IteratorGetIndex(UCharIterator *iter, UCharIteratorOrigin origin) { + switch(origin) { + case UITER_ZERO: + case UITER_START: + return 0; + case UITER_CURRENT: + if(iter->index<0) { + /* the current UTF-16 index is unknown after setState(), count from the beginning */ + const uint8_t *s; + UChar32 c; + int32_t i, limit, index; + + s=(const uint8_t *)iter->context; + i=index=0; + limit=iter->start; /* count up to the UTF-8 index */ + while(i<limit) { + L8_NEXT(s, i, limit, c); + if(c<=0xffff) { + ++index; + } else { + index+=2; + } + } + + iter->start=i; /* just in case setState() did not get us to a code point boundary */ + if(i==iter->limit) { + iter->length=index; /* in case it was <0 or wrong */ + } + if(iter->reservedField!=0) { + --index; /* we are in the middle of a supplementary code point */ + } + iter->index=index; + } + return iter->index; + case UITER_LIMIT: + case UITER_LENGTH: + if(iter->length<0) { + const uint8_t *s; + UChar32 c; + int32_t i, limit, length; + + s=(const uint8_t *)iter->context; + if(iter->index<0) { + /* + * the current UTF-16 index is unknown after setState(), + * we must first count from the beginning to here + */ + i=length=0; + limit=iter->start; + + /* count from the beginning to the current index */ + while(i<limit) { + L8_NEXT(s, i, limit, c); + if(c<=0xffff) { + ++length; + } else { + length+=2; + } + } + + /* assume i==limit==iter->start, set the UTF-16 index */ + iter->start=i; /* just in case setState() did not get us to a code point boundary */ + iter->index= iter->reservedField!=0 ? length-1 : length; + } else { + i=iter->start; + length=iter->index; + if(iter->reservedField!=0) { + ++length; + } + } + + /* count from the current index to the end */ + limit=iter->limit; + while(i<limit) { + L8_NEXT(s, i, limit, c); + if(c<=0xffff) { + ++length; + } else { + length+=2; + } + } + iter->length=length; + } + return iter->length; + default: + /* not a valid origin */ + /* Should never get here! */ + return -1; + } +} + +static int32_t U_CALLCONV +lenient8IteratorMove(UCharIterator *iter, int32_t delta, UCharIteratorOrigin origin) { + const uint8_t *s; + UChar32 c; + int32_t pos; /* requested UTF-16 index */ + int32_t i; /* UTF-8 index */ + UBool havePos; + + /* calculate the requested UTF-16 index */ + switch(origin) { + case UITER_ZERO: + case UITER_START: + pos=delta; + havePos=TRUE; + /* iter->index<0 (unknown) is possible */ + break; + case UITER_CURRENT: + if(iter->index>=0) { + pos=iter->index+delta; + havePos=TRUE; + } else { + /* the current UTF-16 index is unknown after setState(), use only delta */ + pos=0; + havePos=FALSE; + } + break; + case UITER_LIMIT: + case UITER_LENGTH: + if(iter->length>=0) { + pos=iter->length+delta; + havePos=TRUE; + } else { + /* pin to the end, avoid counting the length */ + iter->index=-1; + iter->start=iter->limit; + iter->reservedField=0; + if(delta>=0) { + return UITER_UNKNOWN_INDEX; + } else { + /* the current UTF-16 index is unknown, use only delta */ + pos=0; + havePos=FALSE; + } + } + break; + default: + return -1; /* Error */ + } + + if(havePos) { + /* shortcuts: pinning to the edges of the string */ + if(pos<=0) { + iter->index=iter->start=iter->reservedField=0; + return 0; + } else if(iter->length>=0 && pos>=iter->length) { + iter->index=iter->length; + iter->start=iter->limit; + iter->reservedField=0; + return iter->index; + } + + /* minimize the number of L8_NEXT/PREV operations */ + if(iter->index<0 || pos<iter->index/2) { + /* go forward from the start instead of backward from the current index */ + iter->index=iter->start=iter->reservedField=0; + } else if(iter->length>=0 && (iter->length-pos)<(pos-iter->index)) { + /* + * if we have the UTF-16 index and length and the new position is + * closer to the end than the current index, + * then go backward from the end instead of forward from the current index + */ + iter->index=iter->length; + iter->start=iter->limit; + iter->reservedField=0; + } + + delta=pos-iter->index; + if(delta==0) { + return iter->index; /* nothing to do */ + } + } else { + /* move relative to unknown UTF-16 index */ + if(delta==0) { + return UITER_UNKNOWN_INDEX; /* nothing to do */ + } else if(-delta>=iter->start) { + /* moving backwards by more UChars than there are UTF-8 bytes, pin to 0 */ + iter->index=iter->start=iter->reservedField=0; + return 0; + } else if(delta>=(iter->limit-iter->start)) { + /* moving forward by more UChars than the remaining UTF-8 bytes, pin to the end */ + iter->index=iter->length; /* may or may not be <0 (unknown) */ + iter->start=iter->limit; + iter->reservedField=0; + return iter->index>=0 ? iter->index : UITER_UNKNOWN_INDEX; + } + } + + /* delta!=0 */ + + /* move towards the requested position, pin to the edges of the string */ + s=(const uint8_t *)iter->context; + pos=iter->index; /* could be <0 (unknown) */ + i=iter->start; + if(delta>0) { + /* go forward */ + int32_t limit=iter->limit; + if(iter->reservedField!=0) { + iter->reservedField=0; + ++pos; + --delta; + } + while(delta>0 && i<limit) { + L8_NEXT(s, i, limit, c); + if(c<0xffff) { + ++pos; + --delta; + } else if(delta>=2) { + pos+=2; + delta-=2; + } else /* delta==1 */ { + /* stop in the middle of a supplementary code point */ + iter->reservedField=c; + ++pos; + break; /* delta=0; */ + } + } + if(i==limit) { + if(iter->length<0 && iter->index>=0) { + iter->length= iter->reservedField==0 ? pos : pos+1; + } else if(iter->index<0 && iter->length>=0) { + iter->index= iter->reservedField==0 ? iter->length : iter->length-1; + } + } + } else /* delta<0 */ { + /* go backward */ + if(iter->reservedField!=0) { + iter->reservedField=0; + i-=4; /* we stayed behind the supplementary code point; go before it now */ + --pos; + ++delta; + } + while(delta<0 && i>0) { + L8_PREV(s, 0, i, c); + if(c<0xffff) { + --pos; + ++delta; + } else if(delta<=-2) { + pos-=2; + delta+=2; + } else /* delta==-1 */ { + /* stop in the middle of a supplementary code point */ + i+=4; /* back to behind this supplementary code point for consistent state */ + iter->reservedField=c; + --pos; + break; /* delta=0; */ + } + } + } + + iter->start=i; + if(iter->index>=0) { + return iter->index=pos; + } else { + /* we started with index<0 (unknown) so pos is bogus */ + if(i<=1) { + return iter->index=i; /* reached the beginning */ + } else { + /* we still don't know the UTF-16 index */ + return UITER_UNKNOWN_INDEX; + } + } +} + +static UBool U_CALLCONV +lenient8IteratorHasNext(UCharIterator *iter) { + return iter->reservedField!=0 || iter->start<iter->limit; +} + +static UBool U_CALLCONV +lenient8IteratorHasPrevious(UCharIterator *iter) { + return iter->start>0; +} + +static UChar32 U_CALLCONV +lenient8IteratorCurrent(UCharIterator *iter) { + if(iter->reservedField!=0) { + return U16_TRAIL(iter->reservedField); + } else if(iter->start<iter->limit) { + const uint8_t *s=(const uint8_t *)iter->context; + UChar32 c; + int32_t i=iter->start; + + L8_NEXT(s, i, iter->limit, c); + if(c<0) { + return 0xfffd; + } else if(c<=0xffff) { + return c; + } else { + return U16_LEAD(c); + } + } else { + return U_SENTINEL; + } +} + +static UChar32 U_CALLCONV +lenient8IteratorNext(UCharIterator *iter) { + int32_t index; + + if(iter->reservedField!=0) { + UChar trail=U16_TRAIL(iter->reservedField); + iter->reservedField=0; + if((index=iter->index)>=0) { + iter->index=index+1; + } + return trail; + } else if(iter->start<iter->limit) { + const uint8_t *s=(const uint8_t *)iter->context; + UChar32 c; + + L8_NEXT(s, iter->start, iter->limit, c); + if((index=iter->index)>=0) { + iter->index=++index; + if(iter->length<0 && iter->start==iter->limit) { + iter->length= c<=0xffff ? index : index+1; + } + } else if(iter->start==iter->limit && iter->length>=0) { + iter->index= c<=0xffff ? iter->length : iter->length-1; + } + if(c<0) { + return 0xfffd; + } else if(c<=0xffff) { + return c; + } else { + iter->reservedField=c; + return U16_LEAD(c); + } + } else { + return U_SENTINEL; + } +} + +static UChar32 U_CALLCONV +lenient8IteratorPrevious(UCharIterator *iter) { + int32_t index; + + if(iter->reservedField!=0) { + UChar lead=U16_LEAD(iter->reservedField); + iter->reservedField=0; + iter->start-=4; /* we stayed behind the supplementary code point; go before it now */ + if((index=iter->index)>0) { + iter->index=index-1; + } + return lead; + } else if(iter->start>0) { + const uint8_t *s=(const uint8_t *)iter->context; + UChar32 c; + + L8_PREV(s, 0, iter->start, c); + if((index=iter->index)>0) { + iter->index=index-1; + } else if(iter->start<=1) { + iter->index= c<=0xffff ? iter->start : iter->start+1; + } + if(c<0) { + return 0xfffd; + } else if(c<=0xffff) { + return c; + } else { + iter->start+=4; /* back to behind this supplementary code point for consistent state */ + iter->reservedField=c; + return U16_TRAIL(c); + } + } else { + return U_SENTINEL; + } +} + +static uint32_t U_CALLCONV +lenient8IteratorGetState(const UCharIterator *iter) { + uint32_t state=(uint32_t)(iter->start<<1); + if(iter->reservedField!=0) { + state|=1; + } + return state; +} + +static void U_CALLCONV +lenient8IteratorSetState(UCharIterator *iter, uint32_t state, UErrorCode *pErrorCode) { + if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) { + /* do nothing */ + } else if(iter==NULL) { + *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; + } else if(state==lenient8IteratorGetState(iter)) { + /* setting to the current state: no-op */ + } else { + int32_t index=(int32_t)(state>>1); /* UTF-8 index */ + state&=1; /* 1 if in surrogate pair, must be index>=4 */ + + if((state==0 ? index<0 : index<4) || iter->limit<index) { + *pErrorCode=U_INDEX_OUTOFBOUNDS_ERROR; + } else { + iter->start=index; /* restore UTF-8 byte index */ + if(index<=1) { + iter->index=index; + } else { + iter->index=-1; /* unknown UTF-16 index */ + } + if(state==0) { + iter->reservedField=0; + } else { + /* verified index>=4 above */ + UChar32 c; + L8_PREV((const uint8_t *)iter->context, 0, index, c); + if(c<=0xffff) { + *pErrorCode=U_INDEX_OUTOFBOUNDS_ERROR; + } else { + iter->reservedField=c; + } + } + } + } +} + +static const UCharIterator lenient8Iterator={ + 0, 0, 0, 0, 0, 0, + lenient8IteratorGetIndex, + lenient8IteratorMove, + lenient8IteratorHasNext, + lenient8IteratorHasPrevious, + lenient8IteratorCurrent, + lenient8IteratorNext, + lenient8IteratorPrevious, + NULL, + lenient8IteratorGetState, + lenient8IteratorSetState +}; + +U_CAPI void U_EXPORT2 +uiter_setLenient8(UCharIterator *iter, const char *s, int32_t length) { + if(iter!=0) { + if(s!=0 && length>=-1) { + *iter=lenient8Iterator; + iter->context=s; + if(length>=0) { + iter->limit=length; + } else { + iter->limit=strlen(s); + } + iter->length= iter->limit<=1 ? iter->limit : -1; + } else { + /* set no-op iterator */ + uiter_setString(iter, NULL, 0); + } + } +} diff --git a/Build/source/libs/icu/icu-xetex/samples/uciter8/uit_len8.h b/Build/source/libs/icu/icu-xetex/samples/uciter8/uit_len8.h new file mode 100644 index 00000000000..35748ed4f5d --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/uciter8/uit_len8.h @@ -0,0 +1,29 @@ +/* +******************************************************************************* +* +* Copyright (C) 2003, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +* file name: uit_len8.h +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:4 +* +* created on: 2003feb10 +* created by: Markus W. Scherer +* +* This file contains the declaration for a "lenient UTF-8" UCharIterator +* as used in the uciter8 sample code. +*/ + +#ifndef __UIT_LEN8_H__ +#define __UIT_LEN8_H__ + +#include "unicode/utypes.h" +#include "unicode/uiter.h" + +U_CAPI void U_EXPORT2 +uiter_setLenient8(UCharIterator *iter, const char *s, int32_t length); + +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/ucnv/Makefile b/Build/source/libs/icu/icu-xetex/samples/ucnv/Makefile new file mode 100644 index 00000000000..77536b9946b --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ucnv/Makefile @@ -0,0 +1,23 @@ +# 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 + +# Name of your target +TARGET=convsamp + +# All object files (C or C++) +OBJECTS=convsamp.o flagcb.o + +# Load in standard makefile definitions +include ../defs.mk + +# extra files to clean up +CLEANFILES += *.out data40.utf16 data41.utf16 + +# the actual rules (this is a simple sample) +include ../rules.mk diff --git a/Build/source/libs/icu/icu-xetex/samples/ucnv/convsamp.cpp b/Build/source/libs/icu/icu-xetex/samples/ucnv/convsamp.cpp new file mode 100644 index 00000000000..70b43b6512b --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ucnv/convsamp.cpp @@ -0,0 +1,1102 @@ +/************************************************************************** +* +* Copyright (C) 2000-2003, International Business Machines +* Corporation and others. All Rights Reserved. +* +*************************************************************************** +* file name: convsamp.c +* encoding: ASCII (7-bit) +* +* created on: 2000may30 +* created by: Steven R. Loomis +* +* Sample code for the ICU conversion routines. +* +* Note: Nothing special is needed to build this sample. Link with +* the icu UC and icu I18N libraries. +* +* I use 'assert' for error checking, you probably will want +* something more flexible. '***BEGIN SAMPLE***' and +* '***END SAMPLE***' mark pieces suitable for stand alone +* code snippets. +* +* +* Each test can define it's own BUFFERSIZE +* +*/ + +#define DEBUG_TMI 0 /* define to 1 to enable Too Much Information */ + +#include <stdio.h> +#include <ctype.h> /* for isspace, etc. */ +#include <assert.h> +#include <string.h> +#include <stdlib.h> /* malloc */ + +#include "unicode/utypes.h" /* Basic ICU data types */ +#include "unicode/ucnv.h" /* C Converter API */ +#include "unicode/ustring.h" /* some more string fcns*/ +#include "unicode/uchar.h" /* char names */ +#include "unicode/uloc.h" +#include "unicode/unistr.h" + +#include "flagcb.h" + +/* Some utility functions */ + +static const UChar kNone[] = { 0x0000 }; + +#define U_ASSERT(x) { if(U_FAILURE(x)) {fflush(stdout);fflush(stderr); fprintf(stderr, #x " == %s\n", u_errorName(x)); assert(U_SUCCESS(x)); }} + +/* Print a UChar if possible, in seven characters. */ +void prettyPrintUChar(UChar c) +{ + if( (c <= 0x007F) && + (isgraph(c)) ) { + printf(" '%c' ", (char)(0x00FF&c)); + } else if ( c > 0x007F ) { + char buf[1000]; + UErrorCode status = U_ZERO_ERROR; + int32_t o; + + o = u_charName(c, U_UNICODE_CHAR_NAME, buf, 1000, &status); + if(U_SUCCESS(status) && (o>0) ) { + buf[6] = 0; + printf("%7s", buf); + } else { + o = u_charName(c, U_UNICODE_10_CHAR_NAME, buf, 1000, &status); + if(U_SUCCESS(status) && (o>0)) { + buf[5] = 0; + printf("~%6s", buf); + } + else { + printf(" ??????"); + } + } + } else { + switch((char)(c & 0x007F)) { + case ' ': + printf(" ' ' "); + break; + case '\t': + printf(" \\t "); + break; + case '\n': + printf(" \\n "); + break; + default: + printf(" _ "); + break; + } + } +} + + +void printUChars(const char *name = "?", + const UChar *uch = kNone, + int32_t len = -1 ) +{ + int32_t i; + + if( (len == -1) && (uch) ) { + len = u_strlen(uch); + } + + printf("%5s: ", name); + for( i = 0; i <len; i++) { + printf("%-6d ", i); + } + printf("\n"); + + printf("%5s: ", "uni"); + for( i = 0; i <len; i++) { + printf("\\u%04X ", (int)uch[i]); + } + printf("\n"); + + printf("%5s:", "ch"); + for( i = 0; i <len; i++) { + prettyPrintUChar(uch[i]); + } + printf("\n"); +} + +void printBytes(const char *name = "?", + const char *uch = "", + int32_t len = -1 ) +{ + int32_t i; + + if( (len == -1) && (uch) ) { + len = strlen(uch); + } + + printf("%5s: ", name); + for( i = 0; i <len; i++) { + printf("%-4d ", i); + } + printf("\n"); + + printf("%5s: ", "uni"); + for( i = 0; i <len; i++) { + printf("\\x%02X ", 0x00FF & (int)uch[i]); + } + printf("\n"); + + printf("%5s:", "ch"); + for( i = 0; i <len; i++) { + if(isgraph(0x00FF & (int)uch[i])) { + printf(" '%c' ", (char)uch[i]); + } else { + printf(" "); + } + } + printf("\n"); +} + +void printUChar(UChar32 ch32) +{ + if(ch32 > 0xFFFF) { + printf("ch: U+%06X\n", ch32); + } + else { + UChar ch = (UChar)ch32; + printUChars("C", &ch, 1); + } +} + +/******************************************************************* + Very simple C sample to convert the word 'Moscow' in Russian in Unicode, + followed by an exclamation mark (!) into the KOI8-R Russian code page. + + This example first creates a UChar String out of the Unicode chars. + + targetSize must be set to the amount of space available in the target + buffer. After fromUChars is called, + len will contain the number of bytes in target[] which were + used in the resulting codepage. In this case, there is a 1:1 mapping + between the input and output characters. The exclamation mark has the + same value in both KOI8-R and Unicode. + + src: 0 1 2 3 4 5 6 + uni: \u041C \u043E \u0441 \u043A \u0432 \u0430 \u0021 + ch: CYRILL CYRILL CYRILL CYRILL CYRILL CYRILL '!' + + targ: 0 1 2 3 4 5 6 + uni: \xED \xCF \xD3 \xCB \xD7 \xC1 \x21 + ch: '!' + + +Converting FROM unicode + to koi8-r. + You must call ucnv_close to clean up the memory used by the + converter. + + 'len' returns the number of OUTPUT bytes resulting from the + conversion. + */ + +UErrorCode convsample_02() +{ + printf("\n\n==============================================\n" + "Sample 02: C: simple Unicode -> koi8-r conversion\n"); + + + // **************************** START SAMPLE ******************* + // "cat<cat>OK" + UChar source[] = { 0x041C, 0x043E, 0x0441, 0x043A, 0x0432, + 0x0430, 0x0021, 0x0000 }; + char target[100]; + UErrorCode status = U_ZERO_ERROR; + UConverter *conv; + int32_t len; + + // set up the converter + conv = ucnv_open("koi8-r", &status); + assert(U_SUCCESS(status)); + + // convert to koi8-r + len = ucnv_fromUChars(conv, target, 100, source, -1, &status); + assert(U_SUCCESS(status)); + + // close the converter + ucnv_close(conv); + + // ***************************** END SAMPLE ******************** + + // Print it out + printUChars("src", source); + printf("\n"); + printBytes("targ", target, len); + + return U_ZERO_ERROR; +} + + +UErrorCode convsample_03() +{ + printf("\n\n==============================================\n" + "Sample 03: C: print out all converters\n"); + + int32_t count; + int32_t i; + + // **************************** START SAMPLE ******************* + count = ucnv_countAvailable(); + printf("Available converters: %d\n", count); + + for(i=0;i<count;i++) + { + printf("%s ", ucnv_getAvailableName(i)); + } + + // ***************************** END SAMPLE ******************** + + printf("\n"); + + return U_ZERO_ERROR; +} + + + +#define BUFFERSIZE 17 /* make it interesting :) */ + +/* + Converting from a codepage to Unicode in bulk.. + What is the best way to determine the buffer size? + + The 'buffersize' is in bytes of input. + For a given converter, divinding this by the minimum char size + give you the maximum number of Unicode characters that could be + expected for a given number of input bytes. + see: ucnv_getMinCharSize() + + For example, a single byte codepage like 'Latin-3' has a + minimum char size of 1. (It takes at least 1 byte to represent + each Unicode char.) So the unicode buffer has the same number of + UChars as the input buffer has bytes. + + In a strictly double byte codepage such as cp1362 (Windows + Korean), the minimum char size is 2. So, only half as many Unicode + chars as bytes are needed. + + This work to calculate the buffer size is an optimization. Any + size of input and output buffer can be used, as long as the + program handles the following cases: If the input buffer is empty, + the source pointer will be equal to sourceLimit. If the output + buffer has overflowed, U_BUFFER_OVERFLOW_ERROR will be returned. + */ + +UErrorCode convsample_05() +{ + printf("\n\n==============================================\n" + "Sample 05: C: count the number of letters in a UTF-8 document\n"); + + FILE *f; + int32_t count; + char inBuf[BUFFERSIZE]; + const char *source; + const char *sourceLimit; + UChar *uBuf; + UChar *target; + UChar *targetLimit; + UChar *p; + int32_t uBufSize = 0; + UConverter *conv; + UErrorCode status = U_ZERO_ERROR; + uint32_t letters=0, total=0; + + f = fopen("data01.txt", "r"); + if(!f) + { + fprintf(stderr, "Couldn't open file 'data01.txt' (UTF-8 data file).\n"); + return U_FILE_ACCESS_ERROR; + } + + // **************************** START SAMPLE ******************* + conv = ucnv_open("utf-8", &status); + assert(U_SUCCESS(status)); + + uBufSize = (BUFFERSIZE/ucnv_getMinCharSize(conv)); + printf("input bytes %d / min chars %d = %d UChars\n", + BUFFERSIZE, ucnv_getMinCharSize(conv), uBufSize); + uBuf = (UChar*)malloc(uBufSize * sizeof(UChar)); + assert(uBuf!=NULL); + + // grab another buffer's worth + while((!feof(f)) && + ((count=fread(inBuf, 1, BUFFERSIZE , f)) > 0) ) + { + // Convert bytes to unicode + source = inBuf; + sourceLimit = inBuf + count; + + do + { + target = uBuf; + targetLimit = uBuf + uBufSize; + + ucnv_toUnicode(conv, &target, targetLimit, + &source, sourceLimit, NULL, + feof(f)?TRUE:FALSE, /* pass 'flush' when eof */ + /* is true (when no more data will come) */ + &status); + + if(status == U_BUFFER_OVERFLOW_ERROR) + { + // simply ran out of space - we'll reset the target ptr the next + // time through the loop. + status = U_ZERO_ERROR; + } + else + { + // Check other errors here. + assert(U_SUCCESS(status)); + // Break out of the loop (by force) + } + + // Process the Unicode + // Todo: handle UTF-16/surrogates + + for(p = uBuf; p<target; p++) + { + if(u_isalpha(*p)) + letters++; + total++; + } + } while (source < sourceLimit); // while simply out of space + } + + printf("%d letters out of %d total UChars.\n", letters, total); + + // ***************************** END SAMPLE ******************** + ucnv_close(conv); + + printf("\n"); + + return U_ZERO_ERROR; +} +#undef BUFFERSIZE + +#define BUFFERSIZE 1024 +typedef struct +{ + UChar32 codepoint; + uint32_t frequency; +} CharFreqInfo; + +UErrorCode convsample_06() +{ + printf("\n\n==============================================\n" + "Sample 06: C: frequency distribution of letters in a UTF-8 document\n"); + + FILE *f; + int32_t count; + char inBuf[BUFFERSIZE]; + const char *source; + const char *sourceLimit; + UChar *uBuf; + int32_t uBufSize = 0; + UConverter *conv; + UErrorCode status = U_ZERO_ERROR; + uint32_t letters=0, total=0; + + CharFreqInfo *info; + UChar32 charCount = 0x10000; /* increase this if you want to handle non bmp.. todo: automatically bump it.. */ + UChar32 p; + + uint32_t ie = 0; + uint32_t gh = 0; + UChar32 l = 0; + + f = fopen("data06.txt", "r"); + if(!f) + { + fprintf(stderr, "Couldn't open file 'data06.txt' (UTF-8 data file).\n"); + return U_FILE_ACCESS_ERROR; + } + + info = (CharFreqInfo*)malloc(sizeof(CharFreqInfo) * charCount); + if(!info) + { + fprintf(stderr, " Couldn't allocate %d bytes for freq counter\n", sizeof(CharFreqInfo)*charCount); + } + + /* reset frequencies */ + for(p=0;p<charCount;p++) + { + info[p].codepoint = p; + info[p].frequency = 0; + } + + // **************************** START SAMPLE ******************* + conv = ucnv_open("utf-8", &status); + assert(U_SUCCESS(status)); + + uBufSize = (BUFFERSIZE/ucnv_getMinCharSize(conv)); + printf("input bytes %d / min chars %d = %d UChars\n", + BUFFERSIZE, ucnv_getMinCharSize(conv), uBufSize); + uBuf = (UChar*)malloc(uBufSize * sizeof(UChar)); + assert(uBuf!=NULL); + + // grab another buffer's worth + while((!feof(f)) && + ((count=fread(inBuf, 1, BUFFERSIZE , f)) > 0) ) + { + // Convert bytes to unicode + source = inBuf; + sourceLimit = inBuf + count; + + while(source < sourceLimit) + { + p = ucnv_getNextUChar(conv, &source, sourceLimit, &status); + if(U_FAILURE(status)) + { + fprintf(stderr, "%s @ %d\n", u_errorName(status), total); + status = U_ZERO_ERROR; + continue; + } + U_ASSERT(status); + total++; + + if(u_isalpha(p)) + letters++; + + if((u_tolower(l) == 'i') && (u_tolower(p) == 'e')) + ie++; + + if((u_tolower(l) == 'g') && (u_tolower(p) == 0x0127)) + gh++; + + if(p>charCount) + { + fprintf(stderr, "U+%06X: oh.., we only handle BMP characters so far.. redesign!\n", p); + return U_UNSUPPORTED_ERROR; + } + info[p].frequency++; + l = p; + } + } + + fclose(f); + ucnv_close(conv); + + printf("%d letters out of %d total UChars.\n", letters, total); + printf("%d ie digraphs, %d gh digraphs.\n", ie, gh); + + // now, we could sort it.. + + // qsort(info, charCount, sizeof(info[0]), charfreq_compare); + + for(p=0;p<charCount;p++) + { + if(info[p].frequency) + { + printf("% 5d U+%06X ", info[p].frequency, p); + if(p <= 0xFFFF) + { + prettyPrintUChar((UChar)p); + } + printf("\n"); + } + } + free(info); + // ***************************** END SAMPLE ******************** + + printf("\n"); + + return U_ZERO_ERROR; +} +#undef BUFFERSIZE + + +/****************************************************** + You must call ucnv_close to clean up the memory used by the + converter. + + 'len' returns the number of OUTPUT bytes resulting from the + conversion. + */ + +UErrorCode convsample_12() +{ + printf("\n\n==============================================\n" + "Sample 12: C: simple sjis -> unicode conversion\n"); + + + // **************************** START SAMPLE ******************* + + char source[] = { 0x63, 0x61, 0x74, (char)0x94, 0x4C, (char)0x82, 0x6E, (char)0x82, 0x6A, 0x00 }; + UChar target[100]; + UErrorCode status = U_ZERO_ERROR; + UConverter *conv; + int32_t len; + + // set up the converter + conv = ucnv_open("shift_jis", &status); + assert(U_SUCCESS(status)); + + // convert to Unicode + // Note: we can use strlen, we know it's an 8 bit null terminated codepage + target[6] = 0xFDCA; + len = ucnv_toUChars(conv, target, 100, source, strlen(source), &status); + U_ASSERT(status); + // close the converter + ucnv_close(conv); + + // ***************************** END SAMPLE ******************** + + // Print it out + printBytes("src", source, strlen(source) ); + printf("\n"); + printUChars("targ", target, len); + + return U_ZERO_ERROR; +} + +/****************************************************************** + C: Convert from codepage to Unicode one at a time. +*/ + +UErrorCode convsample_13() +{ + printf("\n\n==============================================\n" + "Sample 13: C: simple Big5 -> unicode conversion, char at a time\n"); + + + const char sourceChars[] = { 0x7a, 0x68, 0x3d, (char)0xa4, (char)0xa4, (char)0xa4, (char)0xe5, (char)0x2e }; + // const char sourceChars[] = { 0x7a, 0x68, 0x3d, 0xe4, 0xb8, 0xad, 0xe6, 0x96, 0x87, 0x2e }; + const char *source, *sourceLimit; + UChar32 target; + UErrorCode status = U_ZERO_ERROR; + UConverter *conv = NULL; + int32_t srcCount=0; + int32_t dstCount=0; + + srcCount = sizeof(sourceChars); + + conv = ucnv_open("Big5", &status); + U_ASSERT(status); + + source = sourceChars; + sourceLimit = sourceChars + sizeof(sourceChars); + + // **************************** START SAMPLE ******************* + + + printBytes("src",source,sourceLimit-source); + + while(source < sourceLimit) + { + puts(""); + target = ucnv_getNextUChar (conv, + &source, + sourceLimit, + &status); + + // printBytes("src",source,sourceLimit-source); + U_ASSERT(status); + printUChar(target); + dstCount++; + } + + + // ************************** END SAMPLE ************************* + + printf("src=%d bytes, dst=%d uchars\n", srcCount, dstCount); + ucnv_close(conv); + + return U_ZERO_ERROR; +} + + + + +UBool convsample_20_didSubstitute(const char *source) +{ + UChar uchars[100]; + char bytes[100]; + UConverter *conv = NULL; + UErrorCode status = U_ZERO_ERROR; + uint32_t len, len2; + UBool flagVal; + + FromUFLAGContext * context = NULL; + + printf("\n\n==============================================\n" + "Sample 20: C: Test for substitution using callbacks\n"); + + /* print out the original source */ + printBytes("src", source); + printf("\n"); + + /* First, convert from UTF8 to unicode */ + conv = ucnv_open("utf-8", &status); + U_ASSERT(status); + + len = ucnv_toUChars(conv, uchars, 100, source, strlen(source), &status); + U_ASSERT(status); + + printUChars("uch", uchars, len); + printf("\n"); + + /* Now, close the converter */ + ucnv_close(conv); + + /* Now, convert to windows-1252 */ + conv = ucnv_open("windows-1252", &status); + U_ASSERT(status); + + /* Converter starts out with the SUBSTITUTE callback set. */ + + /* initialize our callback */ + context = flagCB_fromU_openContext(); + + /* Set our special callback */ + ucnv_setFromUCallBack(conv, + flagCB_fromU, + context, + &(context->subCallback), + &(context->subContext), + &status); + + U_ASSERT(status); + + len2 = ucnv_fromUChars(conv, bytes, 100, uchars, len, &status); + U_ASSERT(status); + + flagVal = context->flag; /* it's about to go away when we close the cnv */ + + ucnv_close(conv); + + /* print out the original source */ + printBytes("bytes", bytes, len2); + + return flagVal; /* true if callback was called */ +} + +UErrorCode convsample_20() +{ + const char *sample1 = "abc\xdf\xbf"; + const char *sample2 = "abc_def"; + + + if(convsample_20_didSubstitute(sample1)) + { + printf("DID substitute.\n******\n"); + } + else + { + printf("Did NOT substitute.\n*****\n"); + } + + if(convsample_20_didSubstitute(sample2)) + { + printf("DID substitute.\n******\n"); + } + else + { + printf("Did NOT substitute.\n*****\n"); + } + + return U_ZERO_ERROR; +} + +// 21 - C, callback, with clone and debug + + + +UBool convsample_21_didSubstitute(const char *source) +{ + UChar uchars[100]; + char bytes[100]; + UConverter *conv = NULL, *cloneCnv = NULL; + UErrorCode status = U_ZERO_ERROR; + uint32_t len, len2; + int32_t cloneLen; + UBool flagVal = FALSE; + UConverterFromUCallback junkCB; + + FromUFLAGContext *flagCtx = NULL, + *cloneFlagCtx = NULL; + + debugCBContext *debugCtx1 = NULL, + *debugCtx2 = NULL, + *cloneDebugCtx = NULL; + + printf("\n\n==============================================\n" + "Sample 21: C: Test for substitution w/ callbacks & clones \n"); + + /* print out the original source */ + printBytes("src", source); + printf("\n"); + + /* First, convert from UTF8 to unicode */ + conv = ucnv_open("utf-8", &status); + U_ASSERT(status); + + len = ucnv_toUChars(conv, uchars, 100, source, strlen(source), &status); + U_ASSERT(status); + + printUChars("uch", uchars, len); + printf("\n"); + + /* Now, close the converter */ + ucnv_close(conv); + + /* Now, convert to windows-1252 */ + conv = ucnv_open("windows-1252", &status); + U_ASSERT(status); + + /* Converter starts out with the SUBSTITUTE callback set. */ + + /* initialize our callback */ + /* from the 'bottom' innermost, out + * CNV -> debugCtx1[debug] -> flagCtx[flag] -> debugCtx2[debug] */ + +#if DEBUG_TMI + printf("flagCB_fromU = %p\n", &flagCB_fromU); + printf("debugCB_fromU = %p\n", &debugCB_fromU); +#endif + + debugCtx1 = debugCB_openContext(); + flagCtx = flagCB_fromU_openContext(); + debugCtx2 = debugCB_openContext(); + + debugCtx1->subCallback = flagCB_fromU; /* debug1 -> flag */ + debugCtx1->subContext = flagCtx; + + flagCtx->subCallback = debugCB_fromU; /* flag -> debug2 */ + flagCtx->subContext = debugCtx2; + + debugCtx2->subCallback = UCNV_FROM_U_CALLBACK_SUBSTITUTE; + debugCtx2->subContext = NULL; + + /* Set our special callback */ + + ucnv_setFromUCallBack(conv, + debugCB_fromU, + debugCtx1, + &(debugCtx2->subCallback), + &(debugCtx2->subContext), + &status); + + U_ASSERT(status); + +#if DEBUG_TMI + printf("Callback chain now: Converter %p -> debug1:%p-> (%p:%p)==flag:%p -> debug2:%p -> cb %p\n", + conv, debugCtx1, debugCtx1->subCallback, + debugCtx1->subContext, flagCtx, debugCtx2, debugCtx2->subCallback); +#endif + + cloneLen = 1; /* but passing in null so it will clone */ + cloneCnv = ucnv_safeClone(conv, NULL, &cloneLen, &status); + + U_ASSERT(status); + +#if DEBUG_TMI + printf("Cloned converter from %p -> %p. Closing %p.\n", conv, cloneCnv, conv); +#endif + + ucnv_close(conv); + +#if DEBUG_TMI + printf("%p closed.\n", conv); +#endif + + U_ASSERT(status); + /* Now, we have to extract the context */ + cloneDebugCtx = NULL; + cloneFlagCtx = NULL; + + ucnv_getFromUCallBack(cloneCnv, &junkCB, (const void **)&cloneDebugCtx); + if(cloneDebugCtx != NULL) { + cloneFlagCtx = (FromUFLAGContext*) cloneDebugCtx -> subContext; + } + + printf("Cloned converter chain: %p -> %p[debug1] -> %p[flag] -> %p[debug2] -> substitute\n", + cloneCnv, cloneDebugCtx, cloneFlagCtx, cloneFlagCtx?cloneFlagCtx->subContext:NULL ); + + len2 = ucnv_fromUChars(cloneCnv, bytes, 100, uchars, len, &status); + U_ASSERT(status); + + if(cloneFlagCtx != NULL) { + flagVal = cloneFlagCtx->flag; /* it's about to go away when we close the cnv */ + } else { + printf("** Warning, couldn't get the subcallback \n"); + } + + ucnv_close(cloneCnv); + + /* print out the original source */ + printBytes("bytes", bytes, len2); + + return flagVal; /* true if callback was called */ +} + +UErrorCode convsample_21() +{ + const char *sample1 = "abc\xdf\xbf"; + const char *sample2 = "abc_def"; + + if(convsample_21_didSubstitute(sample1)) + { + printf("DID substitute.\n******\n"); + } + else + { + printf("Did NOT substitute.\n*****\n"); + } + + if(convsample_21_didSubstitute(sample2)) + { + printf("DID substitute.\n******\n"); + } + else + { + printf("Did NOT substitute.\n*****\n"); + } + + return U_ZERO_ERROR; +} + + +// 40- C, cp37 -> UTF16 [data02.bin -> data40.utf16] + +#define BUFFERSIZE 17 /* make it interesting :) */ + +UErrorCode convsample_40() +{ + printf("\n\n==============================================\n" + "Sample 40: C: convert data02.bin from cp37 to UTF16 [data40.utf16]\n"); + + FILE *f; + FILE *out; + int32_t count; + char inBuf[BUFFERSIZE]; + const char *source; + const char *sourceLimit; + UChar *uBuf; + UChar *target; + UChar *targetLimit; + int32_t uBufSize = 0; + UConverter *conv = NULL; + UErrorCode status = U_ZERO_ERROR; + uint32_t inbytes=0, total=0; + + f = fopen("data02.bin", "rb"); + if(!f) + { + fprintf(stderr, "Couldn't open file 'data02.bin' (cp37 data file).\n"); + return U_FILE_ACCESS_ERROR; + } + + out = fopen("data40.utf16", "wb"); + if(!out) + { + fprintf(stderr, "Couldn't create file 'data40.utf16'.\n"); + return U_FILE_ACCESS_ERROR; + } + + // **************************** START SAMPLE ******************* + conv = ucnv_openCCSID(37, UCNV_IBM, &status); + assert(U_SUCCESS(status)); + + uBufSize = (BUFFERSIZE/ucnv_getMinCharSize(conv)); + printf("input bytes %d / min chars %d = %d UChars\n", + BUFFERSIZE, ucnv_getMinCharSize(conv), uBufSize); + uBuf = (UChar*)malloc(uBufSize * sizeof(UChar)); + assert(uBuf!=NULL); + + // grab another buffer's worth + while((!feof(f)) && + ((count=fread(inBuf, 1, BUFFERSIZE , f)) > 0) ) + { + inbytes += count; + + // Convert bytes to unicode + source = inBuf; + sourceLimit = inBuf + count; + + do + { + target = uBuf; + targetLimit = uBuf + uBufSize; + + ucnv_toUnicode( conv, &target, targetLimit, + &source, sourceLimit, NULL, + feof(f)?TRUE:FALSE, /* pass 'flush' when eof */ + /* is true (when no more data will come) */ + &status); + + if(status == U_BUFFER_OVERFLOW_ERROR) + { + // simply ran out of space - we'll reset the target ptr the next + // time through the loop. + status = U_ZERO_ERROR; + } + else + { + // Check other errors here. + assert(U_SUCCESS(status)); + // Break out of the loop (by force) + } + + // Process the Unicode + // Todo: handle UTF-16/surrogates + assert(fwrite(uBuf, sizeof(uBuf[0]), (target-uBuf), out) == + (size_t)(target-uBuf)); + total += (target-uBuf); + } while (source < sourceLimit); // while simply out of space + } + + printf("%d bytes in, %d UChars out.\n", inbytes, total); + + // ***************************** END SAMPLE ******************** + ucnv_close(conv); + + fclose(f); + fclose(out); + printf("\n"); + + return U_ZERO_ERROR; +} +#undef BUFFERSIZE + + + +// 46- C, UTF16 -> latin2 [data40.utf16 -> data46.out] + +#define BUFFERSIZE 24 /* make it interesting :) */ + +UErrorCode convsample_46() +{ + printf("\n\n==============================================\n" + "Sample 46: C: convert data40.utf16 from UTF16 to latin2 [data46.out]\n"); + + FILE *f; + FILE *out; + int32_t count; + UChar inBuf[BUFFERSIZE]; + const UChar *source; + const UChar *sourceLimit; + char *buf; + char *target; + char *targetLimit; + + int32_t bufSize = 0; + UConverter *conv = NULL; + UErrorCode status = U_ZERO_ERROR; + uint32_t inchars=0, total=0; + + f = fopen("data40.utf16", "rb"); + if(!f) + { + fprintf(stderr, "Couldn't open file 'data40.utf16' (did you run convsample_40() ?)\n"); + return U_FILE_ACCESS_ERROR; + } + + out = fopen("data46.out", "wb"); + if(!out) + { + fprintf(stderr, "Couldn't create file 'data46.out'.\n"); + return U_FILE_ACCESS_ERROR; + } + + // **************************** START SAMPLE ******************* + conv = ucnv_open( "iso-8859-2", &status); + assert(U_SUCCESS(status)); + + bufSize = (BUFFERSIZE*ucnv_getMaxCharSize(conv)); + printf("input UChars[16] %d * max charsize %d = %d bytes output buffer\n", + BUFFERSIZE, ucnv_getMaxCharSize(conv), bufSize); + buf = (char*)malloc(bufSize * sizeof(char)); + assert(buf!=NULL); + + // grab another buffer's worth + while((!feof(f)) && + ((count=fread(inBuf, sizeof(UChar), BUFFERSIZE , f)) > 0) ) + { + inchars += count; + + // Convert bytes to unicode + source = inBuf; + sourceLimit = inBuf + count; + + do + { + target = buf; + targetLimit = buf + bufSize; + + ucnv_fromUnicode( conv, &target, targetLimit, + &source, sourceLimit, NULL, + feof(f)?TRUE:FALSE, /* pass 'flush' when eof */ + /* is true (when no more data will come) */ + &status); + + if(status == U_BUFFER_OVERFLOW_ERROR) + { + // simply ran out of space - we'll reset the target ptr the next + // time through the loop. + status = U_ZERO_ERROR; + } + else + { + // Check other errors here. + assert(U_SUCCESS(status)); + // Break out of the loop (by force) + } + + // Process the Unicode + assert(fwrite(buf, sizeof(buf[0]), (target-buf), out) == + (size_t)(target-buf)); + total += (target-buf); + } while (source < sourceLimit); // while simply out of space + } + + printf("%d Uchars (%d bytes) in, %d chars out.\n", inchars, inchars * sizeof(UChar), total); + + // ***************************** END SAMPLE ******************** + ucnv_close(conv); + + fclose(f); + fclose(out); + printf("\n"); + + return U_ZERO_ERROR; +} +#undef BUFFERSIZE + +#define BUFFERSIZE 219 + + +/* main */ + +int main() +{ + + printf("Default Converter=%s\n", ucnv_getDefaultName() ); + + convsample_02(); // C , u->koi8r, conv + convsample_03(); // C, iterate + + convsample_05(); // C, utf8->u, getNextUChar + convsample_06(); // C freq counter thingy + + convsample_12(); // C, sjis->u, conv + convsample_13(); // C, big5->u, getNextU + + convsample_20(); // C, callback + convsample_21(); // C, callback debug + + convsample_40(); // C, cp37 -> UTF16 [data02.bin -> data40.utf16] + + convsample_46(); // C, UTF16 -> latin3 [data41.utf16 -> data46.out] + + printf("End of converter samples.\n"); + + fflush(stdout); + fflush(stderr); + + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/ucnv/data01.txt b/Build/source/libs/icu/icu-xetex/samples/ucnv/data01.txt new file mode 100644 index 00000000000..5b53359cd46 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ucnv/data01.txt @@ -0,0 +1,15 @@ +-*- Coding: utf-8 ; -*- // for emacs +[some latin, devanagari, and cyrillic text] +raj Rajasthani राजेसà¥à¤¥à¤¾à¤¨à¥€ + Konkani कोंकणी + Haryanvi हरियानवी +rm Rhaeto-Romance रहेयà¥à¤Ÿà¥‹-रोमानà¥à¤¸ +rn Kirundi किरूनà¥à¤¦à¥€ +ro Romanian रूमानीयनॠ+ru Russian रà¥à¤¸à¥€ футбол +том +атом +Ðева +Fid-dinja hawn aktar imÄ¡ienen minn nies f'sensiehom. +Il-mistoqsija oħt il-għerf. (Asking is the sister of knowing.) +aфутбол중앙ì¼ë³´ï¼ã®â€œæ—¥æœ¬èªžâ€ diff --git a/Build/source/libs/icu/icu-xetex/samples/ucnv/data02.bin b/Build/source/libs/icu/icu-xetex/samples/ucnv/data02.bin new file mode 100644 index 00000000000..e1a5aad9e51 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ucnv/data02.bin @@ -0,0 +1 @@ +º…§ƒ…™—£@£¨—…„@‚¨@¢™“|”–•’…¨K¢‚¨K–™‡@¼@%@ˆ££—zaa¦¦¦K”–•’…¨K¢‚¨K–™‡a¡¢™“aˆ”–ƒ£a»%%ȉ¢£–™¨@•„@Ô¨¢£…™¨@–†@Ö””–•@㈉•‡¢@‚¨@ÃK@æK@Á““…•%Õ…¦@è–™’z@Ó…¥‰£@P@Á““…•@™–¢Kk@ø@È–¦™„@⣙……£K%%Å•£…™…„@ƒƒ–™„‰•‡@£–@£ˆ…@Áƒ£@–†@Ö•‡™…¢¢@‰•@£ˆ…@¨…™@ñøõùk%¨@æKÁK@ã–¦•¢…•„@P@ÖKk%‰•@£ˆ…@Ó…™’}¢@Ö††‰ƒ…@–†@£ˆ…@ĉ¢ƒ£‰ƒ£@Ö¤™£@†–™@£ˆ…@â–¤£ˆ…™•@ĉ¢£™‰ƒ£@–†@Õ…¦@è–™’K@%%¼¼¼¼Á‚–¤£@ã…k@Ö††……k@…£ƒK¼¼¼¼¼¼%%º×‡…@ññ»%%戣@‰¢@ã…o@%%㈅@“…¥…¢@–†@@¢ˆ™¤‚@‡™–¦•@ƒˆ‰…†“¨@‰•@ȉ•@•„@Ñ—•^@–†@¦ˆ‰ƒˆ@ƒ–¤•£™‰…¢@‰£@‰¢@@•£‰¥…K@É£@‰¢@•@…¥…™‡™……•k@‡™–¦¢@£–@£ˆ…@ˆ…‰‡ˆ£@–†@†™–”@†–¤™@£–%¢‰§@†……£k@•„@‚…™¢@—™…££¨@¦ˆ‰£…@†“–¦…™¢k@™…¢…”‚“‰•‡@¦‰“„@™–¢…¢K%%É¢@£ˆ…™…@”–™…@£ˆ•@–•…@¢—…ƒ‰…¢@–†@£ˆ…@ã…@ד•£o@%%è…¢k@¢…¥…™“^@£ˆ–¢…@”–¢£@ƒ¤“£‰¥£…„@™…@£ˆ…@㈅@‚–ˆ…@•„@㈅@¥‰™‰„‰¢^@‰£@¦¢@†–™”…™“¨@‚…“‰…¥…„@£ˆ£@£ˆ…¢…@£¦–@—“•£¢@—™–„¤ƒ…„@£ˆ…@‚“ƒ’@•„%‡™……•@£…¢k@•„@†™–”@£ˆ‰¢@‚…“‰…†@£ˆ…¨@„…™‰¥…„@£ˆ…‰™@•”…¢^@‚¤£@‰£@‰¢@•–¦@—™–¥…„@£ˆ£@£ˆ…@„‰††…™…•ƒ…@™‰¢…¢@‰•@£ˆ…@”–„…@–†@—™…—…™£‰–•k@•„@…‰£ˆ…™%’‰•„@–†@£…@ƒ•@‚…@”„…@†™–”@…‰£ˆ…™@—“•£@¦‰£ˆ–¤£@„‰††‰ƒ¤“£¨K%%È–¦@‰¢@£ˆ…@ã…@ד•£@ä“£‰¥£…„o%%É•@ȉ•@£ˆ…™…@™…@‡™…£@•¤”‚…™¢@–†@£…`†™”¢k@‡…•…™““¨@–†@¢”““@…§£…•£k@¢‰£¤£…„@–•@£ˆ…@¤——…™@¥““…¨¢k@•„@–•@£ˆ…@¢“–—‰•‡@¢‰„…¢@–†@£ˆ…@ˆ‰““¢k%¦ˆ…™…@£ˆ…@¢–‰“@‰¢@“‰‡ˆ£@•„@™‰ƒˆk@•„@¦…^“@„™‰•…„K@㈅@—“•£¢@™…@™‰¢…„@†™–”@¢……„k@•„@‡…•…™““¨@““–¦…„@£–@™…”‰•@£ˆ™……@¨…™¢@‚…†–™…@@ƒ™–—@–†%“…¥…¢@‰¢@£’…‰•@†™–”@£ˆ…”k@¢@£ˆ‰¢@–—…™£‰–•@–†@ƒ–¤™¢…@‰•‘¤™…¢@£ˆ…‰™@‡™–¦£ˆ^@…¥…•@¦‰£ˆ@ƒ™…k@£ˆ…¨@‚…ƒ–”…@¢£¤•£…„k@•„@¤•—™–†‰£‚“…@‰•@‚–¤£@…‰‡ˆ£%–™@£…•@¨…™¢K@戅•@£ˆ…@ƒ™–—@‰¢@™…„¨k@£ˆ…@“…¥…¢@™…@ƒ™…†¤““¨@—‰ƒ’…„@‚¨@ˆ•„@–•…@‚¨@–•…k@•„@£ˆ…™…@™…@¤¢¤““¨@£ˆ™……@–™@†–¤™@‡£ˆ…™‰•‡¢@‰•@…ƒˆ%¨…™k@£ˆ…@†‰™¢£@ƒ™–—@‰•@£ˆ…@¢—™‰•‡@‚…‰•‡@–†@£ˆ…@”–¢£@¥“¤…^@@¦…““`‡™–¦•@‚¤¢ˆk@¦…““@£™…£…„k@¦‰““@—™–„¤ƒ…@£¦–@–™@£ˆ™……@—–¤•„¢@–†@£…@••¤““¨K%
\ No newline at end of file diff --git a/Build/source/libs/icu/icu-xetex/samples/ucnv/data06.txt b/Build/source/libs/icu/icu-xetex/samples/ucnv/data06.txt new file mode 100644 index 00000000000..1d7858e18b8 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ucnv/data06.txt @@ -0,0 +1,90 @@ +// ******************************************************************************* +// * +// * Copyright (C) 1997-2000, International Business Machines +// * Corporation and others. All Rights Reserved. +// * +// ******************************************************************************* + + + +fa { + + Version { "x0.0" } + + + DayAbbreviations { + "ی∔", + "د∔", + "س∔", + "چ∔", + "پ∔", + "ج∔", + "ش∔", + } + DayNames { + "یی‌شنبه", + "دوشنبه", + "سه‌شنبه", + "چهارشنبه", + "پنج‌شنبه", + "جمعه", + "شنبه", + } + MonthAbbreviations { + "ژان", + "Ùور", + "مار", + "آور", + "مـه", + "ژون", + "Ú˜ÙˆÛŒ", + "اوت", + "سپت", + "اكت", + "نوا", + "دسا", + "", + } + MonthNames { + "ژانویه", + "Ùورویه", + "مارس", + "آوریل", + "مه", + "ژوئن", + "ژوئیه", + "اوت", + "سپتامبر", + "اكتبر", + "نوامبر", + "دسامبر", + "", + } + NumberElements { + "Ù«", + "Ù¬", + ";", + "%", + "0", + "#", + "-", + "E", + "‰", + "∞", + "�", + } + NumberPatterns { + "#,##0.###;-#,##0.###", + "#,##0.#¤;#,##0.#- ¤", + "#,##0%", + } + LocaleID{ "29"} + // /**************** Info Below is needed ****************/ + // CollationElements{} + // Countries{} + // Eras{} + // Languages{} + // ShortLanguage { } + // localPatternChars{} + // +}
\ No newline at end of file diff --git a/Build/source/libs/icu/icu-xetex/samples/ucnv/flagcb.c b/Build/source/libs/icu/icu-xetex/samples/ucnv/flagcb.c new file mode 100644 index 00000000000..3344c73f2bc --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ucnv/flagcb.c @@ -0,0 +1,288 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2007, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/utypes.h" +#include "unicode/ucnv.h" +#include "flagcb.h" +#include <string.h> +#include <stdlib.h> +#include <stdio.h> + +#define DEBUG_TMI 0 /* set to 1 for Too Much Information (TMI) */ + +U_CAPI FromUFLAGContext* U_EXPORT2 flagCB_fromU_openContext() +{ + FromUFLAGContext *ctx; + + ctx = (FromUFLAGContext*) malloc(sizeof(FromUFLAGContext)); + + ctx->subCallback = NULL; + ctx->subContext = NULL; + ctx->flag = FALSE; + + return ctx; +} + +U_CAPI void U_EXPORT2 flagCB_fromU( + const void *context, + UConverterFromUnicodeArgs *fromUArgs, + const UChar* codeUnits, + int32_t length, + UChar32 codePoint, + UConverterCallbackReason reason, + UErrorCode * err) +{ + /* First step - based on the reason code, take action */ + + if(reason == UCNV_UNASSIGNED) { /* whatever set should be trapped here */ + ((FromUFLAGContext*)context)->flag = TRUE; + } + + if(reason == UCNV_CLONE) { + /* The following is the recommended way to implement UCNV_CLONE + in a callback. */ + UConverterFromUCallback saveCallback; + const void *saveContext; + FromUFLAGContext *old, *cloned; + UErrorCode subErr = U_ZERO_ERROR; + +#if DEBUG_TMI + printf("*** FLAGCB: cloning %p ***\n", context); +#endif + old = (FromUFLAGContext*)context; + cloned = flagCB_fromU_openContext(); + + memcpy(cloned, old, sizeof(FromUFLAGContext)); + +#if DEBUG_TMI + printf("%p: my subcb=%p:%p\n", old, old->subCallback, + old->subContext); + printf("%p: cloned subcb=%p:%p\n", cloned, cloned->subCallback, + cloned->subContext); +#endif + + /* We need to get the sub CB to handle cloning, + * so we have to set up the following, temporarily: + * + * - Set the callback+context to the sub of this (flag) cb + * - preserve the current cb+context, it could be anything + * + * Before: + * CNV -> FLAG -> subcb -> ... + * + * After: + * CNV -> subcb -> ... + * + * The chain from 'something' on is saved, and will be restored + * at the end of this block. + * + */ + + ucnv_setFromUCallBack(fromUArgs->converter, + cloned->subCallback, + cloned->subContext, + &saveCallback, + &saveContext, + &subErr); + + if( cloned->subCallback != NULL ) { + /* Now, call the sub callback if present */ + cloned->subCallback(cloned->subContext, fromUArgs, codeUnits, + length, codePoint, reason, err); + } + + ucnv_setFromUCallBack(fromUArgs->converter, + saveCallback, /* Us */ + cloned, /* new context */ + &cloned->subCallback, /* IMPORTANT! Accept any change in CB or context */ + &cloned->subContext, + &subErr); + + if(U_FAILURE(subErr)) { + *err = subErr; + } + } + + /* process other reasons here if need be */ + + /* Always call the subCallback if present */ + if(((FromUFLAGContext*)context)->subCallback != NULL && + reason != UCNV_CLONE) { + ((FromUFLAGContext*)context)->subCallback( ((FromUFLAGContext*)context)->subContext, + fromUArgs, + codeUnits, + length, + codePoint, + reason, + err); + } + + /* cleanup - free the memory AFTER calling the sub CB */ + if(reason == UCNV_CLOSE) { + free((void*)context); + } +} + +/* Debugging callback, just outputs what happens */ + +/* Test safe clone callback */ + +static uint32_t debugCB_nextSerial() +{ + static uint32_t n = 1; + + return (n++); +} + +static void debugCB_print_log(debugCBContext *q, const char *name) +{ + if(q==NULL) { + printf("debugCBontext: %s is NULL!!\n", name); + } else { + if(q->magic != 0xC0FFEE) { + fprintf(stderr, "debugCBContext: %p:%d's magic is %x, supposed to be 0xC0FFEE\n", + q,q->serial, q->magic); + } + printf("debugCBContext %p:%d=%s - magic %x\n", + q, q->serial, name, q->magic); + } +} + +static debugCBContext *debugCB_clone(debugCBContext *ctx) +{ + debugCBContext *newCtx; + newCtx = malloc(sizeof(debugCBContext)); + + newCtx->serial = debugCB_nextSerial(); + newCtx->magic = 0xC0FFEE; + + newCtx->subCallback = ctx->subCallback; + newCtx->subContext = ctx->subContext; + +#if DEBUG_TMI + printf("debugCB_clone: %p:%d -> new context %p:%d\n", ctx, ctx->serial, newCtx, newCtx->serial); +#endif + + return newCtx; +} + +void debugCB_fromU(const void *context, + UConverterFromUnicodeArgs *fromUArgs, + const UChar* codeUnits, + int32_t length, + UChar32 codePoint, + UConverterCallbackReason reason, + UErrorCode * err) +{ + debugCBContext *ctx = (debugCBContext*)context; + /*UConverterFromUCallback junkFrom;*/ + +#if DEBUG_TMI + printf("debugCB_fromU: Context %p:%d called, reason %d on cnv %p [err=%s]\n", ctx, ctx->serial, reason, fromUArgs->converter, u_errorName(*err)); +#endif + + if(ctx->magic != 0xC0FFEE) { + fprintf(stderr, "debugCB_fromU: Context %p:%d magic is 0x%x should be 0xC0FFEE.\n", ctx,ctx->serial, ctx->magic); + return; + } + + if(reason == UCNV_CLONE) { + /* see comments in above flagCB clone code */ + + UConverterFromUCallback saveCallback; + const void *saveContext; + debugCBContext *cloned; + UErrorCode subErr = U_ZERO_ERROR; + + /* "recreate" it */ +#if DEBUG_TMI + printf("debugCB_fromU: cloning..\n"); +#endif + cloned = debugCB_clone(ctx); + + if(cloned == NULL) { + fprintf(stderr, "debugCB_fromU: internal clone failed on %p\n", ctx); + *err = U_MEMORY_ALLOCATION_ERROR; + return; + } + + ucnv_setFromUCallBack(fromUArgs->converter, + cloned->subCallback, + cloned->subContext, + &saveCallback, + &saveContext, + &subErr); + + if( cloned->subCallback != NULL) { +#if DEBUG_TMI + printf("debugCB_fromU:%p calling subCB %p\n", ctx, cloned->subCallback); +#endif + /* call subCB if present */ + cloned->subCallback(cloned->subContext, fromUArgs, codeUnits, + length, codePoint, reason, err); + } else { + printf("debugCB_fromU:%p, NOT calling subCB, it's NULL\n", ctx); + } + + /* set back callback */ + ucnv_setFromUCallBack(fromUArgs->converter, + saveCallback, /* Us */ + cloned, /* new context */ + &cloned->subCallback, /* IMPORTANT! Accept any change in CB or context */ + &cloned->subContext, + &subErr); + + if(U_FAILURE(subErr)) { + *err = subErr; + } + } + + /* process other reasons here */ + + /* always call subcb if present */ + if(ctx->subCallback != NULL && reason != UCNV_CLONE) { + ctx->subCallback(ctx->subContext, + fromUArgs, + codeUnits, + length, + codePoint, + reason, + err); + } + + if(reason == UCNV_CLOSE) { +#if DEBUG_TMI + printf("debugCB_fromU: Context %p:%d closing\n", ctx, ctx->serial); +#endif + free(ctx); + } + +#if DEBUG_TMI + printf("debugCB_fromU: leaving cnv %p, ctx %p: err %s\n", fromUArgs->converter, ctx, u_errorName(*err)); +#endif +} + +debugCBContext *debugCB_openContext() +{ + debugCBContext *ctx; + + ctx = malloc(sizeof(debugCBContext)); + + if(ctx != NULL) { + ctx->magic = 0xC0FFEE; + ctx->serial = debugCB_nextSerial(); + ctx->subCallback = NULL; + ctx->subContext = NULL; + +#if DEBUG_TMI + fprintf(stderr, "debugCB:openContext opened[%p] = serial #%d\n", ctx, ctx->serial); +#endif + + } + + + return ctx; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/ucnv/flagcb.h b/Build/source/libs/icu/icu-xetex/samples/ucnv/flagcb.h new file mode 100644 index 00000000000..4b1cba5a451 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ucnv/flagcb.h @@ -0,0 +1,60 @@ +/* Copyright (c) 2000 IBM, Inc. and Others. + FLAGCB.H - interface to 'flagging' callback which + simply marks the fact that the callback was called. +*/ + +#ifndef _FLAGCB +#define _FLAGCB + +#include "unicode/utypes.h" +#include "unicode/ucnv.h" + +/* The structure of a FromU Flag context. + (conceivably there could be a ToU Flag Context) */ + +typedef struct +{ + UConverterFromUCallback subCallback; + const void *subContext; + UBool flag; +} FromUFLAGContext; + +/** + * open the context + */ + +U_CAPI FromUFLAGContext* U_EXPORT2 flagCB_fromU_openContext(); + +/** + * the actual callback + */ +U_CAPI void U_EXPORT2 flagCB_fromU( + const void *context, + UConverterFromUnicodeArgs *fromUArgs, + const UChar* codeUnits, + int32_t length, + UChar32 codePoint, + UConverterCallbackReason reason, + UErrorCode * err); + + + +typedef struct +{ + UConverterFromUCallback subCallback; + const void *subContext; + uint32_t magic; /* 0xC0FFEE to identify that the object is OK */ + uint32_t serial; /* minted from nextSerial */ +} debugCBContext; + +U_CAPI void debugCB_fromU(const void *context, + UConverterFromUnicodeArgs *fromUArgs, + const UChar* codeUnits, + int32_t length, + UChar32 codePoint, + UConverterCallbackReason reason, + UErrorCode * err); + +U_CAPI debugCBContext *debugCB_openContext(); + +#endif diff --git a/Build/source/libs/icu/icu-xetex/samples/ucnv/readme.txt b/Build/source/libs/icu/icu-xetex/samples/ucnv/readme.txt new file mode 100644 index 00000000000..34c81ad6ff2 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ucnv/readme.txt @@ -0,0 +1,65 @@ +Copyright (C) 2002-2005, International Business Machines +Corporation and others. All Rights Reserved. + +convsamp: a sample program which demonstrates using ICU conversion + +This sample demonstrates + Opening and closing converters using the C api + String manipulation in 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.sln Windows MSVC workspace. Double-click this to get started. + ucnv.vcproj 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.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 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. + diff --git a/Build/source/libs/icu/icu-xetex/samples/ucnv/ucnv.sln b/Build/source/libs/icu/icu-xetex/samples/ucnv/ucnv.sln new file mode 100644 index 00000000000..9d22e6ab8cf --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ucnv/ucnv.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ucnv", "ucnv.vcproj", "{8C95060E-61F5-464E-BB42-95B788C0D7E4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8C95060E-61F5-464E-BB42-95B788C0D7E4}.Debug|Win32.ActiveCfg = Debug|Win32 + {8C95060E-61F5-464E-BB42-95B788C0D7E4}.Debug|Win32.Build.0 = Debug|Win32 + {8C95060E-61F5-464E-BB42-95B788C0D7E4}.Release|Win32.ActiveCfg = Release|Win32 + {8C95060E-61F5-464E-BB42-95B788C0D7E4}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/ucnv/ucnv.vcproj b/Build/source/libs/icu/icu-xetex/samples/ucnv/ucnv.vcproj new file mode 100644 index 00000000000..6da4a6c5a8c --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ucnv/ucnv.vcproj @@ -0,0 +1,231 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="ucnv" + ProjectGUID="{8C95060E-61F5-464E-BB42-95B788C0D7E4}" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <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" + TypeLibraryName=".\Debug/ucnv.tlb" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Debug/ucnv.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 odbc32.lib odbccp32.lib" + OutputFile=".\Debug/ucnv.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/ucnv.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="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" + TypeLibraryName=".\Release/ucnv.tlb" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE" + StringPooling="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Release/ucnv.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 odbc32.lib odbccp32.lib" + OutputFile=".\Release/ucnv.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + ProgramDatabaseFile=".\Release/ucnv.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=".\convsamp.cpp" + > + </File> + <File + RelativePath=".\flagcb.c" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl" + > + <File + RelativePath=".\flagcb.h" + > + </File> + </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/udata/Makefile b/Build/source/libs/icu/icu-xetex/samples/udata/Makefile new file mode 100644 index 00000000000..30927fc9860 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/udata/Makefile @@ -0,0 +1,69 @@ +# Copyright (c) 2000-2004 IBM, Inc. and others +# udata sample code +# Usage: +# - configure, build, install ICU +# - ensure that 'icu-config' is in the PATH (PREFIX/bin/icu-config) +# - if ICU is not built relative to this directory, +# set the variable ICU_PATH to the 'icu' directory +# (i.e. /foo/icu ) +# - do 'make' in this directory + + +# Include ICU standard definitions +include ../defs.mk + +# look for the ICU_PATH variable, guess if not there +ICU_DEFAULT_PATH=../../.. + +ifeq ($(strip $(ICU_PATH)),) + ICU_PATH=$(ICU_DEFAULT_PATH) +endif + +# Name of your target +TARGET1=reader +TARGET2=writer + +# All object files (C or C++) +OBJECTS1=reader.o +OBJECTS2=writer.o +OBJECTS=$(OBJECTS1) $(OBJECTS2) + +CLEANFILES=*~ $(TARGET).out + +all: $(TARGET1) $(TARGET2) + +# The following lines are to make sure ICU_PATH is set properly. +writer.o: $(ICU_PATH)/source/tools/toolutil/uoptions.h + +$(ICU_PATH)/source/tools/toolutil/uoptions.h: + @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 $(shell icu-config --ldflags-toolutil) + + +.PHONY: all clean distclean check report + +distclean clean: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + -$(RMV) $(OBJECTS) $(TARGET1) $(TARGET2) + +# Can change this to LINK.c if it is a C only program +# Can add more libraries here. +$(TARGET1): $(OBJECTS1) + $(CC) -o $@ $^ $(LDFLAGS) + +$(TARGET2): $(OBJECTS2) + $(CC) -o $@ $^ $(LDFLAGS) + +# Make check: simply runs the sample, logged to a file +check: $(TARGET1) $(TARGET2) + $(INVOKE) ./$(TARGET2) | tee $(TARGET2).out + $(INVOKE) ./$(TARGET1) | tee $(TARGET1).out + + diff --git a/Build/source/libs/icu/icu-xetex/samples/udata/reader.c b/Build/source/libs/icu/icu-xetex/samples/udata/reader.c new file mode 100644 index 00000000000..6cde9480335 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/udata/reader.c @@ -0,0 +1,131 @@ +/* + ******************************************************************************* + * + * Copyright (C) 1999-2004, International Business Machines + * Corporation and others. All Rights Reserved. + * + ******************************************************************************* + * file name: reader.c + * encoding: US-ASCII + * tab size: 8 (not used) + * indentation:4 + * + * created on: 2000sep5 + * created by: Vladimir Weinstein + */ + +/******************************************************************************* + * Derived from Madhu Katragadda gentest + *******************************************************************************/ + + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#ifdef WIN32 +#include <direct.h> +#else +#include <unistd.h> +#endif +#include "unicode/utypes.h" +#include "unicode/putil.h" +#include "unicode/udata.h" + +#define DATA_NAME "example" +#define DATA_TYPE "dat" + +/* UDataInfo cf. udata.h */ +static const UDataInfo dataInfo={ + sizeof(UDataInfo), + 0, + + U_IS_BIG_ENDIAN, + U_CHARSET_FAMILY, + sizeof(UChar), + 0, + + 0x4D, 0x79, 0x44, 0x74, /* dataFormat="MyDt" */ + 1, 0, 0, 0, /* formatVersion */ + 1, 0, 0, 0 /* dataVersion */ +}; + +static UBool +isAcceptable(void *context, + const char *type, const char *name, + const UDataInfo *pInfo){ + + if( pInfo->size>=20 && + pInfo->isBigEndian==U_IS_BIG_ENDIAN && + pInfo->charsetFamily==U_CHARSET_FAMILY && + pInfo->dataFormat[0]==0x4D && /* dataFormat="MyDt" */ + pInfo->dataFormat[1]==0x79 && + pInfo->dataFormat[2]==0x44 && + pInfo->dataFormat[3]==0x74 && + pInfo->formatVersion[0]==1 && + pInfo->dataVersion[0]==1 ) { + return TRUE; + } else { + return FALSE; + } + + +} + +extern int +main(int argc, const char *argv[]) { + UDataMemory *result = NULL; + UErrorCode status=U_ZERO_ERROR; + + uint16_t intValue = 0; + + char *string = NULL; + uint16_t *intPointer = NULL; + + const void *dataMemory = NULL; + char curPathBuffer[1024]; + +#ifdef WIN32 + char *currdir = _getcwd(NULL, 0); +#else + char *currdir = getcwd(NULL, 0); +#endif + + /* need to put "current/dir/pkgname" as path */ + strcpy(curPathBuffer, currdir); + strcat(curPathBuffer, U_FILE_SEP_STRING); + strcat(curPathBuffer, "mypkg"); /* package name */ + + result=udata_openChoice(curPathBuffer, DATA_TYPE, DATA_NAME, isAcceptable, NULL, &status); + + if(currdir != NULL) { + free(currdir); + } + + if(U_FAILURE(status)){ + printf("Failed to open data file example.dat in %s with error number %d\n", curPathBuffer, status); + return -1; + } + + dataMemory = udata_getMemory(result); + + intPointer = (uint16_t *)dataMemory; + + printf("Read value %d from data file\n", *intPointer); + + string = (char *) (intPointer+1); + + printf("Read string %s from data file\n", string); + + if(U_SUCCESS(status)){ + udata_close(result); + } + + return 0; +} + + + + + + + diff --git a/Build/source/libs/icu/icu-xetex/samples/udata/reader.vcproj b/Build/source/libs/icu/icu-xetex/samples/udata/reader.vcproj new file mode 100644 index 00000000000..2b393b9be23 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/udata/reader.vcproj @@ -0,0 +1,231 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="reader" + ProjectGUID="{BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory=".\reader_Win32_Debug" + IntermediateDirectory=".\reader_Win32_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" + TypeLibraryName=".\reader_Win32_Debug/reader.tlb" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\include,..\..\tools\toolutil" + PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\reader_Win32_Debug/reader.pch" + AssemblerListingLocation=".\reader_Win32_Debug/" + ObjectFile=".\reader_Win32_Debug/" + ProgramDataBaseFileName=".\reader_Win32_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" + OutputFile=".\reader_Win32_Debug/reader.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\reader_Win32_Debug/reader.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="Release|Win32" + OutputDirectory=".\reader_Win32_Release" + IntermediateDirectory=".\reader_Win32_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" + TypeLibraryName=".\reader_Win32_Release/reader.tlb" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="..\..\..\include,..\..\tools\toolutil" + PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE" + StringPooling="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\reader_Win32_Release/reader.pch" + AssemblerListingLocation=".\reader_Win32_Release/" + ObjectFile=".\reader_Win32_Release/" + ProgramDataBaseFileName=".\reader_Win32_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" + OutputFile=".\reader_Win32_Release/reader.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib" + ProgramDatabaseFile=".\reader_Win32_Release/reader.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=".\reader.c" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + AdditionalIncludeDirectories="..\..\..\include,..\..\tools\toolutil;..\..\icu\include;$(NoInherit)" + /> + </FileConfiguration> + </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/udata/readme.txt b/Build/source/libs/icu/icu-xetex/samples/udata/readme.txt new file mode 100644 index 00000000000..baccf626d34 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/udata/readme.txt @@ -0,0 +1,61 @@ +Copyright (c) 2002-2005, International Business Machines Corporation and others. All Rights Reserved. +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.sln Windows MSVC workspace. Double-click this to get started. + udata.vcproj 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.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 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. + diff --git a/Build/source/libs/icu/icu-xetex/samples/udata/udata.sln b/Build/source/libs/icu/icu-xetex/samples/udata/udata.sln new file mode 100644 index 00000000000..4a2e29ba8d4 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/udata/udata.sln @@ -0,0 +1,25 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reader", "reader.vcproj", "{BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "writer", "writer.vcproj", "{40A90302-F173-4629-A003-F571D2D93D16}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}.Debug|Win32.ActiveCfg = Debug|Win32 + {BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}.Debug|Win32.Build.0 = Debug|Win32 + {BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}.Release|Win32.ActiveCfg = Release|Win32 + {BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}.Release|Win32.Build.0 = Release|Win32 + {40A90302-F173-4629-A003-F571D2D93D16}.Debug|Win32.ActiveCfg = Debug|Win32 + {40A90302-F173-4629-A003-F571D2D93D16}.Debug|Win32.Build.0 = Debug|Win32 + {40A90302-F173-4629-A003-F571D2D93D16}.Release|Win32.ActiveCfg = Release|Win32 + {40A90302-F173-4629-A003-F571D2D93D16}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/udata/writer.c b/Build/source/libs/icu/icu-xetex/samples/udata/writer.c new file mode 100644 index 00000000000..db0b758e458 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/udata/writer.c @@ -0,0 +1,119 @@ +/* +******************************************************************************* +* +* Copyright (C) 1999-2006, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +* file name: writer.c +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:4 +* +* created on: 2000sep5 +* created by: Vladimir Weinstein +*/ + +/****************************************************************************** + * A program to write simple binary data readable by udata - example for + * ICU workshop + ******************************************************************************/ + + +#include <stdio.h> +#include <stdlib.h> +#ifdef WIN32 +#include <direct.h> +#else +#include <unistd.h> +#endif +#include "unicode/utypes.h" +#include "unicode/udata.h" + +/* this is private - available only through toolutil */ +#include "unewdata.h" + +#define DATA_NAME "mypkg_example" +#define DATA_TYPE "dat" + +/* UDataInfo cf. udata.h */ +static const UDataInfo dataInfo={ + sizeof(UDataInfo), + 0, + + U_IS_BIG_ENDIAN, + U_CHARSET_FAMILY, + sizeof(UChar), + 0, + + 0x4D, 0x79, 0x44, 0x74, /* dataFormat="MyDt" */ + 1, 0, 0, 0, /* formatVersion */ + 1, 0, 0, 0 /* dataVersion */ +}; + + +/* Excersise: add writing out other data types */ +/* see icu/source/tools/toolutil/unewdata.h */ +/* for other possibilities */ + +extern int +main(int argc, const char *argv[]) { + UNewDataMemory *pData; + UErrorCode errorCode=U_ZERO_ERROR; + char stringValue[]={'E', 'X', 'A', 'M', 'P', 'L', 'E', '\0'}; + uint16_t intValue=2000; + + long dataLength; + uint32_t size; +#ifdef WIN32 + char *currdir = _getcwd(NULL, 0); +#else + char *currdir = getcwd(NULL, 0); +#endif + + pData=udata_create(currdir, DATA_TYPE, DATA_NAME, &dataInfo, + U_COPYRIGHT_STRING, &errorCode); + + if(currdir != NULL) { + free(currdir); + } + + + if(U_FAILURE(errorCode)) { + fprintf(stderr, "Error: unable to create data memory, error %d\n", errorCode); + exit(errorCode); + } + + /* write the data to the file */ + /* a 16 bit value and a String*/ + printf("Writing uint16_t value of %d\n", intValue); + udata_write16(pData, intValue); + printf("Writing string value of %s\n", stringValue); + udata_writeString(pData, stringValue, sizeof(stringValue)); + + /* finish up */ + dataLength=udata_finish(pData, &errorCode); + if(U_FAILURE(errorCode)) { + fprintf(stderr, "Error: error %d writing the output file\n", errorCode); + exit(errorCode); + } + size=sizeof(stringValue) + sizeof(intValue); + + + if(dataLength!=(long)size) { + fprintf(stderr, "Error: data length %ld != calculated size %lu\n", dataLength, size); + exit(U_INTERNAL_PROGRAM_ERROR); + } + return 0; +} + + + + + + + + + + + diff --git a/Build/source/libs/icu/icu-xetex/samples/udata/writer.vcproj b/Build/source/libs/icu/icu-xetex/samples/udata/writer.vcproj new file mode 100644 index 00000000000..2cecd0c3ddb --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/udata/writer.vcproj @@ -0,0 +1,223 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="writer" + ProjectGUID="{40A90302-F173-4629-A003-F571D2D93D16}" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <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" + TypeLibraryName=".\Debug/writer.tlb" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\include,..\..\tools\toolutil" + PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Debug/writer.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="icutud.lib" + OutputFile=".\Debug/writer.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/writer.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="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" + TypeLibraryName=".\Release/writer.tlb" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="..\..\..\include,..\..\tools\toolutil" + PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE" + StringPooling="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Release/writer.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="icutu.lib" + OutputFile=".\Release/writer.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib" + ProgramDatabaseFile=".\Release/writer.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=".\writer.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/ufortune/Makefile b/Build/source/libs/icu/icu-xetex/samples/ufortune/Makefile new file mode 100644 index 00000000000..258959a8f5a --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ufortune/Makefile @@ -0,0 +1,55 @@ +# Copyright (c) 2001-2003 IBM, Inc. and others + +# +# File +# icu/source/samples/ufortune/Makefile +# +# Usage: +# - configure and build ICU [see the docs] .. use "--prefix=" something +# +# - do 'make install' of icu +# +# - make sure the script 'icu-config' is executable in your PATH +# +# - do 'gmake' in this directory +# - do 'gmake check' to run the sample. + + +# Load ICU information +include ../defs.mk + +include fortunedefs.mk + +# Name of your target +TARGET=ufortune + +# All object files (C or C++) +OBJECTS=ufortune.o + +# dir containing resources +RESDIR=resources + +# hook variables to tell rules.mk we want subdirectory processing +ALL_SUBDIR= all-$(RESDIR) +CLEAN_SUBDIR= clean-$(RESDIR) + +# Need: ustdio, and to link with ufortune +XTRALIBS=$(RESLDFLAGS) +LDFLAGS += $(LDFLAGS_USTDIO) +CPPFLAGS += $(RESCPPFLAGS) + +### Include standard rules +include ../rules.mk + +# subdirectory processing +all-$(RESDIR): + $(MAKE) -C $(RESDIR) + +clean-$(RESDIR): + -$(MAKE) -C $(RESDIR) clean + + +install-$(RESDIR): + $(MAKE) -C $(RESDIR) install + +install: install-$(RESDIR)
\ No newline at end of file diff --git a/Build/source/libs/icu/icu-xetex/samples/ufortune/fortunedefs.mk b/Build/source/libs/icu/icu-xetex/samples/ufortune/fortunedefs.mk new file mode 100644 index 00000000000..2d52788b17f --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ufortune/fortunedefs.mk @@ -0,0 +1,40 @@ +# Copyright (c) 2001-2002 IBM, Inc. and others +# common makefile between ufortune and ufortune/resources + +# mode of resource bundle - +# you can change this to: +# dll - will create a dynamically linked library +# (may require 'make install' in resources subdir for +# proper library installation) +# +# static - will statically link data into ufortune +# +# common - will create fortune_resources.dat in the resources subdir +# (must be locatable by ICU_PATH - use 'make check') +# +# files - will use separate files, such as es.res, fi.res, etc. +# (use 'make check') +# +RESMODE=static + +# Resource shortname +RESNAME=fortune_resources + +RESLDFLAGS= +# Don't call udata_setAppData unless we are linked with the data +RESCPPFLAGS=-DUFORTUNE_NOSETAPPDATA +CHECK_VARS= ICU_DATA=$(RESDIR) + +# DLL and static modes are identical here +ifeq ($(RESMODE),dll) +RESLDFLAGS= -L$(RESDIR) -l$(RESNAME) +RESCPPFLAGS= +CHECK_VARS= +endif + +ifeq ($(RESMODE),static) +RESLDFLAGS= -L$(RESDIR) -l$(RESNAME) +RESCPPFLAGS= +CHECK_VARS= +endif + diff --git a/Build/source/libs/icu/icu-xetex/samples/ufortune/readme.txt b/Build/source/libs/icu/icu-xetex/samples/ufortune/readme.txt new file mode 100644 index 00000000000..3ad4425453e --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ufortune/readme.txt @@ -0,0 +1,66 @@ +Copyright (c) 2002-2005, International Business Machines Corporation and others. All Rights Reserved. +ufortune: a sample program demonstrating the use of ICU resource files by an application. + +This sample demonstrates + Defining resources for use by an application + Compiling and packaging them into a dll + Referencing the resource-containing dll from application code + Loading resource data using ICU's API + +Files: + ./ufortune.c source code for the sample + ./ufortune.sln Windows MSVC workspace. Double-click this to get started. + ./ufortune.vcproj Windows MSVC project file. + ./Makefile Makefile for Unixes. Needs gmake. + resources/root.txt Default resources (text for messages in English) + resources/es.txt Spanish language resources source file.. + resources/res-file-list.txt List of resource source files to be built + resources/Makefile Makefile for compiling resources, for Unixes. + + +To Build ufortune on Windows + 1. Install and build ICU + 2. In MSVC, open the workspace file icu\samples\ufortune\ufortune.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 ufortune directory, e.g. + cd c:\icu\source\samples\ufortune\debug + 4. Run it + ufortune + + +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 the sample + cd <icu directory>/source/samples/ufortune + export ICU_PREFIX= <icu install directory> + gmake + + To Run on Unixes + cd <icu directory>/source/samples/ufortune + + gmake check + or + export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH + ufortune + + + 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/ufortune/resources/Makefile b/Build/source/libs/icu/icu-xetex/samples/ufortune/resources/Makefile new file mode 100644 index 00000000000..998a7a82557 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ufortune/resources/Makefile @@ -0,0 +1,60 @@ +# Copyright (c) 2001-2006 IBM, Inc. and others +# +# File +# icu/source/samples/ufortune/resources/Makefile +# +# Usage: +# See the instructions in the parent Makefile, +# icu/source/samples/ufortune/Makefile. +# This subproject builds the ICU resource files for ufortune. +# It is normally invoked from the parent directory, +# although the resources can be built from here. +# +# Two ICU tools are run from this makefile: +# genrb compiles a resource source file (.txt) into +# a binary .res file. +# pkgdata combines all of the .res files into a single +# shared library that can then be linked with the +# main application. +# +# pkgdata will recursively generate and run yet +# another makefile, which in turn runs two more +# icu tools. gencmn combines the individual .res +# files, and genccode emits the data as C source +# code that can then be built into a .so +# + +include ../../defs.mk + +# No conventional target - this dir is resources only. +TARGET= +CLEANFILES += *.[co] *.lst $(RESNAME)_*.mak $(RESNAME).dat $(RESFILES) *.ao README*resources.txt + +include ../fortunedefs.mk + +# target file for resource bundle - this must be set, or 'make all' won't +# build any resources. +ifeq ($(RESMODE),dll) +RESTARGET=lib$(RESNAME).$(SO) +endif +ifeq ($(RESMODE),static) +RESTARGET=lib$(RESNAME).a +endif + +# Resource files. Add new ones for additional locales here. +# keep in sync with the file RESLIST +RESFILES=root.res es.res + +# list of resource bundles - keep in sync with RESFILES +RESLIST=res-file-list.txt + +## Include standard rules +include ../../rules.mk + +# for installing the library +install: res-install + +es.res: es.txt + @echo "generating $@" + $(GENRB) $(GENRBOPT) $^ + diff --git a/Build/source/libs/icu/icu-xetex/samples/ufortune/resources/es.txt b/Build/source/libs/icu/icu-xetex/samples/ufortune/resources/es.txt new file mode 100644 index 00000000000..1500b70dd87 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ufortune/resources/es.txt @@ -0,0 +1,471 @@ +// Copyright (C) 2001-2006, International Business Machines +// Corporation and others. All Rights Reserved. + +// +// es.txt +// +// Spanish resource file for ufortune sample program for ICU. +// + +// ufortune has three resources +// usage - the usage string to display if there's a command line error +// or in response to -? or --help. +// optionMessage - the error text to display in response to an unrecognized +// option on the command line. +// fortunes - An array of strings, the fortune messages. +// + +es { + + usage {"usage: ufortune [-v] [-l locale]"} + optionMessage {"unrecognized command line option:"} + + + + fortunes { + + +"Todo lo que no tiene solución no se soluciona, y lo que la tiene tampoco. + -- Bill Gates. (1952?) Fundador de Microsoft. Del manual de Windows 95. ", + +"El hombre todavÃa puede apagar el ordenador. Sin embargo, tendremos que esforzarnos mucho para conservar este privilegio. + -- J. Weizembaum. Sociólogo norteamericano experto en ordenadores. ", + +"El ordenador ha sido hasta ahora el producto más genial de la vagancia humana. + -- Slogan de IBM. ", + +"La página WEB es el soporte interactivo ideal para ofrecer un servicio, facilitar información, hacer negocio, etc de un modo más completo y directo que cualquier otro. + -- Vinton Cerf. (1934) Padre de Internet. (Fundador de Internet Society). ", + +"TodavÃa hay mucha gente que ofrece contenidos por el mero placer de saber que la información puede resultar útil a otras personas. + -- Vinton Cerf. (1934) Padre de Internet. (Fundador de Internet Society). ", + +"En no mucho tiempo contaremos con unas lÃneas inteligentes y que estarán totalmente integradas con la Red. + -- Vinton Cerf. (1934) Padre de Internet. (Fundador de Internet Society). ", + +"En el futuro no se usará MODEM para acceder a Internet. + -- Vinton Cerf. (1934) Padre de Internet. (Fundador de Internet Society). ", + +"En el año 2005 los chips serán tan baratos que los encontraremos en todas partes: la nevera, la lavadora y cualquier otro electrodoméstico. + -- Vinton Cerf. (1934) Padre de Internet. (Fundador de Internet Society). ", + +"Internet 2 será 100 veces más rápida. + -- Irving Wladawsky-Berger. Director General de la División Internet de IBM. ", + +"Windows 95 está colgando su sistema. Por favor espere... + -- Nugar. Internauta y Webmaster panameño. ", + +"No pensábamos en el negocio, sino en Internet como una forma de comunicación global. + -- Jerry Yang. Uno de los creadores de Yahoo!. ", + +"iusfbvksagsvkjsh bvkdns Maldita Gata!!! Bájate del tecladonlagnlbhl + -- Stepi taglines. ", + +"Sueter ke mis mesages pashan po el coretor otójraf + -- Stepi taglines. ", + +"User error: Replace user, hit any key to continue. + -- Stepi taglines. ", + +"SOFTWARE: Aquello que solamente puedes maldecir. + -- Yo. ", + +"HARDWARE: Lo que puedes partir con un hacha. + -- Yo. ", + +"¿Cuál es la patrona de los informáticos? - Santa Tecla. + -- Yo. ", + +"Eres más falso que Windows 95 a prueba de fallos. + -- Yo. ", + +"Gabardinas Windows 95 se cuelgan solas. + -- Yo. ", + +"El hijo de Bill Gates fue por causa de un 'ERROR DE PROTECCION GENERAL'. + -- Yo. ", + +"¿Alguien sabe qué es lo bueno de Windows 95?... Yo tampoco. + -- Yo. ", + +"Multitarea: Dos o más programas pueden fallar simultáneamente. + -- Yo. ", + +"...aquella masa de solidificada razón de dieciséis kilómetros de longitud, a la que los hombres llamaban Multivac, el más complejo ordenador jamás construido. + -- Isaac Asimov. (1920-1992) Escritor y cientÃfico estadounidense. Fragmento del cuento 'El chistoso'. ", + +"Press (Ctrl)(Alt)(Del) to continue... + -- PC Users. La mejor revista de computación del mundo. ", + +"Si debbuging es el proceso de eliminar errores, entonces la programación debe ser el proceso de ponerlos. + -- PC Users. La mejor revista de computación del mundo. ", + +"Hay dos formas de escribir programas sin errores. Sólo la tercera funciona. + -- PC Users. La mejor revista de computación del mundo. ", + +"No confÃes en una PC que no puedas tirar por la ventana. + -- Steve Wozniak. ", + +"Si los arquitectos hiciesen edificios de la misma forma en que los programadores escriben programas, el primer pájaro carpintero que pasase por aquà destruirÃa la civilización. + -- Gerald Weimberg. ", + +"Las PCs no son inteligentes, sólo creen que lo son. + -- PC Users. La mejor revista de computación del mundo. ", + +"S pd lr sto, usd pd btnr n ben trbjo cm prgdor d P. + -- PC Users. La mejor revista de computación del mundo. ", + +"SHIFT TO LEFT! SHIFT TO THE RIGHT! POP UP, PUSH DOWN, BYTE, BYTE, BYTE! + -- Universidad de Massachussets. Utilizado en la toga del equipo para las olimpiadas informáticas. ", + +"Por cada error que se le atribuye a una PC siempre se encuentran al menos dos errores humanos: el de culpar a la PC y el de confiar en ella. + -- PC Users. La mejor revista de computación del mundo. PC Users Nº 68. ", + +"Todo programa hace algo perfectamente bien, aunque no sea exactamente lo que nosotros queremos que haga. + -- R.S. Pressmann. PC Users Nº 68. ", + +"El programa es totalmente perfecto, por lo tanto la PC es que debe andar mal. + -- Cualquier programador. PC Users Nº 68. ", + +"El veloz murciélago hindú comia feliz cardillo y kiwi, La cigueña tocaba el saxofón detrás del palenque de paja. + -- Microsoft. Frase de ejemplo para probar los fonts de Windows. (¿De dónde la sacaron?). ", + +"La red mundial de Internet nos permite a hombres y mujeres llegar a los rincones más desconocidos y comunicarnos, es como llegar con la luz del sol a los lugares donde todo parece noche. + -- Hebe de Bonafini. Presidenta de Madres de Plaza de Mayo. ", + +"En China hay 1200 millones de personas que podrÃan entrar a Internet, pero por ahora tiene otros asuntos prioritarios que atender, como muchos otros paises. + -- Matt Stein. Representante internacional de Yahoo. ", + +"Ahora ya no se pregunta si tenés email, te lo piden directamente. + -- Matt Stein. Representante internacional de Yahoo. ", + +"En Argentina veo que el mercado se está expandiendo rápido, casi todo el mundo habla de Internet y hay muchos expertos. La gente común conoce el tema. + -- Matt Stein. Representante internacional de Yahoo. ", + +"...pronto no se necesitará un computadora para acceder a la Red, estarán los asistentes personales, la TV, los relojes inteligentes y otros. + -- Matt Stein. Representante internacional de Yahoo. ", + +"Los programadores de verdad hacen 'copy con program.exe' + -- PC Users. La mejor revista de computación del mundo. ", + +"Las computadoras de Minardi usan Windows 95. + -- Esteban Tuero. ", + +"El casco del Titanic fue diseñado con Windows 95. + -- Www.frases.com. ", + +"Dinner not ready: (A)bort (R)etry (P)izza (M)cDonalds? + -- Www.frases.com. ", + +"Amante: Versión shareware de esposa. + -- Www.frases.com. ", + +"Las computadoras hacen lo que usted manda. No lo que usted quiere. + -- Www.frases.com. ", + +"No preciso comer ni dormir. ¡Compré un MODEM! + -- Www.frases.com. ", + +"Mi mujer me dijo: O el MODEM o yo. (A veces la extraño). + -- Www.frases.com. ", + +"¿Cuál es la diferencia entre un virus y Windows 95? - El virus funciona. + -- Www.frases.com. ", + +"¿Qué es 200 veces peor que OS/2?: AS-400. + -- Www.frases.com. ", + +"La piraterÃa es un crimen. No ataque barcos. + -- Www.frases.com. ", + +"¿Usted tiene un micro? El mÃo es enorme... + -- Www.frases.com. ", + +"DoubleSpace: Compactando datos y Expandiendo Problemas. + -- Www.frases.com. ", + +"¿Usted le sonrió a su computador hoy? ¿Si? ¡Más que imbécil! + -- Www.frases.com. ", + +"Merdasemerompiólabarraespaciadora. + -- Www.frases.com. ", + +"Si no consigue encontrar el problema, seguro es el BIOS (Bichito Ignorante Operando Sistema). + -- Www.frases.com. ", + +"¿US Robotics? ¿Para qué? Mi Zoltrix vue$$@@!!‘œœ/!(*!3... + -- Www.frases.com. ", + +"¿Por qué uso drogas? Tengo una 286... + -- Www.frases.com. ", + +"El computador nació para resolver problemas que antes no existÃan. + -- Www.frases.com. ", + +"Amar es... borrar el Windows del disco de ella. + -- Www.frases.com. ", + +"HTML: Hoy Tá Más Lento. + -- Www.frases.com. ", + +"WWW: Wait, Wait, Wait... + -- Www.frases.com. ", + +"Nueva tecnologÃa de periféricos: Plug-and-Crack! + -- Www.frases.com. ", + +"¿Sabe por qué Intel no llamó 586 al Pentium? Porque ellos sumaron 486+100 y les dió 585,99999976542 + -- Www.frases.com. ", + +"¿De dónde venimos? ¿Para dónde vamos? - ¿La respuesta, estará en Internet? + -- Www.frases.com. ", + +"A mi me gustarÃa criar homepages, pero no sé que comen. + -- Www.frases.com. ", + +"Windows 95 es realmente un sistema multitarea. Es el único que consigue formatear un diskette y colgar el micro al mismo tiempo. + -- Www.frases.com. ", + +"Windows 95: La gracia para quien lo vé, la desgracia de quien lo usa. + -- Www.frases.com. ", + +"yO connsigg diggtr 400 caartrerrees prr minnuut + -- Www.frases.com. ", + +"Scan report: Windows found. Remove it? (Y/Y) + -- Www.frases.com. ", + +"Si Bill Gates es un dios, Windows debe ser una plaga divina. + -- Www.frases.com. ", + +"BBS e Internet: Métodos infalibles para duplicar su cuenta telefónica. + -- Www.frases.com. ", + +"No se te ocurra usar el teléfono para llamar a los bomberos. Estoy en lo mejor de un download!!! + -- Www.frases.com. ", + +"Si Internet se está tornando una enfermedad, mi destino ya esta trazado... + -- Www.frases.com. ", + +"Compre un MODEM, navegue en Internet: gane amigos y pierda a su mujer. + -- Www.frases.com. ", + +"Si Jesús salva, Norton hace Backup. + -- Www.frases.com. ", + +"Computador que es un carro, siempre tiene un burro adelante. + -- Www.frases.com. ", + +"Error: Preservativo agujereado. (A)bortar (I)gnorar (C)asar? + -- Www.frases.com. ", + +"Un gay se sienta ante una PC y escribe: ¡Oh máquina maravillosa ¿por qué no me hablas? Y la PC responde: Yo no hablo, COMPUTO! + -- Www.frases.com. ", + +"UNDELETE *.* /P/O/R/F/A/V/O/R + -- Www.frases.com. ", + +"RAM: Raramente Adecuada Memoria. + -- Www.frases.com. ", + +"Winchester: Chester for Windows??? + -- Www.frases.com. ", + +"La más nueva tecnologÃa de transferencia de datos entre computadores es DPA / DPA (Diskette Para Allá , Diskette Para Acá). + -- Www.frases.com. ", + +"Novia embarazada: (A)borta (R)econoce (H)uye? + -- Www.frases.com. ", + +"Deltree Windows, THE REAL DOUBLESPACE!!!! + -- Www.frases.com. ", + +"Chernobil usaba Windows 95 para monitorear sus reactores. + -- Www.frases.com. ", + +"Papá, ¿qué significa formatting drive C? + -- Www.frases.com. ", + +"El Universo por nosotros conocido es apenas una versión beta. + -- Www.frases.com. ", + +"Windows 95: Ahora para Mega Drive y Nintendo! + -- Www.frases.com. ", + +"Como transformar un 486 DX4 en XT: digite win + -- Www.frases.com. ", + +"Programador huérfano busca placa-madre. + -- Www.frases.com. ", + +"Teclado no instalado! Presione para continuar. + -- Www.frases.com. ", + +"Mouse no encontrado. ¿Usted tiene gato? (S/N) + -- Www.frases.com. ", + +"Windows 95. 95 veces tendrá que re-instalarlo. + -- Www.frases.com. ", + +"Si su Windows no le dá problemas. ¡Reclame a Microsoft! + -- Www.frases.com. ", + +"Error: Sector not found. ¿Busco atrás del sofá? (S/N) + -- Www.frases.com. ", + +"MACINTOSH: Machine Always Crashes; If Not, Then OS Hangs. + -- Www.frases.com. ", + +"Error al accesar la FAT. ¿Intento accesar a tu hermana? (S/N) + -- Www.frases.com. ", + +"Los gatos de Intel tienen 6,99995634563 vidas. + -- Www.frases.com. ", + +"Aquel que nunca perdió un archivo, que tire el primer diskette. + -- Www.frases.com. ", + +"Chip, imposible comer uno, es horrible! + -- Www.frases.com. ", + +"Multitarea: Destrozar muchas cosas al mismo tiempo. + -- Www.frases.com. ", + +"Bill Gates, 1981: 640K son suficientes para cualquiera. + -- Www.frases.com. ", + +"No confunda MODEM con MODESS... el slot es diferente. + -- Www.frases.com. ", + +"Chequeando virus... Todos los virus funcionan perfectamente. + -- Www.frases.com. ", + +"Donald usa teclado. Mickey, Mouse. + -- Www.frases.com. ", + +"Errar es Humano. Redondear es Pentium. + -- Www.frases.com. ", + +"Mi HD tiene 100K de bad-sector y 130M de bad-windows. + -- Www.frases.com. ", + +"Papá ¿porqué el imán no se pega en tus diskettes? + -- Www.frases.com. ", + +"Ya que la primera impresión es lo que vale, entonces use una impresora LASER. + -- Www.frases.com. ", + +"SeR²qu®lehace mAlelcaféalte‘lado? + -- Www.frases.com. ", + +"qUIEN mE sACO lA tECLA cAPSLOCK/ + -- Www.frases.com. ", + +"Técnico por teléfono: Inserte el disco 3. Usuario: No cabe, ya metà dos, no entran más. + -- Www.frases.com. ", + +"¡Ah! Aquellos DLLs estaban ocupando mucho espacio. + -- Www.frases.com. ", + +"La mayorÃa de los virus son transmitidos por la orina del MOUSE. + -- Www.frases.com. ", + +"Archivo no encontrado... ¿Falsifico? (S/N) + -- Www.frases.com. ", + +"Email de Esteban Tuero: ultimo.lugar@grid.f1.com + -- Www.frases.com. ", + +"Preserve el planeta: use monitores CGA. + -- Www.frases.com. ", + +"Press any key to continue or other key to quit. + -- Www.frases.com. ", + +"¿Quién es ese General Failure? ¿Porque se mete con mi disco rÃgido? + -- Www.frases.com. ", + +"Chips de computadora, disponibles en dos sabores: batata y silicio. + -- Www.frases.com. ", + +"Backup no encontrado. (J)a! J(a)! Ja(!). + -- Www.frases.com. ", + +"Cuanto más inútil el programa, mejor el manual. + -- Www.frases.com. ", + +"Programa de computador: Extraña forma de vida que tiene la capacidad de transformar comandos en mensajes de error. + -- Www.frases.com. ", + +"OUT OF MEMORY. Please use MEMOROL x 10Mg. + -- Www.frases.com. ", + +"Cálmese. Son sólo 0s y 1s. + -- Www.frases.com. ", + +"Muestrame tus bookmarks, y te diré quien eres. + -- Www.frases.com. ", + +"System Error: Press F13 to continue. + -- Www.frases.com. ", + +"Yo gusto de Windows 95, es él que no gusta de mÃ. + -- Www.frases.com. ", + +"En la pelÃcula Independence Day, no fue un virus lo que los americanos colocaron en el computador de la Nave Madre. ¡Instalaron Windows 95! + -- Www.frases.com. ", + +"/=*=\ ¡Cuidado! Si usted tuviese una TK-85 eso serÃa una nave enemiga. + -- Www.frases.com. ", + +"La Navidad de las personas viciadas por la computadora es diferente: El 25 de diciembre, Papá Noel baja por el MODEM y desde el puerto serie dice: ¡Feliz Navidad, ROM, ROM, ROM! + -- Www.frases.com. ", + +"Usuario: ¿Usuario?, ¿qué usuario???? El que te conectó atrás del armario. + -- Www.frases.com. ", + +"Bienaventurados los pesimistas, porque ellos harán backups. + -- Www.frases.com. ", + +"Existen dos tipos de personas en el mundo de la informática: Las que ya perdieron su HD y las que lo perderán algún dia. + -- Www.frases.com. ", + +"Internet es el florecimiento de los sitios eróticos familiares. + -- Gerard Van der Leun. Jefe de redacción de la revista Penthouse. ", + +"Toda la industria de valores se mudará a la Red. + -- Louis Gerstner. Gerente General de IBM. ", + +"La computadora converge con la televisión como lo hizo el automóvil con el caballo. + -- George Gilder. ", + +"Los nombres de dominio se han convertido en commodities. + -- Jon Postel. Presidente de IANA. ", + +"La idea de que las computadoras deberÃan hablar un lenguaje unificado fue robada de los tiempos en que los cavernÃcolas se comunicaban a través de sus pinturas rupestres. + -- Scott McNeally. Sun Microsystems. ", + +"Creo que para el año 2000, las network computers (NCs) superarán en ventas a las computadoras personales (PCs). + -- Larry Ellison. Gerente General de Oracle. ", + +"Cuando percibà que todos finalmente tendrÃan su propio home page, tuve la inspiración de regalar home pages y organizarlas en categorÃas. + -- David Bohnett. Presidente de Geocities. (Idolo). ", + +"Creo que hay un mercado mundial para alrededor de cinco computadoras. + -- Tomas J. Watson. Fundador de IBM. ", + +"No hay ninguna razón para que un individuo tenga una computadora en su casa. + -- Kennet Olsen. Fundador de Digital Equipment Corporation. ", + +"Los ordenadores son inútiles. Sólo pueden darte respuestas. + -- Pablo Picasso. (1881-1973) Pintor español. ", + +"El éxito de un sistema de computación depende en gran medida de los controles que se le efectuan. + -- Ley de la programación de ordenadores. ", + +"No se fÃe de los ordenadores, pero menos aun de los seres humanos. + -- Primera Ley de fiabilidad de Gilb. " + + } +} + diff --git a/Build/source/libs/icu/icu-xetex/samples/ufortune/resources/fortune_resources.mak b/Build/source/libs/icu/icu-xetex/samples/ufortune/resources/fortune_resources.mak new file mode 100644 index 00000000000..fd06568f99d --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ufortune/resources/fortune_resources.mak @@ -0,0 +1,45 @@ +# Copyright (c) 2001-2006 IBM, Inc. and others +# +# fortune_resources.mak +# +# Windows nmake makefile for compiling and packaging the resources +# for for the ICU sample program "ufortune". +# +# This makefile is normally invoked by the pre-link step in the +# MSVC project file for ufortune + +# +# List of resource files to be built. +# When adding a resource source (.txt) file for a new locale, the corresponding +# .res file must be added to this list, AND to the file res-file-list.txt +# +RESFILES= root.res es.res + +# +# ICUDIR the location of ICU, used to locate the tools for +# compiling and packaging resources. +# +ICUDIR=..\..\..\.. + +# +# File name extensions for inference rule matching. +# clear out the built-in ones (for .c and the like), and add +# the definition for .txt to .res. +# +.SUFFIXES : .txt + +# +# Inference rule, for compiling a .txt file into a .res file. +# -t fools make into thinking there are files such as es.res, etc +# +.txt.res: + $(ICUDIR)\bin\genrb -d . $*.txt + +# +# all - nmake starts here by default +# +all: fortune_resources.dll + +fortune_resources.dll: $(RESFILES) + $(ICUDIR)\bin\pkgdata --name fortune_resources -v --mode dll -d . res-file-list.txt + diff --git a/Build/source/libs/icu/icu-xetex/samples/ufortune/resources/res-file-list.txt b/Build/source/libs/icu/icu-xetex/samples/ufortune/resources/res-file-list.txt new file mode 100644 index 00000000000..aa183e9dfb9 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ufortune/resources/res-file-list.txt @@ -0,0 +1,2 @@ +root.res +es.res diff --git a/Build/source/libs/icu/icu-xetex/samples/ufortune/resources/root.txt b/Build/source/libs/icu/icu-xetex/samples/ufortune/resources/root.txt new file mode 100644 index 00000000000..da6ccd778b6 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ufortune/resources/root.txt @@ -0,0 +1,213 @@ +// Copyright (C) 2001-2003, International Business Machines +// Corporation and others. All Rights Reserved. +// +// root.txt +// +// root resource file for ufortune. +// This data will be used as a fall-back if no other resource bundle +// matches the requested locale. +// + +// ufortune has three resources +// usage - the usage string to display if there's a command line error +// or in response to -? or --help. +// optionMessage - the error text to display in response to an unrecognized +// option on the command line. +// fortunes - An array of strings, the fortune messages. +// + +root { + + usage {"usage: ufortune [-v] [-l locale]"} + optionMessage {"unrecognized command line option:"} + + +// +// These fortune messages are from BSD fortune data files. + + fortunes { + + +"186,282 miles per second: + +It isn't just a good idea, it's the law!", + +"2180, U.S. History question: + What 20th Century U.S. President was almost impeached and what +office did he later hold?", + +"$3,000,000", + +"355/113 -- Not the famous irrational number PI, but an incredible +simulation!\"", + +"3 syncs represent the trinity - init, the child and the eternal zombie +process. In doing 3, you're paying homage to each and I think such +traditions are important in this shallow, mercurial business we find +ourselves in. + -- Jordan K. Hubbard", + +"43rd Law of Computing: + Anything that can go wr +fortune: Segmentation violation -- Core dumped", + +"7:30, Channel 5: The Bionic Dog (Action/Adventure) + The Bionic Dog drinks too much and kicks over the National + Redwood Forest.", + +"7:30, Channel 5: The Bionic Dog (Action/Adventure) + The Bionic Dog gets a hormonal short-circuit and violates the + Mann Act with an interstate Greyhound bus.", + +"99 blocks of crud on the disk, +99 blocks of crud! +You patch a bug, and dump it again: +100 blocks of crud on the disk! + +100 blocks of crud on the disk, +100 blocks of crud! +You patch a bug, and dump it again: +101 blocks of crud on the disk! ...", + +"A \"No\" uttered from deepest conviction is better and greater than a +\"Yes\" merely uttered to please, or what is worse, to avoid trouble. + -- Mahatma Ghandi", + +"A [golf] ball hitting a tree shall be deemed not to have hit the tree. +Hitting a tree is simply bad luck and has no place in a scientific +game. The player should estimate the distance the ball would have +traveled if it had not hit the tree and play the ball from there, +preferably atop a nice firm tuft of grass. + -- Donald A. Metz", + +"A [golf] ball sliced or hooked into the rough shall be lifted and +placed in the fairway at a point equal to the distance it carried or +rolled into the rough. Such veering right or left frequently results +from friction between the face of the club and the cover of the ball +and the player should not be penalized for the erratic behavior of the +ball resulting from such uncontrollable physical +phenomena. + -- Donald A. Metz", + +"A baby is an alimentary canal with a loud voice at one end and no +responsibility at the other.", + +"A baby is God's opinion that the world should go on. + -- Carl Sandburg", + +"A bachelor is a selfish, undeserving guy who has cheated some woman out +of a divorce. + -- Don Quinn", + +"A banker is a fellow who lends you his umbrella when the sun is shining +and wants it back the minute it begins to rain. + -- Mark Twain", + +"A billion here, a couple of billion there -- first thing you know it +adds up to be real money. + -- Senator Everett McKinley Dirksen", + +"A bird in the bush usually has a friend in there with him.", + +"A bird in the hand is worth what it will bring.", + +"A bird in the hand makes it awfully hard to blow your nose.", + +"... A booming voice says, \"Wrong, cretin!\", and you notice that you +have turned into a pile of dust.", + +"A bore is someone who persists in holding his own views after we have +enlightened him with ours.", + +"A budget is just a method of worrying before you spend money, as well +as afterward.", + +"A candidate is a person who gets money from the rich and votes from the +poor to protect them from each other.", + +"A celebrity is a person who is known for his well-knownness.", + +"A child can go only so far in life without potty training. It is not +mere coincidence that six of the last seven presidents were potty +trained, not to mention nearly half of the nation's state legislators. + -- Dave Barry", + +"A child of five could understand this! Fetch me a child of five.", + +"A chubby man with a white beard and a red suit will approach you soon. +Avoid him. He's a Commie.", + +"A citizen of America will cross the ocean to fight for democracy, but +won't cross the street to vote in a national election. + -- Bill Vaughan", + +"A city is a large community where people are lonesome together + -- Herbert Prochnow", + +"A classic is something that everybody wants to have read and nobody +wants to read. + -- Mark Twain", + +"A closed mouth gathers no foot.", + +"A computer, to print out a fact, +Will divide, multiply, and subtract. + But this output can be + No more than debris, +If the input was short of exact. + -- Gigo", + +"A conclusion is simply the place where someone got tired of thinking.", + +"A CONS is an object which cares. + -- Bernie Greenberg.", + +"A consultant is a person who borrows your watch, tells you what time it +is, pockets the watch, and sends you a bill for it.", + +"A continuing flow of paper is sufficient to continue the flow of paper. + -- Dyer", + +"A copy of the universe is not what is required of art; one of the +damned things is ample. + -- Rebecca West", + +"A countryman between two lawyers is like a fish between two cats. + -- Ben Franklin", + +"A crusader's wife slipped from the garrison +And had an affair with a Saracen. + She was not oversexed, + Or jealous or vexed, +She just wanted to make a comparison.", + +"A cynic is a person searching for an honest man, with a stolen +lantern. + -- Edgar A. Shoaff", + +"A day for firm decisions!!!!! Or is it?", + +"A day without sunshine is like night.", + +"A diplomat is a man who can convince his wife she'd look stout in a fur +coat.", + +"A diplomat is someone who can tell you to go to hell in such a way that +you will look forward to the trip.", + +" A disciple of another sect once came to Drescher as he was +eating his morning meal. \"I would like to give you this personality +test\", said the outsider, \"because I want you to be happy.\" + Drescher took the paper that was offered him and put it into +the toaster -- \"I wish the toaster to be happy too\".", + +"A diva who specializes in risque arias is an off-coloratura soprano ...", + +" A doctor, an architect, and a computer scientist were arguing +about whose profession was the oldest. In the course of their +arguments, they got all the way back to the Garden of Eden, whereupon +the doctor said, \"The medical profession is clearly the oldest, because +Eve was made from Adam's rib, as the story goes, and that was a simply +incredible surgical feat.\" " + } +}
\ No newline at end of file diff --git a/Build/source/libs/icu/icu-xetex/samples/ufortune/ufortune.c b/Build/source/libs/icu/icu-xetex/samples/ufortune/ufortune.c new file mode 100644 index 00000000000..1adf999009e --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ufortune/ufortune.c @@ -0,0 +1,202 @@ +/************************************************************************** +* +* Copyright (C) 2001-2006, International Business Machines +* Corporation and others. All Rights Reserved. +* +*************************************************************************** +* +* ufortune - An ICU resources sample program +* +* Demonstrates +* Defining resources for use by an application +* Compiling and packaging them into a dll +* Referencing the resource-containing dll from application code +* Loading resource data using ICU's API +* +* Created Nov. 7, 2001 by Andy Heninger +* +* ufortune is a variant of the Unix "fortune" command, with +* ICU resources that contain the fortune-cookie sayings. +* Using resources allows fortunes in different languages to +* be selected based on locale. +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#include "unicode/udata.h" /* ICU API for data handling. */ +#include "unicode/ures.h" /* ICU API for resource loading */ +#include "unicode/ustdio.h" /* ICU API for reading & writing Unicode data */ + /* to files, possibly including character */ + /* set conversions. */ +#include "unicode/ustring.h" + +#ifndef UFORTUNE_NOSETAPPDATA +/* + * Resource Data Reference. The data is packaged as a dll (or .so or + * whatever, depending on the platform) that exports a data + * symbol. The application (that's us) references that symbol, + * here, and will pass the data address to ICU, which will then + * be able to fetch resources from the data. + */ +extern const void U_IMPORT *fortune_resources_dat; +#endif + +void u_write(const UChar *what, int len); + + +/* + * main() This one function is all of the application code. + */ +int main(int argc, char **argv) +{ + UBool displayUsage = FALSE; /* Set true if command line err or help */ + /* option was requested. */ + UBool verbose = FALSE; /* Set true if -v command line option. */ + char *optionError = NULL; /* If command line contains an unrecognized */ + /* option, this will point to it. */ + char *locale=NULL; /* Locale name. Null for system default, */ + /* otherwise set from command line. */ + const char * programName = argv[0]; /* Program invocation name. */ + + + UFILE *u_stdout; /* Unicode stdout file. */ + UErrorCode err = U_ZERO_ERROR; /* Error return, used for most ICU */ + /* functions. */ + + UResourceBundle *myResources; /* ICU Resource "handles" */ + UResourceBundle *fortunes_r; + + int32_t numFortunes; /* Number of fortune strings available. */ + int i; + + const UChar *resString; /* Points to strings fetched from Resources. */ + int32_t len; + + + /* Process command line options. + * -l locale specify a locale + * -v verbose mode. Display extra messages. + * -? or --help display a usage line + */ + for (i=1; i<argc; i++) { + if (strcmp(argv[i], "-l") ==0) { + if (++i < argc) { + locale = argv[i]; + } + continue; + } + if (strcmp(argv[i], "-v") == 0) { + verbose = TRUE; + continue;} + if (strcmp(argv[i], "-?") == 0 || + strcmp(argv[i], "--help") == 0) { + displayUsage = TRUE; + continue;} + optionError = argv[i]; + displayUsage = TRUE; + break; + } + + /* ICU's icuio package provides a convenient way to write Unicode + * data to stdout. The string data that we get from resources + * will be UChar * strings, which icuio can handle nicely. + */ + u_stdout = u_finit(stdout, NULL /*locale*/, NULL /*codepage */); + if (verbose) { + u_fprintf(u_stdout, "%s: checking output via icuio.\n", programName); + } + +#ifndef UFORTUNE_NOSETAPPDATA + /* Tell ICU where our resource data is located in memory. + * The data lives in the Fortune_Resources dll, and we just + * pass the address of an exported symbol from that library + * to ICU. + */ + udata_setAppData("fortune_resources", &fortune_resources_dat, &err); + if (U_FAILURE(err)) { + fprintf(stderr, "%s: udata_setAppData failed with error \"%s\"\n", programName, u_errorName(err)); + exit(-1); + } +#endif + + /* Open our resources. + */ + myResources = ures_open("fortune_resources", locale, &err); + if (U_FAILURE(err)) { + fprintf(stderr, "%s: ures_open failed with error \"%s\"\n", programName, u_errorName(err)); + exit(-1); + } + if (verbose) { + u_fprintf(u_stdout, "status from ures_open(\"fortune_resources\", %s) is %s\n", + locale? locale: " ", u_errorName(err)); + } + + /* + * Display any command line option usage errors and/or the + * usage help message. These messages come from our resource bundle. + */ + if (optionError != NULL) { + const UChar *msg = ures_getStringByKey(myResources, "optionMessage", &len, &err); + if (U_FAILURE(err)) { + fprintf(stderr, "%s: ures_getStringByKey(\"optionMessage\") failed, %s\n", + programName, u_errorName(err)); + exit(-1); + } + u_file_write(msg, len, u_stdout); /* msg is UChar *, from resource */ + u_fprintf(u_stdout, " %s\n", optionError); /* optionError is char *, from argv */ + } + + if (displayUsage) { + const UChar *usage; + int returnValue=0; + + usage = ures_getStringByKey(myResources, "usage", &len, &err); + if (U_FAILURE(err)) { + fprintf(stderr, "%s: ures_getStringByKey(\"usage\") failed, %s\n", programName, u_errorName(err)); + exit(-1); + } + u_file_write(usage, len, u_stdout); + if (optionError != NULL) {returnValue = -1;} + return returnValue; + } + + /* + * Open the "fortunes" resources from within the already open resources + */ + fortunes_r = ures_getByKey(myResources, "fortunes", NULL, &err); + if (U_FAILURE(err)) { + fprintf(stderr, "%s: ures_getByKey(\"fortunes\") failed, %s\n", programName, u_errorName(err)); + exit(-1); + } + + + /* + * Pick up and display a random fortune + * + */ + numFortunes = ures_countArrayItems(myResources, "fortunes", &err); + if (U_FAILURE(err)) { + fprintf(stderr, "%s: ures_countArrayItems(\"fortunes\") failed, %s\n", programName, u_errorName(err)); + exit(-1); + } + if (numFortunes <= 0) { + fprintf(stderr, "%s: no fortunes found.\n", programName); + exit(-1); + } + + i = (int)time(NULL) % numFortunes; /* Use time to pick a somewhat-random fortune. */ + resString = ures_getStringByIndex(fortunes_r, i, &len, &err); + if (U_FAILURE(err)) { + fprintf(stderr, "%s: ures_getStringByIndex(%d) failed, %s\n", programName, i, u_errorName(err)); + exit(-1); + } + + u_file_write(resString, len, u_stdout); /* Write out the message */ + u_fputc(0x0a, u_stdout); /* and a trailing newline */ + + return 0; +} + diff --git a/Build/source/libs/icu/icu-xetex/samples/ufortune/ufortune.sln b/Build/source/libs/icu/icu-xetex/samples/ufortune/ufortune.sln new file mode 100644 index 00000000000..21e78f0821e --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ufortune/ufortune.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ufortune", "ufortune.vcproj", "{25F534DF-93C9-4853-A88E-DB7D8CF74042}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {25F534DF-93C9-4853-A88E-DB7D8CF74042}.Debug|Win32.ActiveCfg = Debug|Win32 + {25F534DF-93C9-4853-A88E-DB7D8CF74042}.Debug|Win32.Build.0 = Debug|Win32 + {25F534DF-93C9-4853-A88E-DB7D8CF74042}.Release|Win32.ActiveCfg = Release|Win32 + {25F534DF-93C9-4853-A88E-DB7D8CF74042}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/ufortune/ufortune.vcproj b/Build/source/libs/icu/icu-xetex/samples/ufortune/ufortune.vcproj new file mode 100644 index 00000000000..5bfcba49ec1 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ufortune/ufortune.vcproj @@ -0,0 +1,259 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="ufortune" + ProjectGUID="{25F534DF-93C9-4853-A88E-DB7D8CF74042}" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <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" + TypeLibraryName=".\Debug/ufortune.tlb" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="true" + PrecompiledHeaderFile=".\Debug/ufortune.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 resources\fortune_resources.lib icuiod.lib" + OutputFile=".\Debug/ufortune.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/ufortune.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="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" + TypeLibraryName=".\Release/ufortune.tlb" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE" + StringPooling="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + PrecompiledHeaderFile=".\Release/ufortune.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 resources\fortune_resources.lib icuio.lib" + OutputFile=".\Release/ufortune.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib" + ProgramDatabaseFile=".\Release/ufortune.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=".\ufortune.c" + > + </File> + </Filter> + <Filter + Name="Resource Files" + Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" + > + <File + RelativePath=".\resources\es.txt" + > + </File> + <File + RelativePath=".\resources\res-file-list.txt" + > + </File> + <File + RelativePath=".\resources\root.txt" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl" + > + </Filter> + <Filter + Name="Makefile" + > + <File + RelativePath=".\resources\fortune_resources.mak" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCustomBuildTool" + CommandLine="cd resources
nmake -f fortune_resources.mak
copy Fortune_Resources.DLL "$(TargetDir)"
" + Outputs="resources\fortune_resources.DLL" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCustomBuildTool" + CommandLine="cd resources
nmake -f fortune_resources.mak
copy Fortune_Resources.DLL "$(TargetDir)"
" + Outputs="resources\fortune_resources.DLL" + /> + </FileConfiguration> + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/Build/source/libs/icu/icu-xetex/samples/ugrep/Makefile b/Build/source/libs/icu/icu-xetex/samples/ugrep/Makefile new file mode 100644 index 00000000000..d214ba74f3f --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ugrep/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=ugrep + +# All object files (C or C++) +OBJECTS=ugrep.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/ugrep/readme.txt b/Build/source/libs/icu/icu-xetex/samples/ugrep/readme.txt new file mode 100644 index 00000000000..c96fb03633a --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ugrep/readme.txt @@ -0,0 +1,71 @@ +Copyright (c) 2002-2005, International Business Machines Corporation and others. All Rights Reserved. +ugrep: a sample program demonstrating the use of ICU regular expression API. + +usage: ugrep [options] pattern [file ...] + + --help Output a brief help message + -n, --line-number Prefix each line of output with the line number within its input file. + -V, --version Output the program version number + + +The program searches for the specified regular expression in each of the +specified files, and outputs each matching line. + +Input files are in the system default (locale dependent) encoding, unless they +begin with a BOM, in which case they are assumed to be in the UTF encoding +specified by the BOM. Program output is always in the system's default +8 bit code page. + + +Files: + ./ugrep.c source code for the sample + ./ugrep.sln Windows MSVC workspace. Double-click this to get started. + ./ugrep.vcproj Windows MSVC project file. + ./Makefile Makefile for Unixes. Needs gmake. + + +To Build ugrep on Windows + 1. Install and build ICU + 2. In MSVC, open the workspace file icu\samples\ugrep\ugrep.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 ugrep directory, e.g. + cd c:\icu\source\samples\ugrep\debug + 4. Run it + ugrep ... + + +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 the sample + Put the install directory containing icu-config on the $PATH. + This will generally be <icu install directory>/bin + cd <icu directory>/source/samples/ugrep + gmake + + To Run on Unixes + cd <icu directory>/source/samples/ugrep + + export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH + ugrep ... + + + 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/ugrep/ugrep.cpp b/Build/source/libs/icu/icu-xetex/samples/ugrep/ugrep.cpp new file mode 100644 index 00000000000..0eeba6802aa --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ugrep/ugrep.cpp @@ -0,0 +1,449 @@ +/************************************************************************** +* +* Copyright (C) 2002, International Business Machines +* Corporation and others. All Rights Reserved. +* +*************************************************************************** +*/ + +// +// ugrep - an ICU sample program illustrating the use of ICU Regular Expressions. +// +// The use of the ICU Regex API all occurs within the main() +// function. The rest of the code deals with with opening files, +// encoding conversions, printing results, etc. +// +// This is not a full-featured grep program. The command line options +// have been kept to a minimum to avoid complicating the sample code. +// + + + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "unicode/utypes.h" +#include "unicode/ustring.h" +#include "unicode/regex.h" +#include "unicode/ucnv.h" +#include "unicode/uclean.h" + + +// +// The following variables contain paramters that may be set from the command line. +// +const char *pattern = NULL; // The regular expression +int firstFileNum; // argv index of the first file name +UBool displayFileName = FALSE; +UBool displayLineNum = FALSE; + + +// +// Info regarding the file currently being processed +// +const char *fileName; +int fileLen; // Length, in UTF-16 Code Units. + +UChar *ucharBuf = 0; // Buffer, holds converted file. (Simple minded program, always reads + // the whole file at once. + +char *charBuf = 0; // Buffer, for original, unconverted file data. + + +// +// Info regarding the line currently being processed +// +int lineStart; // Index of first char of the current line in the file buffer +int lineEnd; // Index of char following the new line sequence for the current line +int lineNum; + +// +// Converter, used on output to convert Unicode data back to char * +// so that it will display in non-Unicode terminal windows. +// +UConverter *outConverter = 0; + +// +// Function forward declarations +// +void processOptions(int argc, const char **argv); +void nextLine(int start); +void printMatch(); +void printUsage(); +void readFile(const char *name); + + + +//------------------------------------------------------------------------------------------ +// +// main for ugrep +// +// Structurally, all use of the ICU Regular Expression API is in main(), +// and all of the supporting stuff necessary to make a running program, but +// not directly related to regular expressions, is factored out into these other +// functions. +// +//------------------------------------------------------------------------------------------ +int main(int argc, const char** argv) { + UBool matchFound = FALSE; + + // + // Process the commmand line options. + // + processOptions(argc, argv); + + // + // Create a RegexPattern object from the user supplied pattern string. + // + UErrorCode status = U_ZERO_ERROR; // All ICU operations report success or failure + // in a status variable. + + UParseError parseErr; // In the event of a syntax error in the regex pattern, + // this struct will contain the position of the + // error. + + RegexPattern *rePat = RegexPattern::compile(pattern, parseErr, status); + // Note that C++ is doing an automatic conversion + // of the (char *) pattern to a temporary + // UnicodeString object. + if (U_FAILURE(status)) { + fprintf(stderr, "ugrep: error in pattern: \"%s\" at position %d\n", + u_errorName(status), parseErr.offset); + exit(-1); + } + + // + // Create a RegexMatcher from the newly created pattern. + // + UnicodeString empty; + RegexMatcher *matcher = rePat->matcher(empty, status); + if (U_FAILURE(status)) { + fprintf(stderr, "ugrep: error in creating RegexMatcher: \"%s\"\n", + u_errorName(status)); + exit(-1); + } + + // + // Loop, processing each of the input files. + // + for (int fileNum=firstFileNum; fileNum < argc; fileNum++) { + readFile(argv[fileNum]); + + // + // Loop through the lines of a file, trying to match the regex pattern on each. + // + for (nextLine(0); lineStart<fileLen; nextLine(lineEnd)) { + UnicodeString s(FALSE, ucharBuf+lineStart, lineEnd-lineStart); + matcher->reset(s); + if (matcher->find()) { + matchFound = TRUE; + printMatch(); + } + } + } + + // + // Clean up + // + delete matcher; + delete rePat; + free(ucharBuf); + free(charBuf); + ucnv_close(outConverter); + + u_cleanup(); // shut down ICU, release any cached data it owns. + + return matchFound? 0: 1; +} + + + +//------------------------------------------------------------------------------------------ +// +// doOptions Run through the command line options, and set +// the global variables accordingly. +// +// exit without returning if an error occured and +// ugrep should not proceed further. +// +//------------------------------------------------------------------------------------------ +void processOptions(int argc, const char **argv) { + int optInd; + UBool doUsage = FALSE; + UBool doVersion = FALSE; + const char *arg; + + + for(optInd = 1; optInd < argc; ++optInd) { + arg = argv[optInd]; + + /* version info */ + if(strcmp(arg, "-V") == 0 || strcmp(arg, "--version") == 0) { + doVersion = TRUE; + } + /* usage info */ + else if(strcmp(arg, "--help") == 0) { + doUsage = TRUE; + } + else if(strcmp(arg, "-n") == 0 || strcmp(arg, "--line-number") == 0) { + displayLineNum = TRUE; + } + /* POSIX.1 says all arguments after -- are not options */ + else if(strcmp(arg, "--") == 0) { + /* skip the -- */ + ++optInd; + break; + } + /* unrecognized option */ + else if(strncmp(arg, "-", strlen("-")) == 0) { + printf("ugrep: invalid option -- %s\n", arg+1); + doUsage = TRUE; + } + /* done with options */ + else { + break; + } + } + + if (doUsage) { + printUsage(); + exit(0); + } + + if (doVersion) { + printf("ugrep version 0.01\n"); + if (optInd == argc) { + exit(0); + } + } + + int remainingArgs = argc-optInd; // pattern file ... + if (remainingArgs < 2) { + fprintf(stderr, "ugrep: files or pattern are missing.\n"); + printUsage(); + exit(1); + } + + if (remainingArgs > 2) { + // More than one file to be processed. Display file names with match output. + displayFileName = TRUE; + } + + pattern = argv[optInd]; + firstFileNum = optInd+1; +} + +//------------------------------------------------------------------------------------------ +// +// printUsage +// +//------------------------------------------------------------------------------------------ +void printUsage() { + printf("ugrep [options] pattern file...\n" + " -V or --version display version information\n" + " --help display this help and exit\n" + " -- stop further option processing\n" + "-n, --line-number Prefix each line of output with the line number within its input file.\n" + ); + exit(0); +} + +//------------------------------------------------------------------------------------------ +// +// readFile Read a file into memory, and convert it to Unicode. +// +// Since this is just a demo program, take the simple minded approach +// of always reading the whole file at once. No intelligent buffering +// is done. +// +//------------------------------------------------------------------------------------------ +void readFile(const char *name) { + + // + // Initialize global file variables + // + fileName = name; + fileLen = 0; // zero length prevents processing in case of errors. + + + // + // Open the file and determine its size. + // + FILE *file = fopen(name, "rb"); + if (file == 0 ) { + fprintf(stderr, "ugrep: Could not open file \"%s\"\n", fileName); + return; + } + fseek(file, 0, SEEK_END); + int rawFileLen = ftell(file); + fseek(file, 0, SEEK_SET); + + + // + // Read in the file + // + charBuf = (char *)realloc(charBuf, rawFileLen+1); // Need error checking... + int t = fread(charBuf, 1, rawFileLen, file); + if (t != rawFileLen) { + fprintf(stderr, "Error reading file \"%s\"\n", fileName); + return; + } + charBuf[rawFileLen]=0; + fclose(file); + + // + // Look for a Unicode Signature (BOM) in the data + // + int32_t signatureLength; + const char * charDataStart = charBuf; + UErrorCode status = U_ZERO_ERROR; + const char* encoding = ucnv_detectUnicodeSignature( + charDataStart, rawFileLen, &signatureLength, &status); + if (U_FAILURE(status)) { + fprintf(stderr, "ugrep: ICU Error \"%s\" from ucnv_detectUnicodeSignature()\n", + u_errorName(status)); + return; + } + if(encoding!=NULL ){ + charDataStart += signatureLength; + rawFileLen -= signatureLength; + } + + // + // Open a converter to take the file to UTF-16 + // + UConverter* conv; + conv = ucnv_open(encoding, &status); + if (U_FAILURE(status)) { + fprintf(stderr, "ugrep: ICU Error \"%s\" from ucnv_open()\n", u_errorName(status)); + return; + } + + // + // Convert the file data to UChar. + // Preflight first to determine required buffer size. + // + uint32_t destCap = ucnv_toUChars(conv, + NULL, // dest, + 0, // destCapacity, + charDataStart, + rawFileLen, + &status); + if (status != U_BUFFER_OVERFLOW_ERROR) { + fprintf(stderr, "ugrep: ucnv_toUChars: ICU Error \"%s\"\n", u_errorName(status)); + return; + }; + + status = U_ZERO_ERROR; + ucharBuf = (UChar *)realloc(ucharBuf, (destCap+1) * sizeof(UChar)); + ucnv_toUChars(conv, + ucharBuf, // dest, + destCap+1, + charDataStart, + rawFileLen, + &status); + if (U_FAILURE(status)) { + fprintf(stderr, "ugrep: ucnv_toUChars: ICU Error \"%s\"\n", u_errorName(status)); + return; + }; + ucnv_close(conv); + + // + // Successful conversion. Set the global size variables so that + // the rest of the processing will proceed for this file. + // + fileLen = destCap; +} + + + + + +//------------------------------------------------------------------------------------------ +// +// nextLine Advance the line index variables, starting at the +// specified position in the input file buffer, by +// scanning forwrd until the next end-of-line. +// +// Need to take into account all of the possible Unicode +// line ending sequences. +// +//------------------------------------------------------------------------------------------ +void nextLine(int startPos) { + if (startPos == 0) { + lineNum = 0; + } else { + lineNum++; + } + lineStart = lineEnd = startPos; + + for (;;) { + if (lineEnd >= fileLen) { + return; + } + UChar c = ucharBuf[lineEnd]; + lineEnd++; + if (c == 0x0a || // Line Feed + c == 0x0c || // Form Feed + c == 0x0d || // Carriage Return + c == 0x85 || // Next Line + c == 0x2028 || // Line Separator + c == 0x2029) // Paragraph separator + { + break; + } + } + + // Check for CR/LF sequence, and advance over the LF if we're in the middle of one. + if (lineEnd < fileLen && + ucharBuf[lineEnd-1] == 0x0d && + ucharBuf[lineEnd] == 0x0a) + { + lineEnd++; + } +} + + +//------------------------------------------------------------------------------------------ +// +// printMatch Called when a matching line has been located. +// Print out the line from the file with the match, after +// converting it back to the default code page. +// +//------------------------------------------------------------------------------------------ +void printMatch() { + char buf[2000]; + UErrorCode status = U_ZERO_ERROR; + + // If we haven't already created a converter for output, do it now. + if (outConverter == 0) { + outConverter = ucnv_open(NULL, &status); + if (U_FAILURE(status)) { + fprintf(stderr, "ugrep: Error opening default converter: \"%s\"\n", + u_errorName(status)); + exit(-1); + } + }; + + // Convert the line to be printed back to the default 8 bit code page. + // If the line is too long for our buffer, just truncate it. + ucnv_fromUChars(outConverter, + buf, // destination buffer for conversion + sizeof(buf), // capacity of destination buffer + &ucharBuf[lineStart], // Input to conversion + lineEnd-lineStart, // number of UChars to convert + &status); + buf[sizeof(buf)-1] = 0; // Add null for use in case of too long lines. + // The converter null-terminates its output unless + // the buffer completely fills. + + if (displayFileName) { + printf("%s:", fileName); + } + if (displayLineNum) { + printf("%d:", lineNum); + } + printf("%s", buf); +} + diff --git a/Build/source/libs/icu/icu-xetex/samples/ugrep/ugrep.sln b/Build/source/libs/icu/icu-xetex/samples/ugrep/ugrep.sln new file mode 100644 index 00000000000..511ba0c2011 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ugrep/ugrep.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ugrep", "ugrep.vcproj", "{63166CEB-02CC-472C-B3B7-E6C559939BDA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {63166CEB-02CC-472C-B3B7-E6C559939BDA}.Debug|Win32.ActiveCfg = Debug|Win32 + {63166CEB-02CC-472C-B3B7-E6C559939BDA}.Debug|Win32.Build.0 = Debug|Win32 + {63166CEB-02CC-472C-B3B7-E6C559939BDA}.Release|Win32.ActiveCfg = Release|Win32 + {63166CEB-02CC-472C-B3B7-E6C559939BDA}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/ugrep/ugrep.vcproj b/Build/source/libs/icu/icu-xetex/samples/ugrep/ugrep.vcproj new file mode 100644 index 00000000000..4860449559e --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ugrep/ugrep.vcproj @@ -0,0 +1,249 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="ugrep" + ProjectGUID="{63166CEB-02CC-472C-B3B7-E6C559939BDA}" + > + <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" + TypeLibraryName=".\Release/ugrep.tlb" + HeaderFileName="" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + InlineFunctionExpansion="2" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE" + StringPooling="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Release/ugrep.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" + AdditionalOptions="/FIXED:NO" + AdditionalDependencies="icuuc.lib icuin.lib" + OutputFile=".\Release/ugrep.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib" + ProgramDatabaseFile=".\Release/ugrep.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="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" + TypeLibraryName=".\Debug/ugrep.tlb" + HeaderFileName="" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Debug/ugrep.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/ugrep.exe" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/ugrep.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> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" + > + <File + RelativePath="ugrep.cpp" + > + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCLCompilerTool" + Optimization="2" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="" + /> + </FileConfiguration> + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="" + PreprocessorDefinitions="" + BasicRuntimeChecks="3" + /> + </FileConfiguration> + </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/uresb/Makefile b/Build/source/libs/icu/icu-xetex/samples/uresb/Makefile new file mode 100644 index 00000000000..488cdb7400d --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/uresb/Makefile @@ -0,0 +1,77 @@ +# Copyright (c) 2000-2005 IBM, Inc. and others +# conversion sample code +# Usage: +# - configure, build, install ICU +# - ensure that 'icu-config' is in the PATH (PREFIX/bin/icu-config) +# - if ICU is not built relative to this directory, +# set the variable ICU_PATH to the 'icu' directory +# (i.e. /foo/icu ) +# - do 'make' in this directory + +include ../defs.mk + +ICU_DEFAULT_PATH=../../.. + +ifeq ($(strip $(ICU_PATH)),) + ICU_PATH=$(ICU_DEFAULT_PATH) +endif + +GENRBOPT = -s. -d. + +# Name of your target +TARGET=uresb +PKG=$(TARGET) +RES_SRC=root.txt en.txt sr.txt +RESOURCES=$(RES_SRC:%.txt=%.res) + +# All object files (C or C++) +OBJECTS=uresb.o + +CLEANFILES=*~ $(TARGET).out + +all: $(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)" + @echo "Can't open $@ - check ICU_PATH" + @false + +CPPFLAGS += -I$(ICU_PATH)/source/tools/toolutil +LDFLAGS += -L$(ICU_PATH)/source/tools/toolutil $(shell icu-config --ldflags-toolutil --ldflags-icuio) + +.PHONY: all clean distclean check report + +distclean clean: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + -$(RMV) $(OBJECTS) $(TARGET) $(RESOURCES) + + +## resources +%.res: %.txt + @echo "generating $@" + $(GENRB) $(GENRBOPT) $^ + +## Special for a special codepage +sr.res : sr.txt + @echo "generating $@" + $(GENRB) $(GENRBOPT) -e cp1251 $? + +# Can change this to LINK.c if it is a C only program +# Can add more libraries here. +$(TARGET): $(OBJECTS) + $(CC) -o $@ $^ $(LDFLAGS) + +# Make check: simply runs the sample, logged to a file +check: $(TARGET) $(RESOURCES) + $(INVOKE) ./$(TARGET) en | 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 > $@ + + + diff --git a/Build/source/libs/icu/icu-xetex/samples/uresb/en.txt b/Build/source/libs/icu/icu-xetex/samples/uresb/en.txt new file mode 100644 index 00000000000..394d53c4a76 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/uresb/en.txt @@ -0,0 +1,46 @@ +// Copyright (C) 2000-2003, International Business Machines +// Corporation and others. All Rights Reserved. + +en { + errorcodes { + "No error", + "Illegal argument passed", + "Missing resource", + "Format is invalid", + "File access error", + "Internal program error", + "Message parse error", + "Memory allocation error", + "Index out of bounds error", + "Parse error", + "Invalid char found", + "Truncated char found", + "Illegal char found", + "Invalid table format", + "Invalid table file", + "Buffer overflow error", + "Unsupported error", + "Resource type mismatch", + "Illegal escape sequence", + "Unsupported escape sequence" + } + helpTopics { + udata { "This is udata help topic" } + resourcebundles { "This is resource bundle help topic" } + collation { "This is collation help topic" } + breakit { "This is break iterator help topic" } + translit { "This is transliteration help topic" } + unicode { "This is unicode help topic" } + format { "This is format help topic" } + } + + helpKeywords { + udata { "udata" } + resourcebundles { "resources" } + collation { "collation" } + breakit { "breakit" } + translit { "transliteration" } + unicode { "unicode" } + format { "format" } + } +} diff --git a/Build/source/libs/icu/icu-xetex/samples/uresb/readme.txt b/Build/source/libs/icu/icu-xetex/samples/uresb/readme.txt new file mode 100644 index 00000000000..362975f15ee --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/uresb/readme.txt @@ -0,0 +1,67 @@ +Copyright (c) 2001-2005 International Business Machines +Corporation and others. All Rights Reserved. +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.sln Windows MSVC workspace. Double-click this to get started. + uresb.vcproj 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.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 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. + diff --git a/Build/source/libs/icu/icu-xetex/samples/uresb/resources.mak b/Build/source/libs/icu/icu-xetex/samples/uresb/resources.mak new file mode 100644 index 00000000000..0c8225fb351 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/uresb/resources.mak @@ -0,0 +1,22 @@ +## Copyright (c) 2001-2005 International Business Machines +## Corporation and others. All Rights Reserved. +PACKAGE_NAME = uresb +TARGETS = en.res root.res sr.res +GENRB = ..\..\..\bin\genrb.exe +GENRBOPT = -s . -d . + +all : $(TARGETS) + @echo All targets are up to date + +clean : + -erase $(TARGETS) + +en.res : en.txt + $(GENRB) $(GENRBOPT) $? + +root.res : root.txt + $(GENRB) $(GENRBOPT) $? + +sr.res : sr.txt + $(GENRB) $(GENRBOPT) --encoding cp1251 $? + diff --git a/Build/source/libs/icu/icu-xetex/samples/uresb/resources.vcproj b/Build/source/libs/icu/icu-xetex/samples/uresb/resources.vcproj new file mode 100644 index 00000000000..c1fc0e3f02e --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/uresb/resources.vcproj @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="resources" + ProjectGUID="{69437707-2FEF-4E2C-8C3F-6E6B3D241366}" + Keyword="MakeFileProj" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory=".\resources_Win32_Debug" + IntermediateDirectory=".\resources_Win32_Debug" + ConfigurationType="0" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + > + <Tool + Name="VCNMakeTool" + BuildCommandLine="nmake /f "resources.mak"" + ReBuildCommandLine="nmake /f "resources.mak" /a" + CleanCommandLine="nmake /f "resources.mak" clean" + Output="uresb_root.res" + PreprocessorDefinitions="" + IncludeSearchPath="" + ForcedIncludes="" + AssemblySearchPath="" + ForcedUsingAssemblies="" + CompileAsManaged="" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory=".\resources_Win32_Release" + IntermediateDirectory=".\resources_Win32_Release" + ConfigurationType="0" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + > + <Tool + Name="VCNMakeTool" + BuildCommandLine="nmake /f "resources.mak"" + ReBuildCommandLine="nmake /f "resources.mak" /a" + CleanCommandLine="nmake /f "resources.mak" clean" + Output="uresb_root.res" + PreprocessorDefinitions="" + IncludeSearchPath="" + ForcedIncludes="" + AssemblySearchPath="" + ForcedUsingAssemblies="" + CompileAsManaged="" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Resource Files" + Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;txt" + > + <File + RelativePath=".\en.txt" + > + </File> + <File + RelativePath=".\root.txt" + > + </File> + <File + RelativePath=".\sr.txt" + > + </File> + </Filter> + <Filter + Name="Build Script" + > + <File + RelativePath=".\resources.mak" + > + </File> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/Build/source/libs/icu/icu-xetex/samples/uresb/root.txt b/Build/source/libs/icu/icu-xetex/samples/uresb/root.txt new file mode 100644 index 00000000000..8d45c73b950 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/uresb/root.txt @@ -0,0 +1,47 @@ +// Copyright (c) 2001-2003 International Business Machines +// Corporation and others. All Rights Reserved. +root { + errorcodes { + "U_ZERO_ERROR", + "U_ILLEGAL_ARGUMENT_ERROR", + "U_MISSING_RESOURCE_ERROR", + "U_INVALID_FORMAT_ERROR", + "U_FILE_ACCESS_ERROR", + "U_INTERNAL_PROGRAM_ERROR", + "U_MESSAGE_PARSE_ERROR", + "U_MEMORY_ALLOCATION_ERROR", + "U_INDEX_OUTOFBOUNDS_ERROR", + "U_PARSE_ERROR", + "U_INVALID_CHAR_FOUND", + "U_TRUNCATED_CHAR_FOUND", + "U_ILLEGAL_CHAR_FOUND", + "U_INVALID_TABLE_FORMAT", + "U_INVALID_TABLE_FILE", + "U_BUFFER_OVERFLOW_ERROR", + "U_UNSUPPORTED_ERROR", + "U_RESOURCE_TYPE_MISMATCH", + "U_ILLEGAL_ESCAPE_SEQUENCE", + "U_UNSUPPORTED_ESCAPE_SEQUENCE" + } + helpTopics { + udata { "ROOT udata help topic" } + resourcebundles { "ROOT resource bundle help topic" } + collation { "ROOT collation help topic" } + breakit { "ROOT break iterator help topic" } + translit { "ROOT transliteration help topic" } + unicode { "ROOT unicode help topic" } + format { "ROOT format help topic" } + } + + helpKeywords { + udata { "udata" } + resourcebundles { "resources" } + collation { "collation" } + breakit { "breakit" } + translit { "transliteration" } + unicode { "unicode" } + format { "format" } + } +} + + diff --git a/Build/source/libs/icu/icu-xetex/samples/uresb/sr.txt b/Build/source/libs/icu/icu-xetex/samples/uresb/sr.txt new file mode 100644 index 00000000000..698d4fcb56a --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/uresb/sr.txt @@ -0,0 +1,47 @@ +// Copyright (c) 2001-2003 International Business Machines +// Corporation and others. All Rights Reserved. +// Use --encoding cp1251 for genrb + +sr { + errorcodes { + "Íåìà ãðåøêå", + "Èëåãàëàí àðãóìåíò", + "Íåäîñòà¼óžè ðåñóðñ", + "Ôîðìàò ¼å ëîø", + "Ãðåøêà ó ïðèñòóïó äàòîòåöè", + "Èíòåðíà ãðåøêà ó ïðîãðàìó", + "Ãðåøêà ó ïàðñèðàœó ïîäàòàêà", + "Ãðåøêà ó çàóçèìàœó ìåìîðè¼å", + "Ãðåøêà ó îïñåãó èíäåêñà", + "Ãðåøêà ó ïàðñèðàœó ïîäàòàêà", + "Ïðîíàåí ¼å ëîø ñèìáîë", + "Ïðîíàåí ¼å ïðåêèíóò ñèìáîë", + "Ïðîíàåí ¼å èëåãàëàí ñèìáîë", + "Ëîø ôîðìàò òàáåëå", + "Ëîøà äàòîòåêà òàáåëå", + "Áàôåð ñå ïðåëèî", + "Íåïîçíàòà ãðåøêà", + "Ëîø òèï ðåñóðñà", + "Ëîøà åñêå¼ï ñåêâåíöà", + "Íåïîäðæàíà åñêå¼ï ñåêâåíöà" + } + helpTopics { + udata { "This is udata help topic" } + resourcebundles { "This is resource bundle help topic" } + collation { "This is collation help topic" } + breakit { "This is break iterator help topic" } + translit { "This is transliteration help topic" } + unicode { "This is unicode help topic" } + format { "This is format help topic" } + } + + helpKeywords { + udata { "udata" } + resourcebundles { "resources" } + collation { "collation" } + breakit { "breakit" } + translit { "transliteration" } + unicode { "unicode" } + format { "format" } + } +} diff --git a/Build/source/libs/icu/icu-xetex/samples/uresb/uresb.c b/Build/source/libs/icu/icu-xetex/samples/uresb/uresb.c new file mode 100644 index 00000000000..e1930503146 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/uresb/uresb.c @@ -0,0 +1,380 @@ +/* +******************************************************************************* +* +* Copyright (C) 1999-2007, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +* file name: uresb.c +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:4 +* +* created on: 2000sep6 +* created by: Vladimir Weinstein +*/ + +/****************************************************************************** + * This program prints out resource bundles - example for + * ICU workshop + * TODO: make a complete i18n layout for this program. + ******************************************************************************/ + +#include "unicode/putil.h" +#include "unicode/ures.h" +#include "unicode/ustdio.h" +#include "unicode/uloc.h" +#include "unicode/ustring.h" +#include "uoptions.h" +#include "toolutil.h" + +#include <string.h> +#include <stdlib.h> +#ifdef WIN32 +#include <direct.h> +#else +#include <unistd.h> +#endif + +#define URESB_DEFAULTTRUNC 40 + +static char *currdir = NULL; +/*--locale sr_YU and --encoding cp855 + * are interesting on Win32 + */ + +static const char *locale = NULL; +static const char *encoding = NULL; +static const char *resPath = NULL; +static const int32_t indentsize = 4; +static UFILE *outerr = NULL; +static int32_t truncsize = URESB_DEFAULTTRUNC; +static UBool trunc = FALSE; + +const UChar baderror[] = { 0x0042, 0x0041, 0x0044, 0x0000 }; + +const UChar *getErrorName(UErrorCode errorNumber); +void reportError(UErrorCode *status); +static UChar *quotedString(const UChar *string); +void printOutBundle(UFILE *out, UResourceBundle *resource, int32_t indent, UErrorCode *status); +void printIndent(UFILE *out, int32_t indent); +void printHex(UFILE *out, const int8_t *what); + +static UOption options[]={ + UOPTION_HELP_H, + UOPTION_HELP_QUESTION_MARK, + { "locale", NULL, NULL, NULL, 'l', UOPT_REQUIRES_ARG, 0 }, + UOPTION_ENCODING, + { "path", NULL, NULL, NULL, 'p', UOPT_OPTIONAL_ARG, 0 }, + { "truncate", NULL, NULL, NULL, 't', UOPT_OPTIONAL_ARG, 0 }, + UOPTION_VERBOSE +}; + +static UBool VERBOSE = FALSE; + +extern int +main(int argc, char* argv[]) { + + UResourceBundle *bundle = NULL; + UErrorCode status = U_ZERO_ERROR; + UFILE *out = NULL; + int32_t i = 0; + const char* arg; + char resPathBuffer[1024]; +#ifdef WIN32 + currdir = _getcwd(NULL, 0); +#else + currdir = getcwd(NULL, 0); +#endif + + argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options); + + /* error handling, printing usage message */ + if(argc<0) { + fprintf(stderr, + "error in command line argument \"%s\"\n", + argv[-argc]); + } + if(argc<2 || options[0].doesOccur || options[1].doesOccur) { + fprintf(stderr, + "usage: %s [-options] locale(s)\n", + argv[0]); + return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR; + } + + if(options[2].doesOccur) { + locale = options[2].value; + } else { + locale = 0; + } + + if(options[3].doesOccur) { + encoding = options[3].value; + } else { + encoding = NULL; + } + + if(options[4].doesOccur) { + if(options[4].value != NULL) { + resPath = options[4].value; /* we'll use users resources */ + } else { + resPath = NULL; /* we'll use ICU system resources for dumping */ + } + } else { + strcpy(resPathBuffer, currdir); + /*strcat(resPathBuffer, U_FILE_SEP_STRING); + strcat(resPathBuffer, "uresb");*/ + resPath = resPathBuffer; /* we'll just dump uresb samples resources */ + } + + if(options[5].doesOccur) { + trunc = TRUE; + if(options[5].value != NULL) { + truncsize = atoi(options[5].value); /* user defined printable size */ + } else { + truncsize = URESB_DEFAULTTRUNC; /* we'll use default omitting size */ + } + } else { + trunc = FALSE; + } + + if(options[6].doesOccur) { + VERBOSE = TRUE; + } + + outerr = u_finit(stderr, locale, encoding); + out = u_finit(stdout, locale, encoding); + + for(i = 1; i < argc; ++i) { + status = U_ZERO_ERROR; + arg = getLongPathname(argv[i]); + + u_fprintf(out, "uresb: processing file \"%s\" in path \"%s\"\n", arg, resPath); + bundle = ures_open(resPath, arg, &status); + if(U_SUCCESS(status)) { + u_fprintf(out, "%s\n", arg); + printOutBundle(out, bundle, 0, &status); + } else { + reportError(&status); + } + + ures_close(bundle); + } + + + + u_fclose(out); + u_fclose(outerr); + return 0; +} + +void printIndent(UFILE *out, int32_t indent) { + char inchar[256]; + int32_t i = 0; + for(i = 0; i<indent; i++) { + inchar[i] = ' '; + } + inchar[indent] = '\0'; + u_fprintf(out, "%s", inchar); +} + +void printHex(UFILE *out, const int8_t *what) { + u_fprintf(out, "%02X", (uint8_t)*what); +} + +static UChar *quotedString(const UChar *string) { + int len = u_strlen(string); + int alen = len; + const UChar *sp; + UChar *newstr, *np; + + for (sp = string; *sp; ++sp) { + switch (*sp) { + case '\n': + case 0x0022: + ++alen; + break; + } + } + + newstr = (UChar *) malloc((1 + alen) * sizeof(*newstr)); + for (sp = string, np = newstr; *sp; ++sp) { + switch (*sp) { + case '\n': + *np++ = 0x005C; + *np++ = 0x006E; + break; + + case 0x0022: + *np++ = 0x005C; + + default: + *np++ = *sp; + break; + } + } + *np = 0; + + return newstr; +} + +void printOutBundle(UFILE *out, UResourceBundle *resource, int32_t indent, UErrorCode *status) { + int32_t i = 0; + const char *key = ures_getKey(resource); + + switch(ures_getType(resource)) { + case URES_STRING : + { + int32_t len=0; + const UChar*thestr = ures_getString(resource, &len, status); + UChar *string = quotedString(thestr); + + /* TODO: String truncation */ + /* + if(trunc && len > truncsize) { + printIndent(out, indent); + u_fprintf(out, "// WARNING: this string, size %d is truncated to %d\n", len, truncsize/2); + len = truncsize/2; + } + */ + printIndent(out, indent); + if(key != NULL) { + u_fprintf(out, "%s { \"%S\" } ", key, string); + } else { + u_fprintf(out, "\"%S\",", string); + } + if(VERBOSE) { + u_fprintf(out, " // STRING"); + } + u_fprintf(out, "\n"); + free(string); + } + break; + case URES_INT : + printIndent(out, indent); + if(key != NULL) { + u_fprintf(out, "%s", key); + } + u_fprintf(out, ":int { %li } ", ures_getInt(resource, status)); + + if(VERBOSE) { + u_fprintf(out, " // INT"); + } + u_fprintf(out, "\n"); + break; + case URES_BINARY : + { + int32_t len = 0; + const int8_t *data = (const int8_t *)ures_getBinary(resource, &len, status); + if(trunc && len > truncsize) { + printIndent(out, indent); + u_fprintf(out, "// WARNING: this resource, size %li is truncated to %li\n", len, truncsize/2); + len = truncsize/2; + } + if(U_SUCCESS(*status)) { + printIndent(out, indent); + if(key != NULL) { + u_fprintf(out, "%s", key); + } + u_fprintf(out, ":binary { "); + for(i = 0; i<len; i++) { + printHex(out, data++); + } + u_fprintf(out, " }"); + if(VERBOSE) { + u_fprintf(out, " // BINARY"); + } + u_fprintf(out, "\n"); + + } else { + reportError(status); + } + } + break; + case URES_INT_VECTOR : + { + int32_t len = 0; + const int32_t *data = ures_getIntVector(resource, &len, status); + if(U_SUCCESS(*status)) { + printIndent(out, indent); + if(key != NULL) { + u_fprintf(out, "%s", key); + } + u_fprintf(out, ":intvector { "); + for(i = 0; i<len-1; i++) { + u_fprintf(out, "%d, ", data[i]); + } + if(len > 0) { + u_fprintf(out, "%d ", data[len-1]); + } + u_fprintf(out, "}"); + if(VERBOSE) { + u_fprintf(out, " // INTVECTOR"); + } + u_fprintf(out, "\n"); + + } else { + reportError(status); + } + } + break; + case URES_TABLE : + case URES_ARRAY : + { + UResourceBundle *t = NULL; + ures_resetIterator(resource); + printIndent(out, indent); + if(key != NULL) { + u_fprintf(out, "%s ", key); + } + u_fprintf(out, "{"); + if(VERBOSE) { + if(ures_getType(resource) == URES_TABLE) { + u_fprintf(out, " // TABLE"); + } else { + u_fprintf(out, " // ARRAY"); + } + } + u_fprintf(out, "\n"); + + while(ures_hasNext(resource)) { + t = ures_getNextResource(resource, t, status); + printOutBundle(out, t, indent+indentsize, status); + } + + printIndent(out, indent); + u_fprintf(out, "}\n"); + ures_close(t); + } + break; + default: + break; + } + +} + +void reportError(UErrorCode *status) { + u_fprintf(outerr, "Error %d(%s) : %U happened!\n", *status, u_errorName(*status), getErrorName(*status)); +} + + +const UChar *getErrorName(UErrorCode errorNumber) { + UErrorCode status = U_ZERO_ERROR; + int32_t len = 0; + + UResourceBundle *error = ures_open(currdir, locale, &status); + + UResourceBundle *errorcodes = ures_getByKey(error, "errorcodes", NULL, &status); + + const UChar *result = ures_getStringByIndex(errorcodes, errorNumber, &len, &status); + + ures_close(errorcodes); + ures_close(error); + + if(U_SUCCESS(status)) { + return result; + } else { + return baderror; + } + +} diff --git a/Build/source/libs/icu/icu-xetex/samples/uresb/uresb.sln b/Build/source/libs/icu/icu-xetex/samples/uresb/uresb.sln new file mode 100644 index 00000000000..bd14ff5edfa --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/uresb/uresb.sln @@ -0,0 +1,28 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "resources", "resources.vcproj", "{69437707-2FEF-4E2C-8C3F-6E6B3D241366}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uresb", "uresb.vcproj", "{92580BF4-F4DA-4024-B3F8-444F982BC72F}" + ProjectSection(ProjectDependencies) = postProject + {69437707-2FEF-4E2C-8C3F-6E6B3D241366} = {69437707-2FEF-4E2C-8C3F-6E6B3D241366} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {69437707-2FEF-4E2C-8C3F-6E6B3D241366}.Debug|Win32.ActiveCfg = Debug|Win32 + {69437707-2FEF-4E2C-8C3F-6E6B3D241366}.Debug|Win32.Build.0 = Debug|Win32 + {69437707-2FEF-4E2C-8C3F-6E6B3D241366}.Release|Win32.ActiveCfg = Release|Win32 + {69437707-2FEF-4E2C-8C3F-6E6B3D241366}.Release|Win32.Build.0 = Release|Win32 + {92580BF4-F4DA-4024-B3F8-444F982BC72F}.Debug|Win32.ActiveCfg = Debug|Win32 + {92580BF4-F4DA-4024-B3F8-444F982BC72F}.Debug|Win32.Build.0 = Debug|Win32 + {92580BF4-F4DA-4024-B3F8-444F982BC72F}.Release|Win32.ActiveCfg = Release|Win32 + {92580BF4-F4DA-4024-B3F8-444F982BC72F}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/uresb/uresb.vcproj b/Build/source/libs/icu/icu-xetex/samples/uresb/uresb.vcproj new file mode 100644 index 00000000000..ade8dd4517c --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/uresb/uresb.vcproj @@ -0,0 +1,223 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="uresb" + ProjectGUID="{92580BF4-F4DA-4024-B3F8-444F982BC72F}" + > + <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" + TypeLibraryName=".\Release/uresb.tlb" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="../../../include,../../tools/toolutil" + PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE" + StringPooling="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Release/uresb.pch" + AssemblerListingLocation=".\Release/" + ObjectFile=".\Release/" + ProgramDataBaseFileName=".\Release/" + WarningLevel="3" + SuppressStartupBanner="true" + CompileAs="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="NDEBUG" + Culture="3098" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="icuuc.lib icuio.lib icutu.lib" + OutputFile=".\Release/uresb.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib/,../../tools/toolutil/" + ProgramDatabaseFile=".\Release/uresb.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" + TypeLibraryName=".\Debug/uresb.tlb" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="../../../include,../../tools/toolutil" + PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Debug/uresb.pch" + AssemblerListingLocation=".\Debug/" + ObjectFile=".\Debug/" + ProgramDataBaseFileName=".\Debug/" + WarningLevel="3" + SuppressStartupBanner="true" + DebugInformationFormat="4" + CompileAs="0" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_DEBUG" + Culture="3098" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="icuucd.lib icuiod.lib icutud.lib" + OutputFile=".\Debug/uresb.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="../../../lib/,../../tools/toolutil/" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/uresb.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=".\uresb.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/ustring/Makefile b/Build/source/libs/icu/icu-xetex/samples/ustring/Makefile new file mode 100644 index 00000000000..ff94488d229 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ustring/Makefile @@ -0,0 +1,20 @@ +# Copyright (c) 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 + +# Name of your target +TARGET=ustring + +# All object files (C or C++) +OBJECTS=ustring.o + +# 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/ustring/readme.txt b/Build/source/libs/icu/icu-xetex/samples/ustring/readme.txt new file mode 100644 index 00000000000..f713963b574 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ustring/readme.txt @@ -0,0 +1,60 @@ +Copyright (c) 2002-2005, International Business Machines Corporation and others. All Rights Reserved. +ustring: Unicode String Manipulation + +This sample demonstrates + Using ICU to manipulate UnicodeString objects + + +Files: + ustring.cpp Main source file in C++ + ustring.sln Windows MSVC workspace. Double-click this to get started. + ustring.vcproj 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.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 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. + + diff --git a/Build/source/libs/icu/icu-xetex/samples/ustring/ustring.cpp b/Build/source/libs/icu/icu-xetex/samples/ustring/ustring.cpp new file mode 100644 index 00000000000..52351e47d07 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ustring/ustring.cpp @@ -0,0 +1,609 @@ +/* +******************************************************************************* +* +* Copyright (C) 2000-2002, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +* file name: ustring.c +* encoding: US-ASCII +* tab size: 8 (not used) +* indentation:4 +* +* created on: 2000aug15 +* created by: Markus W. Scherer +* +* This file contains sample code that illustrates the use of Unicode strings +* with ICU. +*/ + +#include <stdio.h> +#include "unicode/utypes.h" +#include "unicode/uchar.h" +#include "unicode/locid.h" +#include "unicode/ustring.h" +#include "unicode/ucnv.h" +#include "unicode/unistr.h" + +#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0])) + +// helper functions -------------------------------------------------------- *** + +// default converter for the platform encoding +static UConverter *cnv=NULL; + +static void +printUString(const char *announce, const UChar *s, int32_t length) { + static char out[200]; + UChar32 c; + int32_t i; + UErrorCode errorCode=U_ZERO_ERROR; + + /* + * Convert to the "platform encoding". See notes in printUnicodeString(). + * ucnv_fromUChars(), like most ICU APIs understands length==-1 + * to mean that the string is NUL-terminated. + */ + ucnv_fromUChars(cnv, out, sizeof(out), s, length, &errorCode); + if(U_FAILURE(errorCode) || errorCode==U_STRING_NOT_TERMINATED_WARNING) { + printf("%sproblem converting string from Unicode: %s\n", announce, u_errorName(errorCode)); + return; + } + + printf("%s%s {", announce, out); + + /* output the code points (not code units) */ + if(length>=0) { + /* s is not NUL-terminated */ + for(i=0; i<length; /* U16_NEXT post-increments */) { + U16_NEXT(s, i, length, c); + printf(" %04x", c); + } + } else { + /* s is NUL-terminated */ + for(i=0; /* condition in loop body */; /* U16_NEXT post-increments */) { + U16_NEXT(s, i, length, c); + if(c==0) { + break; + } + printf(" %04x", c); + } + } + printf(" }\n"); +} + +static void +printUnicodeString(const char *announce, const UnicodeString &s) { + static char out[200]; + int32_t i, length; + + // output the string, converted to the platform encoding + + // Note for Windows: The "platform encoding" defaults to the "ANSI codepage", + // which is different from the "OEM codepage" in the console window. + // However, if you pipe the output into a file and look at it with Notepad + // or similar, then "ANSI" characters will show correctly. + // Production code should be aware of what encoding is required, + // and use a UConverter or at least a charset name explicitly. + out[s.extract(0, 99, out)]=0; + printf("%s%s {", announce, out); + + // output the code units (not code points) + length=s.length(); + for(i=0; i<length; ++i) { + printf(" %04x", s.charAt(i)); + } + printf(" }\n"); +} + +// sample code for utf.h macros -------------------------------------------- *** + +static void +demo_utf_h_macros() { + static UChar input[]={ 0x0061, 0xd800, 0xdc00, 0xdbff, 0xdfff, 0x0062 }; + UChar32 c; + int32_t i; + UBool isError; + + printf("\n* demo_utf_h_macros() -------------- ***\n\n"); + + printUString("iterate forward through: ", input, LENGTHOF(input)); + for(i=0; i<LENGTHOF(input); /* U16_NEXT post-increments */) { + /* Iterating forwards + Codepoint at offset 0: U+0061 + Codepoint at offset 1: U+10000 + Codepoint at offset 3: U+10ffff + Codepoint at offset 5: U+0062 + */ + printf("Codepoint at offset %d: U+", i); + U16_NEXT(input, i, LENGTHOF(input), c); + printf("%04x\n", c); + } + + puts(""); + + isError=FALSE; + i=1; /* write position, gets post-incremented so needs to be in an l-value */ + U16_APPEND(input, i, LENGTHOF(input), 0x0062, isError); + + printUString("iterate backward through: ", input, LENGTHOF(input)); + for(i=LENGTHOF(input); i>0; /* U16_PREV pre-decrements */) { + U16_PREV(input, 0, i, c); + /* Iterating backwards + Codepoint at offset 5: U+0062 + Codepoint at offset 3: U+10ffff + Codepoint at offset 2: U+dc00 -- unpaired surrogate because lead surr. overwritten + Codepoint at offset 1: U+0062 -- by this BMP code point + Codepoint at offset 0: U+0061 + */ + printf("Codepoint at offset %d: U+%04x\n", i, c); + } +} + +// sample code for Unicode strings in C ------------------------------------ *** + +static void demo_C_Unicode_strings() { + printf("\n* demo_C_Unicode_strings() --------- ***\n\n"); + + static const UChar text[]={ 0x41, 0x42, 0x43, 0 }; /* "ABC" */ + static const UChar appendText[]={ 0x61, 0x62, 0x63, 0 }; /* "abc" */ + static const UChar cmpText[]={ 0x61, 0x53, 0x73, 0x43, 0 }; /* "aSsC" */ + UChar buffer[32]; + int32_t compare; + int32_t length=u_strlen(text); /* length=3 */ + + /* simple ANSI C-style functions */ + buffer[0]=0; /* empty, NUL-terminated string */ + u_strncat(buffer, text, 1); /* append just n=1 character ('A') */ + u_strcat(buffer, appendText); /* buffer=="Aabc" */ + length=u_strlen(buffer); /* length=4 */ + printUString("should be \"Aabc\": ", buffer, -1); + + /* bitwise comparing buffer with text */ + compare=u_strcmp(buffer, text); + if(compare<=0) { + printf("String comparison error, expected \"Aabc\" > \"ABC\"\n"); + } + + /* Build "A<sharp s>C" in the buffer... */ + u_strcpy(buffer, text); + buffer[1]=0xdf; /* sharp s, case-compares equal to "ss" */ + printUString("should be \"A<sharp s>C\": ", buffer, -1); + + /* Compare two strings case-insensitively using full case folding */ + compare=u_strcasecmp(buffer, cmpText, U_FOLD_CASE_DEFAULT); + if(compare!=0) { + printf("String case insensitive comparison error, expected \"AbC\" to be equal to \"ABC\"\n"); + } +} + +// sample code for case mappings with C APIs -------------------------------- *** + +static void demoCaseMapInC() { + /* + * input= + * "aB<capital sigma>" + * "iI<small dotless i><capital dotted I> " + * "<sharp s> <small lig. ffi>" + * "<small final sigma><small sigma><capital sigma>" + */ + static const UChar input[]={ + 0x61, 0x42, 0x3a3, + 0x69, 0x49, 0x131, 0x130, 0x20, + 0xdf, 0x20, 0xfb03, + 0x3c2, 0x3c3, 0x3a3, 0 + }; + UChar buffer[32]; + + UErrorCode errorCode; + UChar32 c; + int32_t i, j, length; + UBool isError; + + printf("\n* demoCaseMapInC() ----------------- ***\n\n"); + + /* + * First, use simple case mapping functions which provide + * 1:1 code point mappings without context/locale ID. + * + * Note that some mappings will not be "right" because some "real" + * case mappings require context, depend on the locale ID, + * and/or result in a change in the number of code points. + */ + printUString("input string: ", input, -1); + + /* uppercase */ + isError=FALSE; + for(i=j=0; j<LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) { + U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */ + if(c==0) { + break; /* stop at terminating NUL, no need to terminate buffer */ + } + c=u_toupper(c); + U16_APPEND(buffer, j, LENGTHOF(buffer), c, isError); + } + printUString("simple-uppercased: ", buffer, j); + /* lowercase */ + isError=FALSE; + for(i=j=0; j<LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) { + U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */ + if(c==0) { + break; /* stop at terminating NUL, no need to terminate buffer */ + } + c=u_tolower(c); + U16_APPEND(buffer, j, LENGTHOF(buffer), c, isError); + } + printUString("simple-lowercased: ", buffer, j); + /* titlecase */ + isError=FALSE; + for(i=j=0; j<LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) { + U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */ + if(c==0) { + break; /* stop at terminating NUL, no need to terminate buffer */ + } + c=u_totitle(c); + U16_APPEND(buffer, j, LENGTHOF(buffer), c, isError); + } + printUString("simple-titlecased: ", buffer, j); + /* case-fold/default */ + isError=FALSE; + for(i=j=0; j<LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) { + U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */ + if(c==0) { + break; /* stop at terminating NUL, no need to terminate buffer */ + } + c=u_foldCase(c, U_FOLD_CASE_DEFAULT); + U16_APPEND(buffer, j, LENGTHOF(buffer), c, isError); + } + printUString("simple-case-folded/default: ", buffer, j); + /* case-fold/Turkic */ + isError=FALSE; + for(i=j=0; j<LENGTHOF(buffer) && !isError; /* U16_NEXT post-increments */) { + U16_NEXT(input, i, INT32_MAX, c); /* without length because NUL-terminated */ + if(c==0) { + break; /* stop at terminating NUL, no need to terminate buffer */ + } + c=u_foldCase(c, U_FOLD_CASE_EXCLUDE_SPECIAL_I); + U16_APPEND(buffer, j, LENGTHOF(buffer), c, isError); + } + printUString("simple-case-folded/Turkic: ", buffer, j); + + /* + * Second, use full case mapping functions which provide + * 1:n code point mappings (n can be 0!) and are sensitive to context and locale ID. + * + * Note that lower/upper/titlecasing take a locale ID while case-folding + * has bit flag options instead, by design of the Unicode SpecialCasing.txt UCD file. + * + * Also, string titlecasing requires a BreakIterator to find starts of words. + * The sample code here passes in a NULL pointer; u_strToTitle() will open and close a default + * titlecasing BreakIterator automatically. + * For production code where many strings are titlecased it would be more efficient + * to open a BreakIterator externally and pass it in. + */ + printUString("\ninput string: ", input, -1); + + /* lowercase/English */ + errorCode=U_ZERO_ERROR; + length=u_strToLower(buffer, LENGTHOF(buffer), input, -1, "en", &errorCode); + if(U_SUCCESS(errorCode)) { + printUString("full-lowercased/en: ", buffer, length); + } else { + printf("error in u_strToLower(en)=%ld error=%s\n", length, u_errorName(errorCode)); + } + /* lowercase/Turkish */ + errorCode=U_ZERO_ERROR; + length=u_strToLower(buffer, LENGTHOF(buffer), input, -1, "tr", &errorCode); + if(U_SUCCESS(errorCode)) { + printUString("full-lowercased/tr: ", buffer, length); + } else { + printf("error in u_strToLower(tr)=%ld error=%s\n", length, u_errorName(errorCode)); + } + /* uppercase/English */ + errorCode=U_ZERO_ERROR; + length=u_strToUpper(buffer, LENGTHOF(buffer), input, -1, "en", &errorCode); + if(U_SUCCESS(errorCode)) { + printUString("full-uppercased/en: ", buffer, length); + } else { + printf("error in u_strToUpper(en)=%ld error=%s\n", length, u_errorName(errorCode)); + } + /* uppercase/Turkish */ + errorCode=U_ZERO_ERROR; + length=u_strToUpper(buffer, LENGTHOF(buffer), input, -1, "tr", &errorCode); + if(U_SUCCESS(errorCode)) { + printUString("full-uppercased/tr: ", buffer, length); + } else { + printf("error in u_strToUpper(tr)=%ld error=%s\n", length, u_errorName(errorCode)); + } + /* titlecase/English */ + errorCode=U_ZERO_ERROR; + length=u_strToTitle(buffer, LENGTHOF(buffer), input, -1, NULL, "en", &errorCode); + if(U_SUCCESS(errorCode)) { + printUString("full-titlecased/en: ", buffer, length); + } else { + printf("error in u_strToTitle(en)=%ld error=%s\n", length, u_errorName(errorCode)); + } + /* titlecase/Turkish */ + errorCode=U_ZERO_ERROR; + length=u_strToTitle(buffer, LENGTHOF(buffer), input, -1, NULL, "tr", &errorCode); + if(U_SUCCESS(errorCode)) { + printUString("full-titlecased/tr: ", buffer, length); + } else { + printf("error in u_strToTitle(tr)=%ld error=%s\n", length, u_errorName(errorCode)); + } + /* case-fold/default */ + errorCode=U_ZERO_ERROR; + length=u_strFoldCase(buffer, LENGTHOF(buffer), input, -1, U_FOLD_CASE_DEFAULT, &errorCode); + if(U_SUCCESS(errorCode)) { + printUString("full-case-folded/default: ", buffer, length); + } else { + printf("error in u_strFoldCase(default)=%ld error=%s\n", length, u_errorName(errorCode)); + } + /* case-fold/Turkic */ + errorCode=U_ZERO_ERROR; + length=u_strFoldCase(buffer, LENGTHOF(buffer), input, -1, U_FOLD_CASE_EXCLUDE_SPECIAL_I, &errorCode); + if(U_SUCCESS(errorCode)) { + printUString("full-case-folded/Turkic: ", buffer, length); + } else { + printf("error in u_strFoldCase(Turkic)=%ld error=%s\n", length, u_errorName(errorCode)); + } +} + +// sample code for case mappings with C++ APIs ------------------------------ *** + +static void demoCaseMapInCPlusPlus() { + /* + * input= + * "aB<capital sigma>" + * "iI<small dotless i><capital dotted I> " + * "<sharp s> <small lig. ffi>" + * "<small final sigma><small sigma><capital sigma>" + */ + static const UChar input[]={ + 0x61, 0x42, 0x3a3, + 0x69, 0x49, 0x131, 0x130, 0x20, + 0xdf, 0x20, 0xfb03, + 0x3c2, 0x3c3, 0x3a3, 0 + }; + + printf("\n* demoCaseMapInCPlusPlus() --------- ***\n\n"); + + UnicodeString s(input), t; + const Locale &en=Locale::getEnglish(); + Locale tr("tr"); + + /* + * Full case mappings as in demoCaseMapInC(), using UnicodeString functions. + * These functions modify the string object itself. + * Since we want to keep the input string around, we copy it each time + * and case-map the copy. + */ + printUnicodeString("input string: ", s); + + /* lowercase/English */ + printUnicodeString("full-lowercased/en: ", (t=s).toLower(en)); + /* lowercase/Turkish */ + printUnicodeString("full-lowercased/tr: ", (t=s).toLower(tr)); + /* uppercase/English */ + printUnicodeString("full-uppercased/en: ", (t=s).toUpper(en)); + /* uppercase/Turkish */ + printUnicodeString("full-uppercased/tr: ", (t=s).toUpper(tr)); + /* titlecase/English */ + printUnicodeString("full-titlecased/en: ", (t=s).toTitle(NULL, en)); + /* titlecase/Turkish */ + printUnicodeString("full-titlecased/tr: ", (t=s).toTitle(NULL, tr)); + /* case-folde/default */ + printUnicodeString("full-case-folded/default: ", (t=s).foldCase(U_FOLD_CASE_DEFAULT)); + /* case-folde/Turkic */ + printUnicodeString("full-case-folded/Turkic: ", (t=s).foldCase(U_FOLD_CASE_EXCLUDE_SPECIAL_I)); +} + +// sample code for UnicodeString storage models ----------------------------- *** + +static const UChar readonly[]={ + 0x61, 0x31, 0x20ac +}; +static UChar writeable[]={ + 0x62, 0x32, 0xdbc0, 0xdc01 // includes a surrogate pair for a supplementary code point +}; +static char out[100]; + +static void +demoUnicodeStringStorage() { + // These sample code lines illustrate how to use UnicodeString, and the + // comments tell what happens internally. There are no APIs to observe + // most of this programmatically, except for stepping into the code + // with a debugger. + // This is by design to hide such details from the user. + int32_t i; + + printf("\n* demoUnicodeStringStorage() ------- ***\n\n"); + + // * UnicodeString with internally stored contents + // instantiate a UnicodeString from a single code point + // the few (2) UChars will be stored in the object itself + UnicodeString one((UChar32)0x24001); + // this copies the few UChars into the "two" object + UnicodeString two=one; + printf("length of short string copy: %d\n", two.length()); + // set "one" to contain the 3 UChars from readonly + // this setTo() variant copies the characters + one.setTo(readonly, LENGTHOF(readonly)); + + // * UnicodeString with allocated contents + // build a longer string that will not fit into the object's buffer + one+=UnicodeString(writeable, LENGTHOF(writeable)); + one+=one; + one+=one; + printf("length of longer string: %d\n", one.length()); + // copying will use the same allocated buffer and increment the reference + // counter + two=one; + printf("length of longer string copy: %d\n", two.length()); + + // * UnicodeString using readonly-alias to a const UChar array + // construct a string that aliases a readonly buffer + UnicodeString three(FALSE, readonly, LENGTHOF(readonly)); + printUnicodeString("readonly-alias string: ", three); + // copy-on-write: any modification to the string results in + // a copy to either the internal buffer or to a newly allocated one + three.setCharAt(1, 0x39); + printUnicodeString("readonly-aliasing string after modification: ", three); + // the aliased array is not modified + for(i=0; i<three.length(); ++i) { + printf("readonly buffer[%d] after modifying its string: 0x%lx\n", + i, readonly[i]); + } + // setTo() readonly alias + one.setTo(FALSE, writeable, LENGTHOF(writeable)); + // copying the readonly-alias object with fastCopyFrom() (new in ICU 2.4) + // will readonly-alias the same buffer + two.fastCopyFrom(one); + printUnicodeString("fastCopyFrom(readonly alias of \"writeable\" array): ", two); + printf("verify that a fastCopyFrom(readonly alias) uses the same buffer pointer: %d (should be 1)\n", + one.getBuffer()==two.getBuffer()); + // a normal assignment will clone the contents (new in ICU 2.4) + two=one; + printf("verify that a regular copy of a readonly alias uses a different buffer pointer: %d (should be 0)\n", + one.getBuffer()==two.getBuffer()); + + // * UnicodeString using writeable-alias to a non-const UChar array + UnicodeString four(writeable, LENGTHOF(writeable), LENGTHOF(writeable)); + printUnicodeString("writeable-alias string: ", four); + // a modification writes through to the buffer + four.setCharAt(1, 0x39); + for(i=0; i<four.length(); ++i) { + printf("writeable-alias backing buffer[%d]=0x%lx " + "after modification\n", i, writeable[i]); + } + // a copy will not alias any more; + // instead, it will get a copy of the contents into allocated memory + two=four; + two.setCharAt(1, 0x21); + for(i=0; i<two.length(); ++i) { + printf("writeable-alias backing buffer[%d]=0x%lx after " + "modification of string copy\n", i, writeable[i]); + } + // setTo() writeable alias, capacity==length + one.setTo(writeable, LENGTHOF(writeable), LENGTHOF(writeable)); + // grow the string - it will not fit into the backing buffer any more + // and will get copied before modification + one.append((UChar)0x40); + // shrink it back so it would fit + one.truncate(one.length()-1); + // we still operate on the copy + one.setCharAt(1, 0x25); + printf("string after growing too much and then shrinking[1]=0x%lx\n" + " backing store for this[1]=0x%lx\n", + one.charAt(1), writeable[1]); + // if we need it in the original buffer, then extract() to it + // extract() does not do anything if the string aliases that same buffer + // i=min(one.length(), length of array) + if(one.length()<LENGTHOF(writeable)) { + i=one.length(); + } else { + i=LENGTHOF(writeable); + } + one.extract(0, i, writeable); + for(i=0; i<LENGTHOF(writeable); ++i) { + printf("writeable-alias backing buffer[%d]=0x%lx after re-extract\n", + i, writeable[i]); + } +} + +// sample code for UnicodeString instantiations ----------------------------- *** + +static void +demoUnicodeStringInit() { + // *** Make sure to read about invariant characters in utypes.h! *** + // Initialization of Unicode strings from C literals works _only_ for + // invariant characters! + + printf("\n* demoUnicodeStringInit() ---------- ***\n\n"); + + // the string literal is 32 chars long - this must be counted for the macro + UnicodeString invariantOnly=UNICODE_STRING("such characters are safe 123 %-.", 32); + + /* + * In C, we need two macros: one to declare the UChar[] array, and + * one to populate it; the second one is a noop on platforms where + * wchar_t is compatible with UChar and ASCII-based. + * The length of the string literal must be counted for both macros. + */ + /* declare the invString array for the string */ + U_STRING_DECL(invString, "such characters are safe 123 %-.", 32); + /* populate it with the characters */ + U_STRING_INIT(invString, "such characters are safe 123 %-.", 32); + + // compare the C and C++ strings + printf("C and C++ Unicode strings are equal: %d\n", invariantOnly==UnicodeString(TRUE, invString, 32)); + + /* + * convert between char * and UChar * strings that + * contain only invariant characters + */ + static const char *cs1="such characters are safe 123 %-."; + static UChar us1[40]; + static char cs2[40]; + u_charsToUChars(cs1, us1, 33); /* include the terminating NUL */ + u_UCharsToChars(us1, cs2, 33); + printf("char * -> UChar * -> char * with only " + "invariant characters: \"%s\"\n", + cs2); + + // initialize a UnicodeString from a string literal that contains + // escape sequences written with invariant characters + // do not forget to duplicate the backslashes for ICU to see them + // then, count each double backslash only once! + UnicodeString german=UNICODE_STRING( + "Sch\\u00f6nes Auto: \\u20ac 11240.\\fPrivates Zeichen: \\U00102345\\n", 64). + unescape(); + printUnicodeString("german UnicodeString from unescaping:\n ", german); + + /* + * C: convert and unescape a char * string with only invariant + * characters to fill a UChar * string + */ + UChar buffer[200]; + int32_t length; + length=u_unescape( + "Sch\\u00f6nes Auto: \\u20ac 11240.\\fPrivates Zeichen: \\U00102345\\n", + buffer, LENGTHOF(buffer)); + printf("german C Unicode string from char * unescaping: (length %d)\n ", length); + printUnicodeString("", UnicodeString(buffer)); +} + +extern int +main(int argc, const char *argv[]) { + UErrorCode errorCode=U_ZERO_ERROR; + + // Note: Using a global variable for any object is not exactly thread-safe... + + // You can change this call to e.g. ucnv_open("UTF-8", &errorCode) if you pipe + // the output to a file and look at it with a Unicode-capable editor. + // This will currently affect only the printUString() function, see the code above. + // printUnicodeString() could use this, too, by changing to an extract() overload + // that takes a UConverter argument. + cnv=ucnv_open(NULL, &errorCode); + if(U_FAILURE(errorCode)) { + fprintf(stderr, "error %s opening the default converter\n", u_errorName(errorCode)); + return errorCode; + } + + ucnv_setFromUCallBack(cnv, UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_C, NULL, NULL, &errorCode); + if(U_FAILURE(errorCode)) { + fprintf(stderr, "error %s setting the escape callback in the default converter\n", u_errorName(errorCode)); + ucnv_close(cnv); + return errorCode; + } + + demo_utf_h_macros(); + demo_C_Unicode_strings(); + demoCaseMapInC(); + demoCaseMapInCPlusPlus(); + demoUnicodeStringStorage(); + demoUnicodeStringInit(); + + ucnv_close(cnv); + return 0; +} diff --git a/Build/source/libs/icu/icu-xetex/samples/ustring/ustring.sln b/Build/source/libs/icu/icu-xetex/samples/ustring/ustring.sln new file mode 100644 index 00000000000..5ce665f90bd --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ustring/ustring.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ustring", "ustring.vcproj", "{FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}.Debug|Win32.ActiveCfg = Debug|Win32 + {FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}.Debug|Win32.Build.0 = Debug|Win32 + {FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}.Release|Win32.ActiveCfg = Release|Win32 + {FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-xetex/samples/ustring/ustring.vcproj b/Build/source/libs/icu/icu-xetex/samples/ustring/ustring.vcproj new file mode 100644 index 00000000000..c95d6a191a2 --- /dev/null +++ b/Build/source/libs/icu/icu-xetex/samples/ustring/ustring.vcproj @@ -0,0 +1,223 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="ustring" + ProjectGUID="{FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}" + > + <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" + TypeLibraryName=".\Release/ustring.tlb" + /> + <Tool + Name="VCCLCompilerTool" + InlineFunctionExpansion="1" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE" + StringPooling="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Release/ustring.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" + OutputFile=".\Release/ustring.exe" + LinkIncremental="1" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + ProgramDatabaseFile=".\Release/ustring.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" + TypeLibraryName=".\Debug/ustring.tlb" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="..\..\..\include" + PreprocessorDefinitions="WIN32,_DEBUG,_CONSOLE" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + TreatWChar_tAsBuiltInType="true" + UsePrecompiledHeader="0" + PrecompiledHeaderFile=".\Debug/ustring.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" + OutputFile=".\Debug/ustring.exe" + LinkIncremental="2" + SuppressStartupBanner="true" + AdditionalLibraryDirectories="..\..\..\lib" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/ustring.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=".\ustring.cpp" + > + </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> |