Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 88

Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 215

Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 216

Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 217

Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 218

Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 219

Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 220
PK!ԿV Makefilenu[## Makefile.in for ICU samples ## Copyright (C) 2016 and later: Unicode, Inc. and others. ## License & terms of use: http://www.unicode.org/copyright.html#License ## ## Copyright (c) 1999-2011, International Business Machines Corporation and ## others. All Rights Reserved. ## Install directory information srcdir = . top_srcdir = .. top_builddir = .. include $(top_builddir)/icudefs.mk ## Build directory information subdir = samples ## Platform-specific setup include $(top_srcdir)/config/mh-linux ## 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 ugrep ## 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 check-exhaustive ## 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 check-exhaustive: check ## 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 PK!(xGllciter/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # 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 PK!Y<citer/citer.cppnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * Copyright (C) 2002-2011, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* */ #include "unicode/uchriter.h" #include "unicode/schriter.h" #include "unicode/ustring.h" #include #include #include #include static UFILE *out; using icu::CharacterIterator; using icu::StringCharacterIterator; using icu::UCharCharacterIterator; using icu::UnicodeString; 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; } PK!2f)6citer/citer.vcxproj.filtersnu[ {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx Source Files PK!Dciter/citer.vcxprojnu[ {247E2681-6C84-408B-B40C-5DB50BC5E18F} Application false MultiByte <_ProjectFileVersion>10.0.30319.1 x86\Debug\ x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true x86\Release\ x86\Release\ false .\x64\Release\ .\x64\Release\ false ..\..\..\include;%(AdditionalIncludeDirectories) true MultiThreadedDebug Level3 EditAndContinue icuucd.lib;icuind.lib;icuiod.lib;%(AdditionalDependencies) .\x86\Debug\citer.exe ..\..\..\lib;%(AdditionalLibraryDirectories) true $(OutDir)citer.pdb Console false ..\..\..\include;%(AdditionalIncludeDirectories) true MultiThreadedDebug Level3 ProgramDatabase icuucd.lib;icuind.lib;icuiod.lib;%(AdditionalDependencies) .\x64\Debug\citer.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) true $(OutDir)citer.pdb Console false ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreaded Level3 ProgramDatabase icuuc.lib;icuin.lib;icuio.lib;%(AdditionalDependencies) .\x86\Release\citer.exe ..\..\..\lib;%(AdditionalLibraryDirectories) true Console true false ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreaded Level3 ProgramDatabase icuuc.lib;icuin.lib;icuio.lib;%(AdditionalDependencies) .\x64\Release\citer.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) true Console true false PK!(F׮citer/readme.txtnu[Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License Copyright (c) 2003-2010, International Business Machines Corporation and others. All Rights Reserved. citer: Character Iteration This sample demonstrates Demonstrating ICU's CharacterIterator 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 (note that it may be in a different relative directory than most of the other samples). 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 /source runConfigureICU --prefix [other options] gmake all 2. Install ICU, gmake install 3. Compile cd /source/samples/citer gmake ICU_PREFIX=/source/samples/citer gmake ICU_PREFIX= check -or- export LD_LIBRARY_PATH=/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. PK!僙defs.mknu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # Copyright (c) 2002-2012 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=-r $(shell icu-config --version) -w -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 PK!>|R=BBplurfmtsample/plurfmtsample.cppnu[/******************************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ******************************************************************************** ******************************************************************************** * Copyright (C) 2008-2013, International Business Machines Corporation and * others. All Rights Reserved. ******************************************************************************** */ //! [PluralFormatExample1] #include #include "unicode/plurfmt.h" #include "unicode/msgfmt.h" #include "unicode/ustdio.h" //! [PluralFormatExample1] using namespace std; using namespace icu; static void PluralFormatExample() { u_printf("=============================================================================\n"); u_printf(" PluralFormatExample()\n"); u_printf("\n"); u_printf(" Use PluralFormat and Messageformat to get Plural Form for languages below:\n"); u_printf(" English, Slovenian\n"); u_printf("=============================================================================\n"); //! [PluralFormatExample] UErrorCode status =U_ZERO_ERROR; Locale locEn = Locale("en"); Locale locSl = Locale("sl"); UnicodeString patEn = UnicodeString("one{dog} other{dogs}"); // English 'dog' UnicodeString patSl = UnicodeString("one{pes} two{psa} few{psi} other{psov}"); // Slovenian translation of dog in Plural Form // Create a new PluralFormat for a given locale locale and pattern string PluralFormat plfmtEn = PluralFormat(locEn, patEn,status); PluralFormat plfmtSl = PluralFormat(locSl, patSl,status); // Constructs a MessageFormat for given pattern and locale. MessageFormat* msgfmtEn = new MessageFormat("{0,number} {1}", locEn,status); MessageFormat* msgfmtSl = new MessageFormat("{0,number} {1}", locSl,status); int numbers[] = {0, 1, 2, 3, 4, 5, 10, 100, 101, 102}; u_printf("Output by using PluralFormat and MessageFormat API\n"); u_printf("%-16s%-16s%-16s\n","Number", "English","Slovenian"); // Use MessageFormat.format () to format the objects and append to the given StringBuffer for (int i=0;iformat(argEn,2,msgEn,fpos,status); msgfmtSl->format(argSl,2,msgSl,fpos,status); u_printf("%-16d%-16S%-16S\n", numbers[i], msgEn.getTerminatedBuffer(),msgSl.getTerminatedBuffer()); } u_printf("\n"); // Equivalent code with message format pattern UnicodeString msgPatEn = "{0,plural, one{# dog} other{# dogs}}"; UnicodeString msgPatSl = "{0,plural, one{# pes} two{# psa} few{# psi} other{# psov}}"; MessageFormat* altMsgfmtEn = new MessageFormat(msgPatEn, locEn,status); MessageFormat* altMsgfmtSl = new MessageFormat(msgPatSl, locSl,status); u_printf("Same Output by using MessageFormat API only\n"); u_printf("%-16s%-16s%-16s\n","Number", "English","Slovenian"); for (int i=0;iformat(arg, 1, msgEn, fPos, status); altMsgfmtSl->format(arg, 1, msgSl, fPos,status); u_printf("%-16d%-16S%-16S\n", numbers[i], msgEn.getTerminatedBuffer(), msgSl.getTerminatedBuffer()); } delete msgfmtEn; delete msgfmtSl; delete altMsgfmtEn; delete altMsgfmtSl; //! [PluralFormatExample] /* output of the sample code: ******************************************************************** Number English Slovenian 0 0 dogs 0 psov 1 1 dog 1 pes 2 2 dogs 2 psa 3 3 dogs 3 psi 4 4 dogs 4 psi 5 5 dogs 5 psov 10 10 dogs 10 psov 100 100 dogs 100 psov 101 101 dogs 101 pes 102 102 dogs 102 psa *********************************************************************/ } int main (int argc, char* argv[]) { PluralFormatExample(); return 0; } PK!έ+plurfmtsample/plurfmtsample.vcxproj.filtersnu[ {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms Source Files PK! {B500B731-ED1A-4761-94ED-B22DFE25FF2B} Application true Unicode Application true Unicode Application false true MultiByte Application false true MultiByte .\x86\Debug\ .\x86\Debug\ $(ProjectName) .\x64\Debug\ .\x64\Debug\ $(ProjectName) .\x86\Release\ .\x86\Release\ $(ProjectName) .\x64\Release\ .\x64\Release\ $(ProjectName) Level3 Disabled ..\..\..\include;%(AdditionalIncludeDirectories) true .\x86\Debug\plurfmtsample.exe ..\..\..\lib;%(AdditionalLibraryDirectories) icuucd.lib;icuind.lib;icuiod.lib;%(AdditionalDependencies) Level3 Disabled ..\..\..\include;%(AdditionalIncludeDirectories) true .\x64\Debug\plurfmtsample.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) icuucd.lib;icuind.lib;icuiod.lib;%(AdditionalDependencies) Level3 MaxSpeed true true ..\..\..\include;%(AdditionalIncludeDirectories) true true true .\x86\Release\plurfmtsample.exe ..\..\..\lib;%(AdditionalLibraryDirectories) icuuc.lib;icuin.lib;icuio.lib;%(AdditionalDependencies) Level3 MaxSpeed true true ..\..\..\include;%(AdditionalIncludeDirectories) true true true .\x64\Release\plurfmtsample.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) icuuc.lib;icuin.lib;icuio.lib;%(AdditionalDependencies) PK! 3:datecal/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # 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 PK!@Udatecal/cal.cppnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * Copyright (C) 2002-2012, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* */ #include "unicode/calendar.h" #include "unicode/gregocal.h" #include extern "C" 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; } PK!msdatecal/ccal.cnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * Copyright (C) 2002-2003, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* */ #include "unicode/ucal.h" #include 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); } PK!uLhh coll/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # 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 PK!/ coll/coll.slnnu[Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "coll", "coll.vcxproj", "{7664D0D2-0263-4BFB-AE19-9A1CAD231440}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {7664D0D2-0263-4BFB-AE19-9A1CAD231440}.Debug|x64.Build.0 = Debug|x64 {7664D0D2-0263-4BFB-AE19-9A1CAD231440}.Release|Win32.ActiveCfg = Release|Win32 {7664D0D2-0263-4BFB-AE19-9A1CAD231440}.Release|Win32.Build.0 = Release|Win32 {7664D0D2-0263-4BFB-AE19-9A1CAD231440}.Release|x64.ActiveCfg = Release|x64 {7664D0D2-0263-4BFB-AE19-9A1CAD231440}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK!:oocoll/coll.vcxproj.filtersnu[ {cf7099c6-0d28-448a-bc7c-2e6dbaff530f} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {a5fd1af4-2570-4018-a6cf-c4e8b05cb316} h;hpp;hxx;hm;inl {719754c2-1947-46e6-9154-ba81ca673139} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files PK!D&&coll/coll.vcxprojnu[ {7664D0D2-0263-4BFB-AE19-9A1CAD231440} Application false MultiByte <_ProjectFileVersion>10.0.30319.1 .\x86\Release\ .\x86\Release\ false .\x64\Release\ .\x64\Release\ false .\x86\Debug\ .\x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true .\x86\Release/coll.tlb OnlyExplicitInline ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreaded true .\x86\Release/coll.pch .\x86\Release/ .\x86\Release/ .\x86\Release/ Level3 Default icuin.lib;icuuc.lib;%(AdditionalDependencies) .\x86\Release/coll.exe ..\..\..\lib;%(AdditionalLibraryDirectories) .\x86\Release/coll.pdb Console false .\x64\Release/coll.tlb OnlyExplicitInline ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreaded true .\x64\Release/coll.pch .\x64\Release/ .\x64\Release/ .\x64\Release/ Level3 Default icuin.lib;icuuc.lib;%(AdditionalDependencies) .\x64\Release/coll.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) .\x64\Release/coll.pdb Console false .\x86\Debug/coll.tlb ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDebug .\x86\Debug/coll.pch .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ true Level3 true EditAndContinue Default icuind.lib;icuucd.lib;%(AdditionalDependencies) .\x86\Debug/coll.exe ..\..\..\lib;%(AdditionalLibraryDirectories) true .\x86\Debug/coll.pdb Console false .\x64\Debug/coll.tlb Disabled ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDebug .\x64\Debug/coll.pch .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ true Level3 ProgramDatabase Default icuind.lib;icuucd.lib;%(AdditionalDependencies) .\x64\Debug/coll.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) true .\x64\Debug/coll.pdb Console false PK!׷ coll/coll.cppnu[/************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ************************************************************************* ************************************************************************* * 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, Secondary, 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 #include #include #include #include #include /** * 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; } PK!|coll/readme.txtnu[Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License 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 /source runConfigureICU --prefix [other options] gmake all 2. Install ICU, gmake install To Run on Unixes cd /source/samples/coll gmake check -or- export LD_LIBRARY_PATH=/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. PK!-pptranslit/util.hnu[/*********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** *********************************************************************** * COPYRIGHT: * Copyright (c) 1999-2002, International Business Machines Corporation and * others. All Rights Reserved. ***********************************************************************/ #include "unicode/unistr.h" using namespace icu; // 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); PK!ov~~translit/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # 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 PK!i%i%translit/translit.vcxprojnu[ {D1BEC124-303A-4F44-BA70-55769B8FE96A} Application false MultiByte <_ProjectFileVersion>10.0.30319.1 .\x86\Debug\ .\x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true .\x86\Release\ .\x86\Release\ false .\x64\Release\ .\x64\Release\ false ..\..\..\include;%(AdditionalIncludeDirectories) Level3 .\x86\Debug/translit.tlb MultiThreadedDebugDLL .\x86\Debug/translit.pch .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ EditAndContinue Default icuucd.lib;icuind.lib;%(AdditionalDependencies) .\x86\Debug/translit.exe ..\..\..\lib;%(AdditionalLibraryDirectories) true .\x86\Debug/translit.pdb Console false .\x64\Debug/translit.tlb MultiThreadedDebugDLL .\x64\Debug/translit.pch .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ ProgramDatabase Default icuucd.lib;icuind.lib;%(AdditionalDependencies) .\x64\Debug/translit.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) true .\x64\Debug/translit.pdb Console false .\x86\Release/translit.tlb OnlyExplicitInline MultiThreadedDLL true .\x86\Release/translit.pch .\x86\Release/ .\x86\Release/ .\x86\Release/ Default icuuc.lib;icuin.lib;%(AdditionalDependencies) .\x86\Release/translit.exe ..\..\..\lib;%(AdditionalLibraryDirectories) .\x86\Release/translit.pdb Console false .\x64\Release/translit.tlb OnlyExplicitInline MultiThreadedDLL true .\x64\Release/translit.pch .\x64\Release/ .\x64\Release/ .\x64\Release/ Default icuuc.lib;icuin.lib;%(AdditionalDependencies) .\x64\Release/translit.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) .\x64\Release/translit.pdb Console false PK! Gtranslit/answers/main_3.cppnu[/*********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** *********************************************************************** * 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 #include #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; } PK!pҏ00translit/answers/main_4.cppnu[/*********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** *********************************************************************** * 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 #include #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; } PK!V translit/answers/main_2.cppnu[/*********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** *********************************************************************** * 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 #include #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; } PK!\translit/answers/main_1.cppnu[/*********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** *********************************************************************** * 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 #include #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; } PK!QpNtranslit/answers/unaccent.cppnu[/*********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** * 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++; } } PK!%translit/answers/unaccent.hnu[/*********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** *********************************************************************** * 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; }; PK!Istranslit/translit.slnnu[Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translit", "translit.vcxproj", "{D1BEC124-303A-4F44-BA70-55769B8FE96A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Debug|x64.Build.0 = Debug|x64 {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Release|Win32.ActiveCfg = Release|Win32 {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Release|Win32.Build.0 = Release|Win32 {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Release|x64.ActiveCfg = Release|x64 {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK!BrhSStranslit/README.TXTnu[Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License Copyright (c) 2002-2010, International Business Machines Corporation and others. All Rights Reserved. IMPORTANT: This sample was originally intended as an exercise for the ICU Workshop (September 2000). The code currently provided in the solution file is the answer to the exercises, each step can still be found in the 'answers' subdirectory. 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! PK!PC3translit/main.cppnu[/*********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** *********************************************************************** * 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 #include #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; } PK!translit/unaccent.cppnu[/********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ********************************************************************** ********************************************************************** * 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++; } } PK!w׎translit/util.cppnu[/*********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** *********************************************************************** * COPYRIGHT: * Copyright (c) 1999-2010, International Business Machines Corporation and * others. All Rights Reserved. ***********************************************************************/ #include "unicode/unistr.h" #include #include using namespace icu; // 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 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; } PK!_6!translit/translit.vcxproj.filtersnu[ {54b54bed-3b7b-4c0c-88b9-c7d168eb2b2f} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {1b482e95-f708-45c1-afa7-842defddd5ab} h;hpp;hxx;hm;inl {33d7c053-4ff7-4f22-974c-5c36cf13b8f6} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files Source Files Source Files Header Files PK!O translit/unaccent.hnu[/*********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** *********************************************************************** * COPYRIGHT: * Copyright (c) 1999-2003, International Business Machines Corporation and * others. All Rights Reserved. ***********************************************************************/ #include "unicode/translit.h" #include "unicode/normlzr.h" using namespace icu; 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: *
     * .      Base* polymorphic_pointer = createPolymorphicObject();
     * .      if (polymorphic_pointer->getDynamicClassID() ==
     * .          Derived::getStaticClassID()) ...
     * 
* @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 polymorphically. 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. * *

Concrete subclasses of Transliterator that wish clients to * be able to identify them should implement getDynamicClassID() * and also a static method and data member: * *

     * static UClassID getStaticClassID() { return (UClassID)&fgClassID; }
     * static char fgClassID;
     * 
* * 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; }; PK!V case/case.slnnu[Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "case", "case.vcxproj", "{2316BE8C-189D-4C8B-B506-9D9EE25AC46D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Debug|x64.Build.0 = Debug|x64 {2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Release|Win32.ActiveCfg = Release|Win32 {2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Release|Win32.Build.0 = Release|Win32 {2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Release|x64.ActiveCfg = Release|x64 {2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK!o$ case/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # 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 PK!6 6 case/case.cppnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * Copyright (C) 2003-2004, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* */ #include #include #include #include using namespace icu; 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; } PK!ƙcase/case.vcxproj.filtersnu[ {43ee3899-8fc9-43ee-afb1-56fc646637b4} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {f8bfa07a-99cc-427e-900b-d224ca9d1a65} h;hpp;hxx;hm;inl {4a483140-b33a-4ddb-a2b5-e481b417d590} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files Source Files PK!/source runConfigureICU --prefix [other options] gmake all 2. Install ICU, gmake install 3. Compile cd /source/samples/case gmake ICU_PREFIX=/source/samples/case gmake ICU_PREFIX= check -or- export LD_LIBRARY_PATH=/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. PK!1zHW case/ucase.cnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * 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 English 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; } PK!#9%%case/case.vcxprojnu[ {2316BE8C-189D-4C8B-B506-9D9EE25AC46D} Application false MultiByte <_ProjectFileVersion>10.0.30319.1 .\x86\Debug\ .\x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true .\x86\Release\ .\x86\Release\ false .\x64\Release\ .\x64\Release\ false ..\..\..\include;%(AdditionalIncludeDirectories) Level3 true .\x86\Debug/case.tlb MultiThreadedDebug .\x86\Debug/case.pch .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ EditAndContinue Default icuucd.lib;icuind.lib;icuiod.lib;%(AdditionalDependencies) .\x86\Debug/case.exe ..\..\..\lib;%(AdditionalLibraryDirectories) .\x86\Debug/case.pdb Console false .\x64\Debug/case.tlb MultiThreadedDebug .\x64\Debug/case.pch .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ ProgramDatabase Default icuucd.lib;icuind.lib;icuiod.lib;%(AdditionalDependencies) .\x64\Debug/case.exe true ..\..\..\lib64;%(AdditionalLibraryDirectories) true .\x64\Debug/case.pdb Console false .\x86\Release/case.tlb OnlyExplicitInline MultiThreaded true .\x86\Release/case.pch .\x86\Release/ .\x86\Release/ .\x86\Release/ Default icuuc.lib;icuin.lib;icuio.lib;%(AdditionalDependencies) .\x86\Release/case.exe ..\..\..\lib;%(AdditionalLibraryDirectories) .\x86\Release/case.pdb Console false .\x64\Release/case.tlb OnlyExplicitInline MultiThreaded true .\x64\Release/case.pch .\x64\Release/ .\x64\Release/ .\x64\Release/ Default icuuc.lib;icuin.lib;icuio.lib;%(AdditionalDependencies) .\x64\Release/case.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) .\x64\Release/case.pdb Console false PK!]+vqufortune/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # 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) PK!YEEufortune/ufortune.vcxprojnu[ Debug Win32 Release Win32 {25F534DF-93C9-4853-A88E-DB7D8CF74042} 8.1 Application false MultiByte v141 .\x86\Debug\ .\x86\Debug\ $(ProjectName) .\x86\Release\ .\x86\Release\ $(ProjectName) .\x86\Debug/ufortune.tlb Disabled ..\..\..\include;%(AdditionalIncludeDirectories) WINVER=0x0601;_WIN32_WINNT=0x0601;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL true Level3 true EditAndContinue Default _DEBUG;%(PreprocessorDefinitions) 0x0409 icuucd.lib;resources\fortune_resources.lib;icuiod.lib;%(AdditionalDependencies) true ../../../lib;%(AdditionalLibraryDirectories) true Console false .\x86\Release/ufortune.tlb OnlyExplicitInline ..\..\..\include;%(AdditionalIncludeDirectories) WINVER=0x0601;_WIN32_WINNT=0x0601;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) true MultiThreadedDLL true true Level3 true Default NDEBUG;%(PreprocessorDefinitions) 0x0409 icuuc.lib;resources\fortune_resources.lib;icuio.lib;%(AdditionalDependencies) true ../../../lib;%(AdditionalLibraryDirectories) Console false cd resources nmake -f fortune_resources.mak CFG=x86\Debug copy Fortune_Resources.DLL "$(TargetDir)" resources\fortune_resources.DLL;%(Outputs) cd resources nmake -f fortune_resources.mak CFG=x86\Release copy Fortune_Resources.DLL "$(TargetDir)" resources\fortune_resources.DLL;%(Outputs) PK!ƃ!ufortune/ufortune.slnnu[Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ufortune", "ufortune.vcxproj", "{25F534DF-93C9-4853-A88E-DB7D8CF74042}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {25F534DF-93C9-4853-A88E-DB7D8CF74042}.Debug|x64.Build.0 = Debug|x64 {25F534DF-93C9-4853-A88E-DB7D8CF74042}.Release|Win32.ActiveCfg = Release|Win32 {25F534DF-93C9-4853-A88E-DB7D8CF74042}.Release|Win32.Build.0 = Release|Win32 {25F534DF-93C9-4853-A88E-DB7D8CF74042}.Release|x64.ActiveCfg = Release|x64 {25F534DF-93C9-4853-A88E-DB7D8CF74042}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK!t!ufortune/ufortune.vcxproj.filtersnu[ {6ab67213-fd7b-45cd-b44f-8deffb1990ac} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {b342f76f-065b-4c8c-9abc-4e524e21ab35} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe {492bec7f-3152-419a-afa7-8735518021f6} h;hpp;hxx;hm;inl {aa083dae-ee83-4d36-bb4f-8a592bf805d1} Source Files Resource Files Resource Files Resource Files Makefile PK!VPufortune/ufortune.cnu[/************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ************************************************************************** ************************************************************************** * * 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 #include #include #include #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/source runConfigureICU --prefix [other options] gmake all 2. Install ICU, gmake install 3. Build the sample cd /source/samples/ufortune export ICU_PREFIX= gmake To Run on Unixes cd /source/samples/ufortune gmake check or export LD_LIBRARY_PATH=/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. PK!>dufortune/resources/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # Copyright (c) 2001-2011 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 $(RESNAME)_dat* 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) $^ PK!C4(ufortune/resources/fortune_resources.maknu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # Copyright (c) 2001-2009 IBM, Inc. and others # # fortune_resources.mak # # Windows nmake makefile for compiling and packaging the resources # 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=..\..\..\.. # # The directory that contains the tools. # !IF "$(CFG)" == "x64\Release" || "$(CFG)" == "x64\Debug" BIN=bin64 !ELSE BIN=bin !ENDIF # # 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 PK!{$ufortune/resources/res-file-list.txtnu[root.res es.res PK!C,,ufortune/resources/root.txtnu[// Copyright (C) 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html#License // // 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.\" " } } PK!`@@ufortune/resources/es.txtnu[// Copyright (C) 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html#License // // 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. " } } PK!' ' ucnv/data06.txtnu[// ******************************************************************************* // * // * Copyright (C) 2016 and later: Unicode, Inc. and others. // * License & terms of use: http://www.unicode.org/copyright.html#License // * // ******************************************************************************* // ******************************************************************************* // * // * 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{} // } PK! 8 ucnv/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # 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 PK!8sCCucnv/data01.txtnu[-*- 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футбол중앙일보-の“日本語” PK!)G,Eucnv/data02.binnu[@@@|KK@@%@zaaKKKaaa%%ȉ@@Ԩ@@Ö@㈉@@K@K@%Յ@薙z@Ӆ@P@@™Kk@@Ȗ@⣙K%%ŕ@@@@@@Ö@@@@k%¨@KK@㖦@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%PK!ܶM8%8%ucnv/ucnv.vcxprojnu[ {8C95060E-61F5-464E-BB42-95B788C0D7E4} Application false MultiByte <_ProjectFileVersion>10.0.30319.1 .\x86\Debug\ .\x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true .\x86\Release\ .\x86\Release\ false .\x64\Release\ .\x64\Release\ false ..\..\..\include;%(AdditionalIncludeDirectories) Level3 .\x86\Debug/ucnv.tlb MultiThreadedDebugDLL .\x86\Debug/ucnv.pch .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ EditAndContinue Default icuucd.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) .\x86\Debug/ucnv.exe ..\..\..\lib;%(AdditionalLibraryDirectories) true .\x86\Debug/ucnv.pdb Console false .\x64\Debug/ucnv.tlb MultiThreadedDebugDLL .\x64\Debug/ucnv.pch .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ ProgramDatabase Default icuucd.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) .\x64\Debug/ucnv.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) true .\x64\Debug/ucnv.pdb Console false .\x86\Release/ucnv.tlb OnlyExplicitInline MultiThreadedDLL true .\x86\Release/ucnv.pch .\x86\Release/ .\x86\Release/ .\x86\Release/ Default icuuc.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) .\x86\Release/ucnv.exe ..\..\..\lib;%(AdditionalLibraryDirectories) .\x86\Release/ucnv.pdb Console false .\x64\Release/ucnv.tlb OnlyExplicitInline MultiThreadedDLL true .\x64\Release/ucnv.pch .\x64\Release/ .\x64\Release/ .\x64\Release/ Default icuuc.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) .\x64\Release/ucnv.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) .\x64\Release/ucnv.pdb Console false PK!{ ucnv/ucnv.slnnu[Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ucnv", "ucnv.vcxproj", "{8C95060E-61F5-464E-BB42-95B788C0D7E4}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {8C95060E-61F5-464E-BB42-95B788C0D7E4}.Debug|x64.Build.0 = Debug|x64 {8C95060E-61F5-464E-BB42-95B788C0D7E4}.Release|Win32.ActiveCfg = Release|Win32 {8C95060E-61F5-464E-BB42-95B788C0D7E4}.Release|Win32.Build.0 = Release|Win32 {8C95060E-61F5-464E-BB42-95B788C0D7E4}.Release|x64.ActiveCfg = Release|x64 {8C95060E-61F5-464E-BB42-95B788C0D7E4}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK!m^ ucnv/flagcb.hnu[/* © 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License 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 PK!ε2ttucnv/convsamp.cppnu[/************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ************************************************************************** ************************************************************************** * * Copyright (C) 2000-2016, 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 #include /* for isspace, etc. */ #include #include #include /* 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 */ #ifndef UPRV_LENGTHOF #define UPRV_LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) #endif 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_EXTENDED_CHAR_NAME, buf, 1000, &status); if(U_SUCCESS(status) && (o>0) ) { buf[6] = 0; printf("%7s", 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 (strlen(uch)); } printf("%5s: ", name); for( i = 0; i 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 ******************* // "catOK" 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 //! [ucnv_open] conv = ucnv_open("koi8-r", &status); //! [ucnv_open] 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(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(sizeof(CharFreqInfo)*charCount)); } /* reset frequencies */ for(p=0;p(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); free(info); fclose(f); ucnv_close(conv); 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 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, static_cast(strlen(source)), &status); U_ASSERT(status); // close the converter ucnv_close(conv); // ***************************** END SAMPLE ******************** // Print it out printBytes("src", source, static_cast(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, static_cast(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, static_cast(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; 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, static_cast(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 cloneCnv = ucnv_safeClone(conv, NULL, NULL, &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"); fclose(f); 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=static_cast(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 += static_cast((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"); fclose(f); 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=static_cast(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 += static_cast((target-buf)); } while (source < sourceLimit); // while simply out of space } printf("%d Uchars (%d bytes) in, %d chars out.\n", inchars, static_cast(inchars * sizeof(UChar)), total); // ***************************** END SAMPLE ******************** ucnv_close(conv); fclose(f); fclose(out); printf("\n"); return U_ZERO_ERROR; } #undef BUFFERSIZE #define BUFFERSIZE 219 void convsample_50() { printf("\n\n==============================================\n" "Sample 50: C: ucnv_detectUnicodeSignature\n"); //! [ucnv_detectUnicodeSignature] UErrorCode err = U_ZERO_ERROR; UBool discardSignature = TRUE; /* set to TRUE to throw away the initial U+FEFF */ char input[] = { '\xEF','\xBB', '\xBF','\x41','\x42','\x43' }; int32_t signatureLength = 0; const char *encoding = ucnv_detectUnicodeSignature(input,sizeof(input),&signatureLength,&err); UConverter *conv = NULL; UChar output[100]; UChar *target = output, *out; const char *source = input; if(encoding!=NULL && U_SUCCESS(err)){ // should signature be discarded ? conv = ucnv_open(encoding, &err); // do the conversion ucnv_toUnicode(conv, &target, output + UPRV_LENGTHOF(output), &source, input + sizeof(input), NULL, TRUE, &err); out = output; if (discardSignature){ ++out; // ignore initial U+FEFF } while(out != target) { printf("%04x ", *out++); } puts(""); } //! [ucnv_detectUnicodeSignature] puts(""); } /* 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] convsample_50(); // C, detect unicode signature printf("End of converter samples.\n"); fflush(stdout); fflush(stderr); return 0; } PK!g## ucnv/flagcb.cnu[/************************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ************************************************************************** ************************************************************************** * 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 #include #include #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; } PK!c; ucnv/readme.txtnu[Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License Copyright (C) 2002-2010, 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 WARNING: The .bin and .txt files must be in the same directory as the executable, which is not the case by default on some systems. 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 /source runConfigureICU --prefix [other options] gmake all 2. Install ICU, gmake install 3. Build set the variable ICU_PREFIX= gmake all To Run on Unixes cd /source/samples/ucnv gmake check -or- export LD_LIBRARY_PATH=/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. PK! @@ucnv/ucnv.vcxproj.filtersnu[ {a6fcae56-1378-4c39-8eba-41a0b2ce48cc} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {3f311d2a-87ba-4d72-a595-0996b7f3b3ee} h;hpp;hxx;hm;inl {1ac535db-fcad-45d6-87f2-3eb87a31a25f} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files Source Files Header Files PK!;!R Makefile.innu[## Makefile.in for ICU samples ## Copyright (C) 2016 and later: Unicode, Inc. and others. ## License & terms of use: http://www.unicode.org/copyright.html#License ## ## Copyright (c) 1999-2011, 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 ugrep ## 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 check-exhaustive ## 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 check-exhaustive: check ## 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 PK!K(wwdatefmt/util.hnu[/******************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ************************************************************************* ************************************************************************* * COPYRIGHT: * Copyright (c) 1999-2003, International Business Machines Corporation and * others. All Rights Reserved. *************************************************************************/ #include "unicode/unistr.h" using namespace icu; // 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); PK!ԁVVdatefmt/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # 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 PK!,S8  datefmt/answers/main_3.cppnu[/******************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ************************************************************************* ************************************************************************* * 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 #include #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; iadoptTimeZone(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; } PK!m. datefmt/answers/main_2.cppnu[/******************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ************************************************************************* ************************************************************************* * 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 #include #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; iformat(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; } PK! ccdatefmt/answers/main_1.cppnu[/******************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ************************************************************************* ************************************************************************* * 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 #include #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 #include #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 {a5cbb044-7694-4d1d-98c1-bb578ee7f1ea} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {aadf5a92-1812-45ce-90a0-e9db3945d7c5} h;hpp;hxx;hm;inl {9eff3ddc-6822-4225-81fc-a867b9e592c0} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files Source Files PK!ILL61&1&datefmt/datefmt.vcxprojnu[ {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4} Application false MultiByte <_ProjectFileVersion>10.0.30319.1 .\x86\Debug\ .\x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true .\x86\Release\ .\x86\Release\ false .\x64\Release\ .\x64\Release\ false .\x86\Debug/datefmt.tlb ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL .\x86\Debug/datefmt.pch .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ Level3 EditAndContinue Default icuucd.lib;icuind.lib;%(AdditionalDependencies) .\x86\Debug/datefmt.exe ..\..\..\lib;%(AdditionalLibraryDirectories) true .\x86\Debug/datefmt.pdb Console false .\x64\Debug/datefmt.tlb ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL .\x64\Debug/datefmt.pch .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ Level3 ProgramDatabase Default icuucd.lib;icuind.lib;%(AdditionalDependencies) .\x64\Debug/datefmt.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) true .\x64\Debug/datefmt.pdb Console false .\x86\Release/datefmt.tlb OnlyExplicitInline ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDLL true .\x86\Release/datefmt.pch .\x86\Release/ .\x86\Release/ .\x86\Release/ Level3 Default icuuc.lib;icuin.lib;%(AdditionalDependencies) .\x86\Release/datefmt.exe ..\..\..\lib;%(AdditionalLibraryDirectories) .\x86\Release/datefmt.pdb Console false .\x64\Release/datefmt.tlb OnlyExplicitInline ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDLL true .\x64\Release/datefmt.pch .\x64\Release/ .\x64\Release/ .\x64\Release/ Level3 Default icuuc.lib;icuin.lib;%(AdditionalDependencies) .\x64\Release/datefmt.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) .\x64\Release/datefmt.pdb Console false PK!cb>>datefmt/README.TXTnu[Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License Copyright (c) 2002-2010, International Business Machines Corporation and others. All Rights Reserved. IMPORTANT: This sample was originally intended as an exercise for the ICU Workshop (September 2000). The code currently provided in the solution file is the answer to the exercises, each step can still be found in the 'answers' subdirectory. ** Workshop homepage is: http://www.icu-project.org/docs/workshop_2000/agenda.html #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! PK!lC C datefmt/main.cppnu[/************************************************************************* * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ************************************************************************* ************************************************************************* * 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 #include #include "util.h" using namespace icu; /** * 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 const 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 const 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; iadoptTimeZone(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; } PK!< datefmt/util.cppnu[/******************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ************************************************************************* ************************************************************************* * COPYRIGHT: * Copyright (c) 1999-2003, International Business Machines Corporation and * others. All Rights Reserved. *************************************************************************/ #include "unicode/unistr.h" #include #include using namespace icu; // 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 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; } PK!,__all/samplecheck.batnu[@echo off REM Copyright (C) 2016 and later: Unicode, Inc. and others. REM License & terms of use: http://www.unicode.org/copyright.html REM ******************************************************************** REM Don't add additional global environment variables, keep the variables local to this script. rem setlocal set ICU_ARCH=%1 set ICU_DBRL=%2 if "%1" == "" ( echo Usage: %0 "x86 or x64" "Debug or Release" exit /b 1 ) if "%2" == "" ( echo Usage: %0 %1 "Debug or Release" exit /b 1 ) set ICU_ICUDIR="%~dp0"\..\..\.. set ICU_SAMPLESDIR=%ICU_ICUDIR%\source\samples if "%ICU_ARCH%" == "x64" ( set ICU_BINDIR=%~dp0..\..\..\bin64 ) else ( set ICU_BINDIR=%~dp0..\..\..\bin ) if not exist "%ICU_BINDIR%" ( echo Error '%ICU_BINDIR%' does not exist! echo Have you built all of ICU yet ? goto :eof ) echo Testing ICU samples in %ICU_ICUDIR% arch=%ICU_ARCH% type=%ICU_DBRL% set PATH=%ICU_BINDIR%;%PATH% pushd %ICU_BINDIR% set SAMPLE_BREAK=%ICU_SAMPLESDIR%\break\%ICU_ARCH%\%ICU_DBRL%\break.exe set SAMPLE_CAL=%ICU_SAMPLESDIR%\cal\%ICU_ARCH%\%ICU_DBRL%\cal.exe set SAMPLE_CASE=%ICU_SAMPLESDIR%\case\%ICU_ARCH%\%ICU_DBRL%\case.exe set SAMPLE_CITER=%ICU_SAMPLESDIR%\citer\%ICU_ARCH%\%ICU_DBRL%\citer.exe set SAMPLE_COLL=%ICU_SAMPLESDIR%\coll\%ICU_ARCH%\%ICU_DBRL%\coll.exe set SAMPLE_CSDET=%ICU_SAMPLESDIR%\csdet\%ICU_ARCH%\%ICU_DBRL%\csdet.exe set SAMPLE_DATE=%ICU_SAMPLESDIR%\date\%ICU_ARCH%\%ICU_DBRL%\date.exe set SAMPLE_DATEFMT=%ICU_SAMPLESDIR%\datefmt\%ICU_ARCH%\%ICU_DBRL%\datefmt.exe set SAMPLE_DTITVFMT=%ICU_SAMPLESDIR%\dtitvfmtsample\%ICU_ARCH%\%ICU_DBRL%\dtitvfmtsample.exe set SAMPLE_DTPTNG=%ICU_SAMPLESDIR%\dtptngsample\%ICU_ARCH%\%ICU_DBRL%\dtptngsample.exe set SAMPLE_MSGFMT=%ICU_SAMPLESDIR%\msgfmt\%ICU_ARCH%\%ICU_DBRL%\msgfmt.exe set SAMPLE_NUMFMT=%ICU_SAMPLESDIR%\numfmt\%ICU_ARCH%\%ICU_DBRL%\numfmt.exe set SAMPLE_PLURFMTSAMPLE=%ICU_SAMPLESDIR%\plurfmtsample\%ICU_ARCH%\%ICU_DBRL%\plurfmtsample.exe set SAMPLE_PROPS=%ICU_SAMPLESDIR%\props\%ICU_ARCH%\%ICU_DBRL%\props.exe set SAMPLE_STRSRCH=%ICU_SAMPLESDIR%\strsrch\%ICU_ARCH%\%ICU_DBRL%\strsrch.exe set SAMPLE_TRANSLIT=%ICU_SAMPLESDIR%\translit\%ICU_ARCH%\%ICU_DBRL%\translit.exe set SAMPLE_UCITER8=%ICU_SAMPLESDIR%\uciter8\%ICU_ARCH%\%ICU_DBRL%\uciter8.exe set SAMPLE_UCNV=%ICU_SAMPLESDIR%\ucnv\%ICU_ARCH%\%ICU_DBRL%\ucnv.exe REM udata needs changes to the vcxproj to change the output locations for writer/reader. rem set SAMPLE_UDATA_WRITER=%ICU_SAMPLESDIR%\udata\%ICU_ARCH%\%ICU_DBRL%\writer.exe rem set SAMPLE_UDATA_READER=%ICU_SAMPLESDIR%\udata\%ICU_ARCH%\%ICU_DBRL%\reader.exe set SAMPLE_UFORTUNE=%ICU_SAMPLESDIR%\ufortune\%ICU_ARCH%\%ICU_DBRL%\ufortune.exe set SAMPLE_UGREP=%ICU_SAMPLESDIR%\ugrep\%ICU_ARCH%\%ICU_DBRL%\ugrep.exe REM There is also the 'resources' project in VS. set SAMPLE_URESB=%ICU_SAMPLESDIR%\uresb\%ICU_ARCH%\%ICU_DBRL%\uresb.exe set SAMPLE_USTRING=%ICU_SAMPLESDIR%\ustring\%ICU_ARCH%\%ICU_DBRL%\ustring.exe @set THT=break @echo. @echo ==== %THT% ========================================================================= %SAMPLE_BREAK% if ERRORLEVEL 1 goto :SampleError @set THT=cal @echo. @echo ==== %THT% ========================================================================= %SAMPLE_CAL% if ERRORLEVEL 1 goto :SampleError @set THT=case @echo. @echo ==== %THT% ========================================================================= %SAMPLE_CASE% if ERRORLEVEL 1 goto :SampleError @set THT=citer @echo. @echo ==== %THT% ========================================================================= %SAMPLE_CITER% if ERRORLEVEL 1 goto :SampleError @set THT=coll @echo. @echo ==== %THT% ========================================================================= %SAMPLE_COLL% if ERRORLEVEL 1 goto :SampleError @set THT=csdet @echo. @echo ==== %THT% ========================================================================= %SAMPLE_CSDET% %ICU_SAMPLESDIR%\csdet\readme.txt if ERRORLEVEL 1 goto :SampleError @set THT=date @echo. @echo ==== %THT% ========================================================================= %SAMPLE_DATE% if ERRORLEVEL 1 goto :SampleError @set THT=datefmt @echo. @echo ==== %THT% ========================================================================= %SAMPLE_DATEFMT% if ERRORLEVEL 1 goto :SampleError @set THT=dtitvfmtsample @echo. @echo ==== %THT% ========================================================================= %SAMPLE_DTITVFMT% if ERRORLEVEL 1 goto :SampleError @set THT=dtptngsample @echo. @echo ==== %THT% ========================================================================= pushd %ICU_SAMPLESDIR%\dtptngsample\%ICU_ARCH%\%ICU_DBRL% %SAMPLE_DTPTNG% popd if ERRORLEVEL 1 goto :SampleError @set THT=msgfmt @echo. @echo ==== %THT% ========================================================================= %SAMPLE_MSGFMT% arg1 arg2 if ERRORLEVEL 1 goto :SampleError @set THT=numfmt @echo. @echo ==== %THT% ========================================================================= %SAMPLE_NUMFMT% if ERRORLEVEL 1 goto :SampleError @set THT=plurfmtsample @echo. @echo ==== %THT% ========================================================================= %SAMPLE_PLURFMTSAMPLE% if ERRORLEVEL 1 goto :SampleError @set THT=props @echo. @echo ==== %THT% ========================================================================= %SAMPLE_PROPS% if ERRORLEVEL 1 goto :SampleError @set THT=strsrch @echo. @echo ==== %THT% ========================================================================= %SAMPLE_STRSRCH% if ERRORLEVEL 1 goto :SampleError @set THT=translit @echo. @echo ==== %THT% ========================================================================= %SAMPLE_TRANSLIT% if ERRORLEVEL 1 goto :SampleError @set THT=citer8 @echo. @echo ==== %THT% ========================================================================= %SAMPLE_UCITER8% if ERRORLEVEL 1 goto :SampleError @set THT=ucnv @echo. @echo ==== %THT% ========================================================================= pushd %ICU_SAMPLESDIR%\ucnv %SAMPLE_UCNV% popd if ERRORLEVEL 1 goto :SampleError REM TODO: udata needs changes to the vcxproj file to fix the output locations for writer/reader. @set THT=udata @echo. @echo ==== %THT% ========================================================================= pushd %ICU_SAMPLESDIR%\udata\%ICU_ARCH%\%ICU_DBRL% @echo TODO: udata needs changes to the vcxproj file to fix the output locations for writer/reader. @echo Skipping %THT% rem %SAMPLE_UDATA_WRITER% rem %SAMPLE_UDATA_READER% popd if ERRORLEVEL 1 goto :SampleError @set THT=ufortune @echo. @echo ==== %THT% ========================================================================= if "%ICU_ARCH%" == "x64" ( @echo The ufortune sample currently only runs on x86. @echo Skipping %THT%. ) else ( %SAMPLE_UFORTUNE% if ERRORLEVEL 1 goto :SampleError ) @set THT=ugrep @echo. @echo ==== %THT% ========================================================================= echo Looking for "ICU" in '%ICU_SAMPLESDIR%\ugrep\readme.txt' with ugrep.exe %SAMPLE_UGREP% ICU %ICU_SAMPLESDIR%\ugrep\readme.txt if ERRORLEVEL 1 goto :SampleError @set THT=uresb @echo. @echo ==== %THT% ========================================================================= pushd %ICU_SAMPLESDIR%\uresb %SAMPLE_URESB% en %SAMPLE_URESB% root %SAMPLE_URESB% sr popd if ERRORLEVEL 1 goto :SampleError @set THT=ustring @echo. @echo ==== %THT% ========================================================================= %SAMPLE_USTRING% if ERRORLEVEL 1 goto :SampleError rem All done goto :QuitWithNoError :SampleError echo. echo ERROR: Sample program %THT% did not exit cleanly. Stopping execution. echo. goto :QuitWithError :QuitWithNoError echo. popd exit /b 0 :QuitWithError echo. popd rem Exit with non-zero error code. exit /b 1 PK!JJ all/all.slnnu[Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27130.2036 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "break", "..\break\break.vcxproj", "{DEEADF02-9C14-4854-A395-E505D2904D65}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cal", "..\cal\cal.vcxproj", "{F7659D77-09CF-4FE9-ACEE-927287AA9509}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "case", "..\case\case.vcxproj", "{2316BE8C-189D-4C8B-B506-9D9EE25AC46D}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "date", "..\date\date.vcxproj", "{38B5751A-C6F9-4409-950C-F4F9DA17275F}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "datefmt", "..\datefmt\datefmt.vcxproj", "{6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msgfmt", "..\msgfmt\msgfmt.vcxproj", "{5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "numfmt", "..\numfmt\numfmt.vcxproj", "{721FBD47-E458-4C35-90DA-FF192907D5E2}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "props", "..\props\props.vcxproj", "{ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reader", "..\udata\reader.vcxproj", "{BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "resources", "..\uresb\resources.vcxproj", "{69437707-2FEF-4E2C-8C3F-6E6B3D241366}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "strsrch", "..\strsrch\strsrch.vcxproj", "{E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translit", "..\translit\translit.vcxproj", "{D1BEC124-303A-4F44-BA70-55769B8FE96A}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uciter8", "..\uciter8\uciter8.vcxproj", "{94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ucnv", "..\ucnv\ucnv.vcxproj", "{8C95060E-61F5-464E-BB42-95B788C0D7E4}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ufortune", "..\ufortune\ufortune.vcxproj", "{25F534DF-93C9-4853-A88E-DB7D8CF74042}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ugrep", "..\ugrep\ugrep.vcxproj", "{63166CEB-02CC-472C-B3B7-E6C559939BDA}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uresb", "..\uresb\uresb.vcxproj", "{92580BF4-F4DA-4024-B3F8-444F982BC72F}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ustring", "..\ustring\ustring.vcxproj", "{FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "writer", "..\udata\writer.vcxproj", "{40A90302-F173-4629-A003-F571D2D93D16}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "citer", "..\citer\citer.vcxproj", "{247E2681-6C84-408B-B40C-5DB50BC5E18F}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "coll", "..\coll\coll.vcxproj", "{7664D0D2-0263-4BFB-AE19-9A1CAD231440}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "csdet", "..\csdet\csdet.vcxproj", "{683745AD-3BC2-4B89-898B-93490D7F2757}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dtitvfmtsample", "..\dtitvfmtsample\dtitvfmtsample.vcxproj", "{8945255B-473B-4C47-9425-E92384338CAA}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "plurfmtsample", "..\plurfmtsample\plurfmtsample.vcxproj", "{B500B731-ED1A-4761-94ED-B22DFE25FF2B}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dtptngsample", "..\dtptngsample\dtptngsample.vcxproj", "{115886F0-7DFB-4B8B-BE79-83162EE8713B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {DEEADF02-9C14-4854-A395-E505D2904D65}.Debug|x64.ActiveCfg = Debug|x64 {DEEADF02-9C14-4854-A395-E505D2904D65}.Debug|x64.Build.0 = Debug|x64 {DEEADF02-9C14-4854-A395-E505D2904D65}.Debug|x86.ActiveCfg = Debug|Win32 {DEEADF02-9C14-4854-A395-E505D2904D65}.Debug|x86.Build.0 = Debug|Win32 {DEEADF02-9C14-4854-A395-E505D2904D65}.Release|x64.ActiveCfg = Release|x64 {DEEADF02-9C14-4854-A395-E505D2904D65}.Release|x64.Build.0 = Release|x64 {DEEADF02-9C14-4854-A395-E505D2904D65}.Release|x86.ActiveCfg = Release|Win32 {DEEADF02-9C14-4854-A395-E505D2904D65}.Release|x86.Build.0 = Release|Win32 {F7659D77-09CF-4FE9-ACEE-927287AA9509}.Debug|x64.ActiveCfg = Debug|x64 {F7659D77-09CF-4FE9-ACEE-927287AA9509}.Debug|x64.Build.0 = Debug|x64 {F7659D77-09CF-4FE9-ACEE-927287AA9509}.Debug|x86.ActiveCfg = Debug|Win32 {F7659D77-09CF-4FE9-ACEE-927287AA9509}.Debug|x86.Build.0 = Debug|Win32 {F7659D77-09CF-4FE9-ACEE-927287AA9509}.Release|x64.ActiveCfg = Release|x64 {F7659D77-09CF-4FE9-ACEE-927287AA9509}.Release|x64.Build.0 = Release|x64 {F7659D77-09CF-4FE9-ACEE-927287AA9509}.Release|x86.ActiveCfg = Release|Win32 {F7659D77-09CF-4FE9-ACEE-927287AA9509}.Release|x86.Build.0 = Release|Win32 {2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Debug|x64.ActiveCfg = Debug|x64 {2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Debug|x64.Build.0 = Debug|x64 {2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Debug|x86.ActiveCfg = Debug|Win32 {2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Debug|x86.Build.0 = Debug|Win32 {2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Release|x64.ActiveCfg = Release|x64 {2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Release|x64.Build.0 = Release|x64 {2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Release|x86.ActiveCfg = Release|Win32 {2316BE8C-189D-4C8B-B506-9D9EE25AC46D}.Release|x86.Build.0 = Release|Win32 {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Debug|x64.ActiveCfg = Debug|x64 {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Debug|x64.Build.0 = Debug|x64 {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Debug|x86.ActiveCfg = Debug|Win32 {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Debug|x86.Build.0 = Debug|Win32 {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Release|x64.ActiveCfg = Release|x64 {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Release|x64.Build.0 = Release|x64 {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Release|x86.ActiveCfg = Release|Win32 {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Release|x86.Build.0 = Release|Win32 {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Debug|x64.ActiveCfg = Debug|x64 {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Debug|x64.Build.0 = Debug|x64 {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Debug|x86.ActiveCfg = Debug|Win32 {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Debug|x86.Build.0 = Debug|Win32 {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Release|x64.ActiveCfg = Release|x64 {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Release|x64.Build.0 = Release|x64 {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Release|x86.ActiveCfg = Release|Win32 {6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Release|x86.Build.0 = Release|Win32 {5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}.Debug|x64.ActiveCfg = Debug|x64 {5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}.Debug|x64.Build.0 = Debug|x64 {5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}.Debug|x86.ActiveCfg = Debug|Win32 {5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}.Debug|x86.Build.0 = Debug|Win32 {5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}.Release|x64.ActiveCfg = Release|x64 {5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}.Release|x64.Build.0 = Release|x64 {5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}.Release|x86.ActiveCfg = Release|Win32 {5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}.Release|x86.Build.0 = Release|Win32 {721FBD47-E458-4C35-90DA-FF192907D5E2}.Debug|x64.ActiveCfg = Debug|x64 {721FBD47-E458-4C35-90DA-FF192907D5E2}.Debug|x64.Build.0 = Debug|x64 {721FBD47-E458-4C35-90DA-FF192907D5E2}.Debug|x86.ActiveCfg = Debug|Win32 {721FBD47-E458-4C35-90DA-FF192907D5E2}.Debug|x86.Build.0 = Debug|Win32 {721FBD47-E458-4C35-90DA-FF192907D5E2}.Release|x64.ActiveCfg = Release|x64 {721FBD47-E458-4C35-90DA-FF192907D5E2}.Release|x64.Build.0 = Release|x64 {721FBD47-E458-4C35-90DA-FF192907D5E2}.Release|x86.ActiveCfg = Release|Win32 {721FBD47-E458-4C35-90DA-FF192907D5E2}.Release|x86.Build.0 = Release|Win32 {ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}.Debug|x64.ActiveCfg = Debug|x64 {ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}.Debug|x64.Build.0 = Debug|x64 {ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}.Debug|x86.ActiveCfg = Debug|Win32 {ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}.Debug|x86.Build.0 = Debug|Win32 {ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}.Release|x64.ActiveCfg = Release|x64 {ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}.Release|x64.Build.0 = Release|x64 {ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}.Release|x86.ActiveCfg = Release|Win32 {ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}.Release|x86.Build.0 = Release|Win32 {BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}.Debug|x64.ActiveCfg = Debug|x64 {BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}.Debug|x64.Build.0 = Debug|x64 {BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}.Debug|x86.ActiveCfg = Debug|Win32 {BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}.Debug|x86.Build.0 = Debug|Win32 {BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}.Release|x64.ActiveCfg = Release|x64 {BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}.Release|x64.Build.0 = Release|x64 {BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}.Release|x86.ActiveCfg = Release|Win32 {BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}.Release|x86.Build.0 = Release|Win32 {69437707-2FEF-4E2C-8C3F-6E6B3D241366}.Debug|x64.ActiveCfg = Debug|x64 {69437707-2FEF-4E2C-8C3F-6E6B3D241366}.Debug|x64.Build.0 = Debug|x64 {69437707-2FEF-4E2C-8C3F-6E6B3D241366}.Debug|x86.ActiveCfg = Debug|Win32 {69437707-2FEF-4E2C-8C3F-6E6B3D241366}.Debug|x86.Build.0 = Debug|Win32 {69437707-2FEF-4E2C-8C3F-6E6B3D241366}.Release|x64.ActiveCfg = Release|x64 {69437707-2FEF-4E2C-8C3F-6E6B3D241366}.Release|x64.Build.0 = Release|x64 {69437707-2FEF-4E2C-8C3F-6E6B3D241366}.Release|x86.ActiveCfg = Release|Win32 {69437707-2FEF-4E2C-8C3F-6E6B3D241366}.Release|x86.Build.0 = Release|Win32 {E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}.Debug|x64.ActiveCfg = Debug|x64 {E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}.Debug|x64.Build.0 = Debug|x64 {E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}.Debug|x86.ActiveCfg = Debug|Win32 {E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}.Debug|x86.Build.0 = Debug|Win32 {E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}.Release|x64.ActiveCfg = Release|x64 {E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}.Release|x64.Build.0 = Release|x64 {E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}.Release|x86.ActiveCfg = Release|Win32 {E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}.Release|x86.Build.0 = Release|Win32 {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Debug|x64.ActiveCfg = Debug|x64 {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Debug|x64.Build.0 = Debug|x64 {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Debug|x86.ActiveCfg = Debug|Win32 {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Debug|x86.Build.0 = Debug|Win32 {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Release|x64.ActiveCfg = Release|x64 {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Release|x64.Build.0 = Release|x64 {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Release|x86.ActiveCfg = Release|Win32 {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Release|x86.Build.0 = Release|Win32 {94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}.Debug|x64.ActiveCfg = Debug|x64 {94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}.Debug|x64.Build.0 = Debug|x64 {94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}.Debug|x86.ActiveCfg = Debug|Win32 {94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}.Debug|x86.Build.0 = Debug|Win32 {94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}.Release|x64.ActiveCfg = Release|x64 {94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}.Release|x64.Build.0 = Release|x64 {94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}.Release|x86.ActiveCfg = Release|Win32 {94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}.Release|x86.Build.0 = Release|Win32 {8C95060E-61F5-464E-BB42-95B788C0D7E4}.Debug|x64.ActiveCfg = Debug|x64 {8C95060E-61F5-464E-BB42-95B788C0D7E4}.Debug|x64.Build.0 = Debug|x64 {8C95060E-61F5-464E-BB42-95B788C0D7E4}.Debug|x86.ActiveCfg = Debug|Win32 {8C95060E-61F5-464E-BB42-95B788C0D7E4}.Debug|x86.Build.0 = Debug|Win32 {8C95060E-61F5-464E-BB42-95B788C0D7E4}.Release|x64.ActiveCfg = Release|x64 {8C95060E-61F5-464E-BB42-95B788C0D7E4}.Release|x64.Build.0 = Release|x64 {8C95060E-61F5-464E-BB42-95B788C0D7E4}.Release|x86.ActiveCfg = Release|Win32 {8C95060E-61F5-464E-BB42-95B788C0D7E4}.Release|x86.Build.0 = Release|Win32 {25F534DF-93C9-4853-A88E-DB7D8CF74042}.Debug|x64.ActiveCfg = Debug|Win32 {25F534DF-93C9-4853-A88E-DB7D8CF74042}.Debug|x86.ActiveCfg = Debug|Win32 {25F534DF-93C9-4853-A88E-DB7D8CF74042}.Debug|x86.Build.0 = Debug|Win32 {25F534DF-93C9-4853-A88E-DB7D8CF74042}.Release|x64.ActiveCfg = Release|Win32 {25F534DF-93C9-4853-A88E-DB7D8CF74042}.Release|x86.ActiveCfg = Release|Win32 {25F534DF-93C9-4853-A88E-DB7D8CF74042}.Release|x86.Build.0 = Release|Win32 {63166CEB-02CC-472C-B3B7-E6C559939BDA}.Debug|x64.ActiveCfg = Debug|x64 {63166CEB-02CC-472C-B3B7-E6C559939BDA}.Debug|x64.Build.0 = Debug|x64 {63166CEB-02CC-472C-B3B7-E6C559939BDA}.Debug|x86.ActiveCfg = Debug|Win32 {63166CEB-02CC-472C-B3B7-E6C559939BDA}.Debug|x86.Build.0 = Debug|Win32 {63166CEB-02CC-472C-B3B7-E6C559939BDA}.Release|x64.ActiveCfg = Release|x64 {63166CEB-02CC-472C-B3B7-E6C559939BDA}.Release|x64.Build.0 = Release|x64 {63166CEB-02CC-472C-B3B7-E6C559939BDA}.Release|x86.ActiveCfg = Release|Win32 {63166CEB-02CC-472C-B3B7-E6C559939BDA}.Release|x86.Build.0 = Release|Win32 {92580BF4-F4DA-4024-B3F8-444F982BC72F}.Debug|x64.ActiveCfg = Debug|x64 {92580BF4-F4DA-4024-B3F8-444F982BC72F}.Debug|x64.Build.0 = Debug|x64 {92580BF4-F4DA-4024-B3F8-444F982BC72F}.Debug|x86.ActiveCfg = Debug|Win32 {92580BF4-F4DA-4024-B3F8-444F982BC72F}.Debug|x86.Build.0 = Debug|Win32 {92580BF4-F4DA-4024-B3F8-444F982BC72F}.Release|x64.ActiveCfg = Release|x64 {92580BF4-F4DA-4024-B3F8-444F982BC72F}.Release|x64.Build.0 = Release|x64 {92580BF4-F4DA-4024-B3F8-444F982BC72F}.Release|x86.ActiveCfg = Release|Win32 {92580BF4-F4DA-4024-B3F8-444F982BC72F}.Release|x86.Build.0 = Release|Win32 {FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}.Debug|x64.ActiveCfg = Debug|x64 {FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}.Debug|x64.Build.0 = Debug|x64 {FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}.Debug|x86.ActiveCfg = Debug|Win32 {FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}.Debug|x86.Build.0 = Debug|Win32 {FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}.Release|x64.ActiveCfg = Release|x64 {FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}.Release|x64.Build.0 = Release|x64 {FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}.Release|x86.ActiveCfg = Release|Win32 {FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}.Release|x86.Build.0 = Release|Win32 {40A90302-F173-4629-A003-F571D2D93D16}.Debug|x64.ActiveCfg = Debug|x64 {40A90302-F173-4629-A003-F571D2D93D16}.Debug|x64.Build.0 = Debug|x64 {40A90302-F173-4629-A003-F571D2D93D16}.Debug|x86.ActiveCfg = Debug|Win32 {40A90302-F173-4629-A003-F571D2D93D16}.Debug|x86.Build.0 = Debug|Win32 {40A90302-F173-4629-A003-F571D2D93D16}.Release|x64.ActiveCfg = Release|x64 {40A90302-F173-4629-A003-F571D2D93D16}.Release|x64.Build.0 = Release|x64 {40A90302-F173-4629-A003-F571D2D93D16}.Release|x86.ActiveCfg = Release|Win32 {40A90302-F173-4629-A003-F571D2D93D16}.Release|x86.Build.0 = Release|Win32 {247E2681-6C84-408B-B40C-5DB50BC5E18F}.Debug|x64.ActiveCfg = Debug|x64 {247E2681-6C84-408B-B40C-5DB50BC5E18F}.Debug|x64.Build.0 = Debug|x64 {247E2681-6C84-408B-B40C-5DB50BC5E18F}.Debug|x86.ActiveCfg = Debug|Win32 {247E2681-6C84-408B-B40C-5DB50BC5E18F}.Debug|x86.Build.0 = Debug|Win32 {247E2681-6C84-408B-B40C-5DB50BC5E18F}.Release|x64.ActiveCfg = Release|x64 {247E2681-6C84-408B-B40C-5DB50BC5E18F}.Release|x64.Build.0 = Release|x64 {247E2681-6C84-408B-B40C-5DB50BC5E18F}.Release|x86.ActiveCfg = Release|Win32 {247E2681-6C84-408B-B40C-5DB50BC5E18F}.Release|x86.Build.0 = Release|Win32 {7664D0D2-0263-4BFB-AE19-9A1CAD231440}.Debug|x64.ActiveCfg = Debug|x64 {7664D0D2-0263-4BFB-AE19-9A1CAD231440}.Debug|x64.Build.0 = Debug|x64 {7664D0D2-0263-4BFB-AE19-9A1CAD231440}.Debug|x86.ActiveCfg = Debug|Win32 {7664D0D2-0263-4BFB-AE19-9A1CAD231440}.Debug|x86.Build.0 = Debug|Win32 {7664D0D2-0263-4BFB-AE19-9A1CAD231440}.Release|x64.ActiveCfg = Release|x64 {7664D0D2-0263-4BFB-AE19-9A1CAD231440}.Release|x64.Build.0 = Release|x64 {7664D0D2-0263-4BFB-AE19-9A1CAD231440}.Release|x86.ActiveCfg = Release|Win32 {7664D0D2-0263-4BFB-AE19-9A1CAD231440}.Release|x86.Build.0 = Release|Win32 {683745AD-3BC2-4B89-898B-93490D7F2757}.Debug|x64.ActiveCfg = Debug|x64 {683745AD-3BC2-4B89-898B-93490D7F2757}.Debug|x64.Build.0 = Debug|x64 {683745AD-3BC2-4B89-898B-93490D7F2757}.Debug|x86.ActiveCfg = Debug|Win32 {683745AD-3BC2-4B89-898B-93490D7F2757}.Debug|x86.Build.0 = Debug|Win32 {683745AD-3BC2-4B89-898B-93490D7F2757}.Release|x64.ActiveCfg = Release|x64 {683745AD-3BC2-4B89-898B-93490D7F2757}.Release|x64.Build.0 = Release|x64 {683745AD-3BC2-4B89-898B-93490D7F2757}.Release|x86.ActiveCfg = Release|Win32 {683745AD-3BC2-4B89-898B-93490D7F2757}.Release|x86.Build.0 = Release|Win32 {8945255B-473B-4C47-9425-E92384338CAA}.Debug|x64.ActiveCfg = Debug|x64 {8945255B-473B-4C47-9425-E92384338CAA}.Debug|x64.Build.0 = Debug|x64 {8945255B-473B-4C47-9425-E92384338CAA}.Debug|x86.ActiveCfg = Debug|Win32 {8945255B-473B-4C47-9425-E92384338CAA}.Debug|x86.Build.0 = Debug|Win32 {8945255B-473B-4C47-9425-E92384338CAA}.Release|x64.ActiveCfg = Release|x64 {8945255B-473B-4C47-9425-E92384338CAA}.Release|x64.Build.0 = Release|x64 {8945255B-473B-4C47-9425-E92384338CAA}.Release|x86.ActiveCfg = Release|Win32 {8945255B-473B-4C47-9425-E92384338CAA}.Release|x86.Build.0 = Release|Win32 {B500B731-ED1A-4761-94ED-B22DFE25FF2B}.Debug|x64.ActiveCfg = Debug|x64 {B500B731-ED1A-4761-94ED-B22DFE25FF2B}.Debug|x64.Build.0 = Debug|x64 {B500B731-ED1A-4761-94ED-B22DFE25FF2B}.Debug|x86.ActiveCfg = Debug|Win32 {B500B731-ED1A-4761-94ED-B22DFE25FF2B}.Debug|x86.Build.0 = Debug|Win32 {B500B731-ED1A-4761-94ED-B22DFE25FF2B}.Release|x64.ActiveCfg = Release|x64 {B500B731-ED1A-4761-94ED-B22DFE25FF2B}.Release|x64.Build.0 = Release|x64 {B500B731-ED1A-4761-94ED-B22DFE25FF2B}.Release|x86.ActiveCfg = Release|Win32 {B500B731-ED1A-4761-94ED-B22DFE25FF2B}.Release|x86.Build.0 = Release|Win32 {115886F0-7DFB-4B8B-BE79-83162EE8713B}.Debug|x64.ActiveCfg = Debug|x64 {115886F0-7DFB-4B8B-BE79-83162EE8713B}.Debug|x64.Build.0 = Debug|x64 {115886F0-7DFB-4B8B-BE79-83162EE8713B}.Debug|x86.ActiveCfg = Debug|Win32 {115886F0-7DFB-4B8B-BE79-83162EE8713B}.Debug|x86.Build.0 = Debug|Win32 {115886F0-7DFB-4B8B-BE79-83162EE8713B}.Release|x64.ActiveCfg = Release|x64 {115886F0-7DFB-4B8B-BE79-83162EE8713B}.Release|x64.Build.0 = Release|x64 {115886F0-7DFB-4B8B-BE79-83162EE8713B}.Release|x86.ActiveCfg = Release|Win32 {115886F0-7DFB-4B8B-BE79-83162EE8713B}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DB7CDCAF-F002-40F8-9E0E-F25F68EEC77B} SolutionGuid = {60B84F6E-86EE-46F7-9AF4-8A3ABB09A513} EndGlobalSection EndGlobal PK! Xlegacy/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # 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 PK!"blegacy/legacy.slnnu[Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "legacy", "legacy.vcxproj", "{57F56795-1802-4605-88A0-013AAE9998F6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {57F56795-1802-4605-88A0-013AAE9998F6}.Debug|x64.Build.0 = Debug|x64 {57F56795-1802-4605-88A0-013AAE9998F6}.Release|Win32.ActiveCfg = Release|Win32 {57F56795-1802-4605-88A0-013AAE9998F6}.Release|Win32.Build.0 = Release|Win32 {57F56795-1802-4605-88A0-013AAE9998F6}.Release|x64.ActiveCfg = Release|x64 {57F56795-1802-4605-88A0-013AAE9998F6}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK!. %%legacy/legacy.vcxproj.filtersnu[ {28feb3e5-286e-4bae-8a94-1831f7734250} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {82030ac6-467e-4020-a013-5b05ba72e3c8} h;hpp;hxx;hm;inl {f2650fcf-69b6-4d3c-b3ff-8eb4b63775c9} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files Source Files Source Files PK!Qh legacy/oldcol.cppnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * Copyright (C) 2001-2005, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* * file name: oldcol.cpp * encoding: UTF-8 * tab size: 8 (not used) * indentation:4 * * created on: 2001jul24 * created by: Vladimir Weinstein */ /****************************************************************************** * This is the module that uses old collation ******************************************************************************/ #include #include #include #include // 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 #include #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 Debug Win32 Debug x64 Release Win32 Release x64 {57F56795-1802-4605-88A0-013AAE9998F6} 8.1 Application false MultiByte v141 Application false MultiByte v141 Application false MultiByte v141 Application false MultiByte v141 <_ProjectFileVersion>10.0.30319.1 .\x86\Release\ .\x86\Release\ false .\x64\Release\ .\x64\Release\ false .\x86\Debug\ .\x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true .\x86\Release/legacy.tlb OnlyExplicitInline ../../../include;%(AdditionalIncludeDirectories) WINVER=0x0601;_WIN32_WINNT=0x0601;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true MultiThreaded true true .\x86\Release/legacy.pch .\x86\Release/ .\x86\Release/ .\x86\Release/ Level3 true Default NDEBUG;%(PreprocessorDefinitions) 0x0409 icuuc.lib;icuin.lib;../../../../icu-1-8-1/lib/icuuc.lib;../../../../icu-1-8-1/lib/icuin.lib;%(AdditionalDependencies) .\x86\Release/legacy.exe true ../../../lib;%(AdditionalLibraryDirectories) .\x86\Release/legacy.pdb Console false X64 .\x64\Release/legacy.tlb OnlyExplicitInline ../../../include;%(AdditionalIncludeDirectories) WINVER=0x0601;_WIN32_WINNT=0x0601;WIN64;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true MultiThreaded true true .\x64\Release/legacy.pch .\x64\Release/ .\x64\Release/ .\x64\Release/ Level3 true Default NDEBUG;%(PreprocessorDefinitions) 0x0409 icuuc.lib;icuin.lib;../../../../icu-1-8-1/lib/icuuc.lib;../../../../icu-1-8-1/lib/icuin.lib;%(AdditionalDependencies) .\x64\Release/legacy.exe true ../../../lib64;%(AdditionalLibraryDirectories) .\x64\Release/legacy.pdb Console false MachineX64 .\x86\Debug/legacy.tlb Disabled ../../../include;%(AdditionalIncludeDirectories) WINVER=0x0601;_WIN32_WINNT=0x0601;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug true .\x86\Debug/legacy.pch .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ Level3 true EditAndContinue Default _DEBUG;%(PreprocessorDefinitions) 0x0409 icuucd.lib;icuind.lib;../../../../icu-1-8-1/lib/icuucd.lib;../../../../icu-1-8-1/lib/icuind.lib;%(AdditionalDependencies) .\x86\Debug/legacy.exe true ../../../lib;%(AdditionalLibraryDirectories) true .\x86\Debug/legacy.pdb Console false X64 .\x64\Debug/legacy.tlb Disabled ../../../include;%(AdditionalIncludeDirectories) WINVER=0x0601;_WIN32_WINNT=0x0601;WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug true .\x64\Debug/legacy.pch .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ Level3 true ProgramDatabase Default _DEBUG;%(PreprocessorDefinitions) 0x0409 icuucd.lib;icuind.lib;../../../../icu-1-8-1/lib/icuucd.lib;../../../../icu-1-8-1/lib/icuind.lib;%(AdditionalDependencies) .\x64\Debug/legacy.exe true ../../../lib64;%(AdditionalLibraryDirectories) true .\x64\Debug/legacy.pdb Console false MachineX64 ../../../include;../../../../icu-1-8-1/include ../../../include;../../../../icu-1-8-1/include ../../../include;../../../../icu-1-8-1/include ../../../include;../../../../icu-1-8-1/include PK! legacy/READMEnu[Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License 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. PK!lMl% % legacy/legacy.cppnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * Copyright (C) 2001 - 2005, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* * file name: main.cpp * encoding: UTF-8 * 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 #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 #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(istart=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(istart, 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(ilength=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 || posindex/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=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->startlimit; } 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->startlimit) { 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->startlimit) { 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->limitstart=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=(int32_t)strlen(s); } iter->length= iter->limit<=1 ? iter->limit : -1; } else { /* set no-op iterator */ uiter_setString(iter, NULL, 0); } } } PK!AAuciter8/uciter8.vcxproj.filtersnu[ {539093c3-5b8d-4243-9153-abe14e9601b8} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {a04b6e49-ecbb-408f-a73c-9797cf0d45ae} h;hpp;hxx;hm;inl {b1a5a5b9-75a4-4bd6-8283-9eba59b3489d} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files Source Files Header Files PK!;0uciter8/uciter8.slnnu[Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uciter8", "uciter8.vcxproj", "{94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}.Debug|x64.Build.0 = Debug|x64 {94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}.Release|Win32.ActiveCfg = Release|Win32 {94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}.Release|Win32.Build.0 = Release|Win32 {94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}.Release|x64.ActiveCfg = Release|x64 {94379DD9-E6CC-47AC-8E62-0A4ABD8EB121}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK!~*L+L+uciter8/uciter8.cnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * Copyright (C) 2003-2014, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* * file name: uciter8.c * encoding: UTF-8 * 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 #include #include "unicode/utypes.h" #include "unicode/uiter.h" #include "uit_len8.h" #ifndef UPRV_LENGTHOF #define UPRV_LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) #endif #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= */ 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=UPRV_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; } PK!e e uciter8/readme.txtnu[Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License 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 /source runConfigureICU --prefix [other options] gmake all 2. Install ICU, gmake install 3. Compile cd /source/samples/uciter8 gmake ICU_PREFIX=/source/samples/uciter8 gmake ICU_PREFIX= check -or- export LD_LIBRARY_PATH=/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. PK!> % %uciter8/uciter8.vcxprojnu[ {94379DD9-E6CC-47AC-8E62-0A4ABD8EB121} Application false MultiByte <_ProjectFileVersion>10.0.30319.1 .\x86\Debug\ .\x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true .\x86\Release\ .\x86\Release\ false .\x64\Release\ .\x64\Release\ false ..\..\..\include;%(AdditionalIncludeDirectories) Level3 .\x86\Debug/uciter8.tlb MultiThreadedDebugDLL .\x86\Debug/uciter8.pch .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ EditAndContinue Default icuucd.lib;%(AdditionalDependencies) .\x86\Debug/uciter8.exe ..\..\..\lib;%(AdditionalLibraryDirectories) true .\x86\Debug/uciter8.pdb Console false .\x64\Debug/uciter8.tlb MultiThreadedDebugDLL .\x64\Debug/uciter8.pch .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ ProgramDatabase Default icuucd.lib;%(AdditionalDependencies) .\x64\Debug/uciter8.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) true .\x64\Debug/uciter8.pdb Console false .\x86\Release/uciter8.tlb OnlyExplicitInline MultiThreadedDLL true .\x86\Release/uciter8.pch .\x86\Release/ .\x86\Release/ .\x86\Release/ Default icuuc.lib;%(AdditionalDependencies) .\x86\Release/uciter8.exe ..\..\..\lib;%(AdditionalLibraryDirectories) .\x86\Release/uciter8.pdb Console false .\x64\Release/uciter8.tlb OnlyExplicitInline MultiThreadedDLL true .\x64\Release/uciter8.pch .\x64\Release/ .\x64\Release/ .\x64\Release/ Default icuuc.lib;%(AdditionalDependencies) .\x64\Release/uciter8.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) .\x64\Release/uciter8.pdb Console false PK!cbreak/break.slnnu[Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "break", "break.vcxproj", "{DEEADF02-9C14-4854-A395-E505D2904D65}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {DEEADF02-9C14-4854-A395-E505D2904D65}.Debug|x64.Build.0 = Debug|x64 {DEEADF02-9C14-4854-A395-E505D2904D65}.Release|Win32.ActiveCfg = Release|Win32 {DEEADF02-9C14-4854-A395-E505D2904D65}.Release|Win32.Build.0 = Release|Win32 {DEEADF02-9C14-4854-A395-E505D2904D65}.Release|x64.ActiveCfg = Release|x64 {DEEADF02-9C14-4854-A395-E505D2904D65}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK!#mJssbreak/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # 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 PK!{~~break/break.cppnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * Copyright (C) 2002-2003, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* */ #include #include #include using namespace icu; 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(); } PK!eѷbreak/ubreak.cnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * Copyright (C) 2002, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* */ #include #include #include #include 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; } PK!break/break.vcxproj.filtersnu[ {3cfd1084-1652-4648-bb97-9b38a2780005} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {34cb1edc-aa5a-4702-b867-a867ebe8496c} h;hpp;hxx;hm;inl {6aea4120-7995-4705-b3b7-7013af485c18} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files Source Files PK!break/readme.txtnu[Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License Copyright (c) 2002-2010, 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 (Warning: Be careful, 'break' is also a system command on many systems) .\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 /source runConfigureICU --prefix [other options] gmake all 2. Install ICU, gmake install 3. Compile cd /source/samples/break gmake ICU_PREFIX=/source/samples/break gmake ICU_PREFIX= check -or- export LD_LIBRARY_PATH=/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. PK! _2A%A%break/break.vcxprojnu[ {DEEADF02-9C14-4854-A395-E505D2904D65} Application false MultiByte <_ProjectFileVersion>10.0.30319.1 .\x86\Release\ .\x86\Release\ false .\x64\Release\ .\x64\Release\ false .\x86\Debug\ .\x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true ..\..\..\include;%(AdditionalIncludeDirectories) Level3 .\x86\Release/break.tlb OnlyExplicitInline MultiThreaded true .\x86\Release/break.pch .\x86\Release/ .\x86\Release/ .\x86\Release/ Default icuuc.lib;icuin.lib;%(AdditionalDependencies) .\x86\Release/break.exe ..\..\..\lib;%(AdditionalLibraryDirectories) .\x86\Release/break.pdb Console false .\x64\Release/break.tlb OnlyExplicitInline MultiThreaded true .\x64\Release/break.pch .\x64\Release/ .\x64\Release/ .\x64\Release/ Default icuuc.lib;icuin.lib;%(AdditionalDependencies) .\x64\Release/break.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) .\x64\Release/break.pdb Console false .\x86\Debug/break.tlb EnableFastChecks MultiThreadedDebug .\x86\Debug/break.pch .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ EditAndContinue Default icuucd.lib;icuind.lib;%(AdditionalDependencies) .\x86\Debug/break.exe ..\..\..\lib;%(AdditionalLibraryDirectories) true .\x86\Debug/break.pdb Console false .\x64\Debug/break.tlb EnableFastChecks MultiThreadedDebug .\x64\Debug/break.pch .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ ProgramDatabase Default icuucd.lib;icuind.lib;%(AdditionalDependencies) .\x64\Debug/break.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) true .\x64\Debug/break.pdb Console false PK!I_jjcsdet/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # 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 PK!:T~ csdet/csdet.vcxprojnu[ {683745AD-3BC2-4B89-898B-93490D7F2757} Win32Proj Application false MultiByte <_ProjectFileVersion>10.0.30319.1 x86\Debug\ x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true x86\Release\ x86\Release\ false .\x64\Release\ .\x64\Release\ false ../../../include;%(AdditionalIncludeDirectories) true EnableFastChecks MultiThreadedDebug Level3 EditAndContinue icuucd.lib;icuind.lib;%(AdditionalDependencies) $(OutDir)csdet.exe ../../../lib;%(AdditionalLibraryDirectories) true $(OutDir)csdet.pdb Console false X64 Disabled ../../../include;%(AdditionalIncludeDirectories) true EnableFastChecks MultiThreadedDebug Level3 ProgramDatabase icuucd.lib;icuind.lib;%(AdditionalDependencies) $(OutDir)csdet.exe ../../../lib64;%(AdditionalLibraryDirectories) true $(OutDir)csdet.pdb Console false ../../../include;%(AdditionalIncludeDirectories) MultiThreaded Level3 ProgramDatabase icuuc.lib;icuin.lib;%(AdditionalDependencies) $(OutDir)csdet.exe ../../../lib;%(AdditionalLibraryDirectories) true Console true false ../../../include;%(AdditionalIncludeDirectories) MultiThreaded Level3 ProgramDatabase icuuc.lib;icuin.lib;%(AdditionalDependencies) $(OutDir)csdet.exe ../../../lib64;%(AdditionalLibraryDirectories) true Console true false PK!0ጂcsdet/csdet.vcxproj.filtersnu[ {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx Source Files PK!.><`` csdet/csdet.cnu[/* ******************************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ******************************************************************************** ******************************************************************************** * Copyright (C) 2005-2006, International Business Machines * Corporation and others. All Rights Reserved. ******************************************************************************* */ #include "unicode/utypes.h" #include "unicode/ucsdet.h" #include #include #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; } PK!C)csdet/readme.txtnu[Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License Copyright (c) 2001-2010 International Business Machines Corporation and others. All Rights Reserved. uresb: Resource Bundle This sample demonstrates Using ICU's CharSet Detection API Files: csdet.c Main source file *.txt Various sample .txt files 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) csdet eucJP.txt WARNING: The .txt files must be in the same directory as the executable, which is not the case by default on some systems. 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 /source runConfigureICU --prefix [other options] gmake all 2. Install ICU, gmake install 3. Compile cd /source/samples/uresb gmake ICU_PREFIX= To Run on Unixes cd /source/samples/uresb gmake ICU_PREFIX= check -or- export LD_LIBRARY_PATH=/lib:.:$LD_LIBRARY_PATH csdet eucJP.txt 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. PK!<ڗ date/Makefilenu[## Copyright (C) 2016 and later: Unicode, Inc. and others. ## License & terms of use: http://www.unicode.org/copyright.html#License ## ## Makefile.in for ICU - samples/date ## Copyright (c) 1999-2012, International Business Machines Corporation and ## others. All Rights Reserved. ## Source directory information 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_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) $(ICUDATE_OPTS) Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status $(TARGET) : $(OBJECTS) $(LINK.cc) $(OUTOPT)$@ $^ $(LIBS) $(POST_BUILD_STEP) ifeq (,$(MAKECMDGOALS)) -include $(DEPS) else ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),) -include $(DEPS) endif endif PK!`֌-'' date/date.cnu[/* ************************************************************************* * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ************************************************************************* *********************************************************************** * Copyright (C) 1998-2012, 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. * 08/11/11 srl added Parse and milli/second in/out ******************************************************************************* */ #include #include #include #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 || UCONFIG_NO_CONVERSION int main(int argc, char **argv) { printf("%s: Sorry, UCONFIG_NO_FORMATTING or UCONFIG_NO_CONVERSION 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(UDate when, const UChar *tz, UDateFormatStyle style, const char *format, const char *locale, UErrorCode *status); static UDate getWhen(const char *millis, const char *seconds, const char *format, const char *locale, UDateFormatStyle style, const char *parse, const UChar *tz, UErrorCode *status); UConverter *cnv = NULL; /* The version of date */ #define DATE_VERSION "1.0" /* "GMT" */ static const UChar GMT_ID [] = { 0x0047, 0x004d, 0x0054, 0x0000 }; #define FORMAT_MILLIS "%" #define FORMAT_SECONDS "%%" 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; const char *format = NULL; const char *locale = NULL; char *parse = NULL; char *seconds = NULL; char *millis = NULL; UDate when; /* 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]; } } else if(strcmp(arg, "-r") == 0) { if ( optInd + 1 < argc ) { optInd++; seconds = argv[optInd]; } } else if(strcmp(arg, "-R") == 0) { if ( optInd + 1 < argc ) { optInd++; millis = argv[optInd]; } } else if(strcmp(arg, "-P") == 0) { if ( optInd + 1 < argc ) { optInd++; parse = argv[optInd]; } } else if (strcmp(arg, "-L") == 0) { if (optInd + 1 < argc) { optInd++; locale = 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; } /* get the 'when' (or now) */ when = getWhen(millis, seconds, format, locale, style, parse, tz, &status); if(parse != NULL) { format = FORMAT_MILLIS; /* output in millis */ } /* print the date */ date(when, tz, style, format, locale, &status); ucnv_close(cnv); 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."); puts(" -F , --format Use as the display format."); puts(" (Special formats: \"%\" alone is Millis since 1970, \"%%\" alone is Seconds since 1970)"); puts(" -r Use as the time (Epoch 1970) rather than now."); puts(" -R Use as the time (Epoch 1970) rather than now."); puts(" -P Parse as the time, output in millis format."); puts(" -L Use the locale instead of the default ICU locale."); } /* Version information */ static void version() { UErrorCode status = U_ZERO_ERROR; const char *tzVer; int len = 256; UChar tzName[256]; printf("icudate version %s, created by Stephen F. Booth.\n", DATE_VERSION); puts(U_COPYRIGHT_STRING); tzVer = ucal_getTZDataVersion(&status); if(U_FAILURE(status)) { tzVer = u_errorName(status); } printf("\n"); printf("ICU Version: %s\n", U_ICU_VERSION); printf("ICU Data (major+min): %s\n", U_ICUDATA_NAME); printf("Default Locale: %s\n", uloc_getDefault()); printf("Time Zone Data Version: %s\n", tzVer); printf("Default Time Zone: "); status = U_ZERO_ERROR; u_init(&status); len = ucal_getDefaultTimeZone(tzName, len, &status); if(U_FAILURE(status)) { fprintf(stderr, " ** Error getting default zone: %s\n", u_errorName(status)); } uprint(tzName, stdout, &status); printf("\n\n"); } static int32_t charsToUCharsDefault(UChar *uchars, int32_t ucharsSize, const char*chars, int32_t charsSize, UErrorCode *status) { int32_t len=-1; if(U_FAILURE(*status)) return len; if(cnv==NULL) { cnv = ucnv_open(NULL, status); } if(cnv&&U_SUCCESS(*status)) { len = ucnv_toUChars(cnv, uchars, ucharsSize, chars,charsSize, status); } return len; } /* Format the date */ static void date(UDate when, const UChar *tz, UDateFormatStyle style, const char *format, const char *locale, UErrorCode *status ) { UChar *s = 0; int32_t len = 0; UDateFormat *fmt; UChar uFormat[100]; if(U_FAILURE(*status)) return; if( format != NULL ) { if(!strcmp(format,FORMAT_MILLIS)) { printf("%.0f\n", when); return; } else if(!strcmp(format, FORMAT_SECONDS)) { printf("%.3f\n", when/1000.0); return; } } fmt = udat_open(style, style, locale, tz, -1,NULL,0, status); if ( format != NULL ) { charsToUCharsDefault(uFormat,sizeof(uFormat)/sizeof(uFormat[0]),format,-1,status); udat_applyPattern(fmt,FALSE,uFormat,-1); } len = udat_format(fmt, when, 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, when, 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: if(U_FAILURE(*status)) { fprintf(stderr, "Error in Print: %s\n", u_errorName(*status)); } udat_close(fmt); free(s); } static UDate getWhen(const char *millis, const char *seconds, const char *format, const char *locale, UDateFormatStyle style, const char *parse, const UChar *tz, UErrorCode *status) { UDateFormat *fmt = NULL; UChar uFormat[100]; UChar uParse[256]; UDate when=0; int32_t parsepos = 0; if(millis != NULL) { sscanf(millis, "%lf", &when); return when; } else if(seconds != NULL) { sscanf(seconds, "%lf", &when); return when*1000.0; } if(parse!=NULL) { if( format != NULL ) { if(!strcmp(format,FORMAT_MILLIS)) { sscanf(parse, "%lf", &when); return when; } else if(!strcmp(format, FORMAT_SECONDS)) { sscanf(parse, "%lf", &when); return when*1000.0; } } fmt = udat_open(style, style, locale, tz, -1,NULL,0, status); if ( format != NULL ) { charsToUCharsDefault(uFormat,sizeof(uFormat)/sizeof(uFormat[0]), format,-1,status); udat_applyPattern(fmt,FALSE,uFormat,-1); } charsToUCharsDefault(uParse,sizeof(uParse)/sizeof(uParse[0]), parse,-1,status); when = udat_parse(fmt, uParse, -1, &parsepos, status); if(U_FAILURE(*status)) { fprintf(stderr, "Error in Parse: %s\n", u_errorName(*status)); if(parsepos > 0 && parsepos <= (int32_t)strlen(parse)) { fprintf(stderr, "ERR>\"%s\" @%d\n" "ERR> %*s^\n", parse,parsepos,parsepos,""); } } udat_close(fmt); return when; } else { return ucal_getNow(); } } #endif PK!5Y&&date/date.vcxprojnu[ {38B5751A-C6F9-4409-950C-F4F9DA17275F} Application false MultiByte <_ProjectFileVersion>10.0.30319.1 .\x86\Release\ .\x86\Release\ false .\x64\Release\ .\x64\Release\ false .\x86\Debug\ .\x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true .\x86\Release/date.tlb OnlyExplicitInline ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDLL true NotUsing .\x86\Release/ .\x86\Release/ .\x86\Release/ Level3 true Default icuuc.lib;icuin.lib;%(AdditionalDependencies) .\x86\Release/date.exe ../../../lib;%(AdditionalLibraryDirectories) .\x86\Release/date.pdb Console false .\x64\Release/date.tlb OnlyExplicitInline ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDLL true NotUsing .\x64\Release/ .\x64\Release/ .\x64\Release/ Level3 Default icuuc.lib;icuin.lib;%(AdditionalDependencies) .\x64\Release/date.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) .\x64\Release/date.pdb Console false .\x86\Debug/date.tlb Disabled ..\..\..\include;%(AdditionalIncludeDirectories) EnableFastChecks MultiThreadedDebugDLL NotUsing .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ Level3 EditAndContinue Default icuucd.lib;icuind.lib;%(AdditionalDependencies) .\x86\Debug/date.exe ../../../lib;%(AdditionalLibraryDirectories) true .\x86\Debug/date.pdb Console false .\x64\Debug/date.tlb ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL NotUsing .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ Level3 ProgramDatabase Default icuucd.lib;icuind.lib;%(AdditionalDependencies) .\x64\Debug/date.exe ../../../lib64;%(AdditionalLibraryDirectories) true .\x64\Debug/date.pdb Console false PK!?date/Makefile.innu[## Copyright (C) 2016 and later: Unicode, Inc. and others. ## License & terms of use: http://www.unicode.org/copyright.html#License ## ## Makefile.in for ICU - samples/date ## Copyright (c) 1999-2012, 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_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) $(ICUDATE_OPTS) Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status $(TARGET) : $(OBJECTS) $(LINK.cc) $(OUTOPT)$@ $^ $(LIBS) $(POST_BUILD_STEP) ifeq (,$(MAKECMDGOALS)) -include $(DEPS) else ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),) -include $(DEPS) endif endif PK! 22 date/uprint.cnu[/* *********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** ********************************************************************** * 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); } PK!(c date/date.slnnu[Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "date", "date.vcxproj", "{38B5751A-C6F9-4409-950C-F4F9DA17275F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Debug|x64.Build.0 = Debug|x64 {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Release|Win32.ActiveCfg = Release|Win32 {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Release|Win32.Build.0 = Release|Win32 {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Release|x64.ActiveCfg = Release|x64 {38B5751A-C6F9-4409-950C-F4F9DA17275F}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK! u5 5 date/readme.txtnu[Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License Copyright (c) 2002-2010, 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 (Warning: Be careful, 'date' is also a system command on many systems) .\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 /source runConfigureICU --prefix [other options] gmake all 2. Install ICU, gmake install To Run on Unixes cd /source/samples/date gmake check -or- export LD_LIBRARY_PATH=/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. PK!lȸ date/uprint.hnu[/* ******************************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ******************************************************************************** ********************************************************************** * 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 #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 */ PK!DO::date/date.vcxproj.filtersnu[ {5d1a92f4-cd62-4008-981f-9b9ce42ff51d} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {384d6dc3-d172-42ad-b155-2995c3a6821a} h;hpp;hxx;hm;inl {b7a5bc57-56cb-42af-9127-0a3369186ee8} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files Source Files Header Files PK!dduresb/resources.vcxproj.filtersnu[ {6b52e0ef-641f-45e1-b497-f06105317781} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;txt {a4e32c14-ea1d-4778-b403-912d60e3ad79} Resource Files Resource Files Resource Files Build Script PK!wkuresb/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # 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 $(TARGET) $(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 > $@ PK!Βw22uresb/uresb.slnnu[Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "resources", "resources.vcxproj", "{69437707-2FEF-4E2C-8C3F-6E6B3D241366}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uresb", "uresb.vcxproj", "{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 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {69437707-2FEF-4E2C-8C3F-6E6B3D241366}.Debug|x64.Build.0 = Debug|x64 {69437707-2FEF-4E2C-8C3F-6E6B3D241366}.Release|Win32.ActiveCfg = Release|Win32 {69437707-2FEF-4E2C-8C3F-6E6B3D241366}.Release|Win32.Build.0 = Release|Win32 {69437707-2FEF-4E2C-8C3F-6E6B3D241366}.Release|x64.ActiveCfg = Release|x64 {69437707-2FEF-4E2C-8C3F-6E6B3D241366}.Release|x64.Build.0 = Release|x64 {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}.Debug|x64.ActiveCfg = Debug|x64 {92580BF4-F4DA-4024-B3F8-444F982BC72F}.Debug|x64.Build.0 = Debug|x64 {92580BF4-F4DA-4024-B3F8-444F982BC72F}.Release|Win32.ActiveCfg = Release|Win32 {92580BF4-F4DA-4024-B3F8-444F982BC72F}.Release|Win32.Build.0 = Release|Win32 {92580BF4-F4DA-4024-B3F8-444F982BC72F}.Release|x64.ActiveCfg = Release|x64 {92580BF4-F4DA-4024-B3F8-444F982BC72F}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK!SǶ!!uresb/resources.vcxprojnu[ {69437707-2FEF-4E2C-8C3F-6E6B3D241366} MakeFileProj Makefile <_ProjectFileVersion>10.0.30319.1 .\resources_Win32_Debug\ .\resources_Win32_Debug\ nmake /f "resources.mak" CFG=x86\Debug nmake /f "resources.mak" /a CFG=x86\Debug nmake /f "resources.mak" clean CFG=x86\Debug uresb_root.res $(NMakePreprocessorDefinitions) $(NMakeIncludeSearchPath) $(NMakeForcedIncludes) $(NMakeAssemblySearchPath) $(NMakeForcedUsingAssemblies) .\x64\Debug\ .\x64\Debug\ nmake /f "resources.mak" CFG=x64\Debug nmake /f "resources.mak" /a CFG=x64\Debug nmake /f "resources.mak" clean CFG=x64\Debug uresb_root.res $(NMakePreprocessorDefinitions) $(NMakeIncludeSearchPath) $(NMakeForcedIncludes) $(NMakeAssemblySearchPath) $(NMakeForcedUsingAssemblies) .\resources_Win32_Release\ .\resources_Win32_Release\ nmake /f "resources.mak" CFG=x86\Release nmake /f "resources.mak" /a CFG=x86\Release nmake /f "resources.mak" clean CFG=x86\Release uresb_root.res $(NMakePreprocessorDefinitions) $(NMakeIncludeSearchPath) $(NMakeForcedIncludes) $(NMakeAssemblySearchPath) $(NMakeForcedUsingAssemblies) .\x64\Release\ .\x64\Release\ nmake /f "resources.mak" CFG=x64\Release nmake /f "resources.mak" /a CFG=x64\Release nmake /f "resources.mak" clean CFG=x64\Release uresb_root.res $(NMakePreprocessorDefinitions) $(NMakeIncludeSearchPath) $(NMakeForcedIncludes) $(NMakeAssemblySearchPath) $(NMakeForcedUsingAssemblies) PK!E_Dburesb/resources.maknu[## Copyright (C) 2016 and later: Unicode, Inc. and others. ## License & terms of use: http://www.unicode.org/copyright.html#License ## ## Copyright (c) 2001-2009 International Business Machines ## Corporation and others. All Rights Reserved. PACKAGE_NAME = uresb TARGETS = en.res root.res sr.res !IF "$(CFG)" == "x64\Release" || "$(CFG)" == "x64\Debug" GENRB = ..\..\..\bin64\genrb.exe !ELSE GENRB = ..\..\..\bin\genrb.exe !ENDIF 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 $? PK!R uresb/sr.txtnu[// Copyright (C) 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html#License // // 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" } } } PK!e?Yuresb/root.txtnu[// Copyright (C) 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html#License // // 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" } } } PK!c''uresb/uresb.vcxprojnu[ {92580BF4-F4DA-4024-B3F8-444F982BC72F} Application false MultiByte <_ProjectFileVersion>10.0.30319.1 .\x86\Release\ .\x86\Release\ false .\x64\Release\ .\x64\Release\ false .\x86\Debug\ .\x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true ../../../include;../../tools/toolutil;%(AdditionalIncludeDirectories) Level3 .\x86\Release/uresb.tlb OnlyExplicitInline MultiThreadedDLL true .\x86\Release/uresb.pch .\x86\Release/ .\x86\Release/ .\x86\Release/ Default 0x0c1a icuuc.lib;icuio.lib;icutu.lib;%(AdditionalDependencies) .\x86\Release/uresb.exe ../../../lib/;../../tools/toolutil/;%(AdditionalLibraryDirectories) .\x86\Release/uresb.pdb Console false .\x64\Release/uresb.tlb OnlyExplicitInline MultiThreadedDLL true .\x64\Release/uresb.pch .\x64\Release/ .\x64\Release/ .\x64\Release/ Default 0x0c1a icuuc.lib;icuio.lib;icutu.lib;%(AdditionalDependencies) .\x64\Release/uresb.exe true ../../../lib64/;../../tools/toolutil/;%(AdditionalLibraryDirectories) .\x64\Release/uresb.pdb Console false .\x86\Debug/uresb.tlb MultiThreadedDebugDLL .\x86\Debug/uresb.pch .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ EditAndContinue Default 0x0c1a icuucd.lib;icuiod.lib;icutud.lib;%(AdditionalDependencies) .\x86\Debug/uresb.exe ../../../lib/;../../tools/toolutil/;%(AdditionalLibraryDirectories) true .\x86\Debug/uresb.pdb Console false .\x64\Debug/uresb.tlb MultiThreadedDebugDLL .\x64\Debug/uresb.pch .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ ProgramDatabase Default 0x0c1a icuucd.lib;icuiod.lib;icutud.lib;%(AdditionalDependencies) .\x64\Debug/uresb.exe ../../../lib64/;../../tools/toolutil/;%(AdditionalLibraryDirectories) true .\x64\Debug/uresb.pdb Console false {69437707-2fef-4e2c-8c3f-6e6b3d241366} false PK!,p5*5* uresb/uresb.cnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * Copyright (C) 1999-2007, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* * file name: uresb.c * encoding: UTF-8 * 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 #include #ifdef WIN32 #include #else #include #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 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 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; } } PK! uresb/en.txtnu[// Copyright (C) 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html#License // // 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" } } } PK!W  uresb/readme.txtnu[Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License Copyright (c) 2001-2010 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 WARNING: The .txt files must be in the same directory as the executable, which is not the case by default on some systems. 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 /source runConfigureICU --prefix [other options] gmake all 2. Install ICU, gmake install 3. Compile cd /source/samples/uresb gmake ICU_PREFIX= To Run on Unixes cd /source/samples/uresb gmake ICU_PREFIX= check -or- export LD_LIBRARY_PATH=/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. PK!:Wnnuresb/uresb.vcxproj.filtersnu[ {8ee7965d-1f49-4d43-822c-1769f483fb4d} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {360c4d2a-1def-4b5d-854c-d069c425e6bb} h;hpp;hxx;hm;inl {5ff61356-999a-4b96-8195-2cdac0185df9} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files PK!~koo msgfmt/util.hnu[/********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** *********************************************************************** * COPYRIGHT: * Copyright (c) 1999-2002, International Business Machines Corporation and * others. All Rights Reserved. ***********************************************************************/ #include "unicode/unistr.h" using namespace icu; // 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); PK!?MVqqmsgfmt/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # 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 PK!##msgfmt/answers/main_3.cppnu[/********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** *********************************************************************** * 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 #include #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; } PK!hmsgfmt/answers/main_2.cppnu[/********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** *********************************************************************** * 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 #include #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; } PK!`__msgfmt/answers/main_1.cppnu[/********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** *********************************************************************** * COPYRIGHT: * Copyright (c) 1999-2002, International Business Machines Corporation and * others. All Rights Reserved. ***********************************************************************/ #include "unicode/unistr.h" #include "unicode/msgfmt.h" #include #include #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; } PK!msgfmt/answers/main_0.cppnu[/********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** *********************************************************************** * 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 #include #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; } PK!8a&&msgfmt/msgfmt.vcxprojnu[ {5FF1D1A2-1630-446C-B6EA-93EFD4F975C3} Application false MultiByte <_ProjectFileVersion>10.0.30319.1 .\x86\Release\ .\x86\Release\ false .\x64\Release\ .\x64\Release\ false .\x86\Debug\ .\x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true .\x86\Release/msgfmt.tlb OnlyExplicitInline ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDLL true .\x86\Release/msgfmt.pch .\x86\Release/ .\x86\Release/ .\x86\Release/ Level3 true Default icuuc.lib;icuin.lib;%(AdditionalDependencies) .\x86\Release/msgfmt.exe ..\..\..\lib;%(AdditionalLibraryDirectories) .\x86\Release/msgfmt.pdb Console false .\x64\Release/msgfmt.tlb OnlyExplicitInline ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDLL true .\x64\Release/msgfmt.pch .\x64\Release/ .\x64\Release/ .\x64\Release/ Level3 Default icuuc.lib;icuin.lib;%(AdditionalDependencies) .\x64\Release/msgfmt.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) .\x64\Release/msgfmt.pdb Console false .\x86\Debug/msgfmt.tlb ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL .\x86\Debug/msgfmt.pch .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ Level3 true EditAndContinue Default icuucd.lib;icuind.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) .\x86\Debug/msgfmt.exe ..\..\..\lib;%(AdditionalLibraryDirectories) true .\x86\Debug/msgfmt.pdb Console false .\x64\Debug/msgfmt.tlb ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL .\x64\Debug/msgfmt.pch .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ Level3 ProgramDatabase Default icuucd.lib;icuind.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) .\x64\Debug/msgfmt.exe true ..\..\..\lib64;%(AdditionalLibraryDirectories) true .\x64\Debug/msgfmt.pdb Console false PK! argument(s) on .", 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! PK!msgfmt/msgfmt.slnnu[Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "msgfmt", "msgfmt.vcxproj", "{5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}.Debug|x64.Build.0 = Debug|x64 {5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}.Release|Win32.ActiveCfg = Release|Win32 {5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}.Release|Win32.Build.0 = Release|Win32 {5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}.Release|x64.ActiveCfg = Release|x64 {5FF1D1A2-1630-446C-B6EA-93EFD4F975C3}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK!##msgfmt/main.cppnu[/********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** *********************************************************************** * 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 #include #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; } PK!G[dmsgfmt/util.cppnu[/********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** *********************************************************************** * COPYRIGHT: * Copyright (c) 1999-2010, International Business Machines Corporation and * others. All Rights Reserved. ***********************************************************************/ #include "unicode/unistr.h" #include #include using namespace icu; // 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 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; } PK!msgfmt/msgfmt.vcxproj.filtersnu[ {ee7c4dbe-02ac-43f8-89cf-260b2bebecc9} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {b140c5d1-fe3d-4fbc-9931-fd1a6a555dc7} h;hpp;hxx;hm;inl {66a2f758-b543-469a-a2c9-754e37e23a81} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files Source Files PK!aחee numfmt/util.hnu[/******************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ************************************************************************* ************************************************************************* * COPYRIGHT: * Copyright (c) 1999-2002, International Business Machines Corporation and * others. All Rights Reserved. *************************************************************************/ #include "unicode/unistr.h" #include "unicode/fmtable.h" using namespace icu; #ifndef UPRV_LENGTHOF #define UPRV_LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) #endif // 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); PK!wxxnumfmt/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # 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 PK!Y ['['numfmt/numfmt.vcxprojnu[ {721FBD47-E458-4C35-90DA-FF192907D5E2} Application false MultiByte <_ProjectFileVersion>10.0.30319.1 .\x86\Debug\ .\x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true .\x86\Release\ .\x86\Release\ false .\x64\Release\ .\x64\Release\ false .\x86\Debug/numfmt.tlb ../../../include;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL .\x86\Debug/numfmt.pch .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ Level3 EditAndContinue Default icuucd.lib;icuind.lib;%(AdditionalDependencies) .\x86\Debug/numfmt.exe ../../../lib;%(AdditionalLibraryDirectories) true .\x86\Debug/numfmt.pdb Console false X64 .\x64\Debug/numfmt.tlb Disabled ../../../include;%(AdditionalIncludeDirectories) EnableFastChecks MultiThreadedDebugDLL .\x64\Debug/numfmt.pch .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ Level3 ProgramDatabase Default icuucd.lib;icuind.lib;%(AdditionalDependencies) .\x64\Debug/numfmt.exe true ../../../lib64;%(AdditionalLibraryDirectories) true .\x64\Debug/numfmt.pdb Console false .\x86\Release/numfmt.tlb OnlyExplicitInline ../../../include;%(AdditionalIncludeDirectories) MultiThreadedDLL true .\x86\Release/numfmt.pch .\x86\Release/ .\x86\Release/ .\x86\Release/ Level3 Default icuuc.lib;icuin.lib;%(AdditionalDependencies) .\x86\Release/numfmt.exe ../../../lib;%(AdditionalLibraryDirectories) .\x86\Release/numfmt.pdb Console false .\x64\Release/numfmt.tlb OnlyExplicitInline ../../../include;%(AdditionalIncludeDirectories) MultiThreadedDLL true .\x64\Release/numfmt.pch .\x64\Release/ .\x64\Release/ .\x64\Release/ Level3 Default icuuc.lib;icuin.lib;%(AdditionalDependencies) .\x64\Release/numfmt.exe ../../../lib64;%(AdditionalLibraryDirectories) .\x64\Release/numfmt.pdb Console false PK!Xnumfmt/numfmt.vcxproj.filtersnu[ {88ce2f55-7fa8-4f41-8f4b-218bc68250c4} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {d646ea9a-5f23-4c6a-9db6-b028a0f18de5} h;hpp;hxx;hm;inl {1fc0ba57-7696-49f7-a631-29ca4759be0e} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files Source Files Source Files Header Files PK!Anumfmt/numfmt.slnnu[Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "numfmt", "numfmt.vcxproj", "{721FBD47-E458-4C35-90DA-FF192907D5E2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {721FBD47-E458-4C35-90DA-FF192907D5E2}.Debug|x64.Build.0 = Debug|x64 {721FBD47-E458-4C35-90DA-FF192907D5E2}.Release|Win32.ActiveCfg = Release|Win32 {721FBD47-E458-4C35-90DA-FF192907D5E2}.Release|Win32.Build.0 = Release|Win32 {721FBD47-E458-4C35-90DA-FF192907D5E2}.Release|x64.ActiveCfg = Release|x64 {721FBD47-E458-4C35-90DA-FF192907D5E2}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK!iSɱu$u$numfmt/main.cppnu[/******************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ************************************************************************* ************************************************************************* * COPYRIGHT: * Copyright (c) 1999-2014, 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 #include #include 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 DecimalFormat *dnf=dynamic_cast(&nf); if(dnf==NULL) { 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; isetRoundingIncrement(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; iformat(12345678.93, output); output+=(UChar)0x0a; // '\n' uprintf(output); } } } PK!B numfmt/capi.cnu[/******************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ************************************************************************* ************************************************************************* * COPYRIGHT: * Copyright (c) 1999-2002, International Business Machines Corporation and * others. All Rights Reserved. *************************************************************************/ #include "unicode/unum.h" #include "unicode/ustring.h" #include #include 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); } PK!/.Oinumfmt/util.cppnu[/******************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ************************************************************************* ************************************************************************* * COPYRIGHT: * Copyright (c) 1999-2009, International Business Machines Corporation and * others. All Rights Reserved. *************************************************************************/ #define __STDC_FORMAT_MACROS 1 #include #include "unicode/unistr.h" #include "unicode/fmtable.h" #include #include using namespace icu; 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 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: { char buf[256]; sprintf(buf, "%" PRId32 "L", f.getLong()); return UnicodeString(buf, ""); } case Formattable::kInt64: { char buf[256]; sprintf(buf, "%" PRId64 "L", f.getInt64()); 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 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"); } } PK!cGu u numfmt/readme.txtnu[Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License 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 /source runConfigureICU --prefix [other options] gmake all 2. Install ICU, gmake install 3. Compile cd /source/samples/numfmt gmake ICU_PREFIX=/source/samples/numfmt gmake ICU_PREFIX= check -or- export LD_LIBRARY_PATH=/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. PK!ooudata/reader.vcxproj.filtersnu[ {70f91413-5190-4f71-88a6-42eddfb11351} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {e31be275-f3ff-42ca-8017-1ddab3cbd23b} h;hpp;hxx;hm;inl {ce6ba23d-b7db-40f6-8e79-a1d386c0c707} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files PK!Rtudata/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # Copyright (c) 2000-2012 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 $(TARGET1).out $(TARGET2).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) $(CXX) -o $@ $(LDFLAGS) $(TARGET2): $(OBJECTS2) $(CXX) -o $@ $(LDFLAGS) -licui18n -licuuc # Make check: simply runs the sample, logged to a file check: $(TARGET1) $(TARGET2) $(INVOKE) ./$(TARGET2) | tee $(TARGET2).out $(INVOKE) ./$(TARGET1) | tee $(TARGET1).out PK!0'%'%udata/writer.vcxprojnu[ {40A90302-F173-4629-A003-F571D2D93D16} Application false MultiByte .\x86\Debug\ .\x86\Debug\ $(ProjectName) .\x64\Debug\ .\x64\Debug\ $(ProjectName) .\x86\Release\ .\x86\Release\ $(ProjectName) .\x64\Release\ .\x64\Release\ $(ProjectName) .\x86\Debug/writer.tlb ..\..\..\include;..\..\tools\toolutil;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL .\x86\Debug/writer.pch .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ Level3 EditAndContinue Default icutud.lib;%(AdditionalDependencies) .\x86\Debug/writer.exe true ../../../lib;%(AdditionalLibraryDirectories) true .\x86\Debug/writer.pdb Console false .\x64\Debug/writer.tlb Disabled ..\..\..\include;..\..\tools\toolutil;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL .\x64\Debug/writer.pch .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ Level3 ProgramDatabase Default icutud.lib;%(AdditionalDependencies) .\x64\Debug/writer.exe true ../../../lib64;%(AdditionalLibraryDirectories) true .\x64\Debug/writer.pdb Console false .\x86\Release/writer.tlb OnlyExplicitInline ..\..\..\include;..\..\tools\toolutil;%(AdditionalIncludeDirectories) MultiThreadedDLL true .\x86\Release/writer.pch .\x86\Release/ .\x86\Release/ .\x86\Release/ Level3 Default icutu.lib;%(AdditionalDependencies) .\x86\Release/writer.exe ../../../lib;%(AdditionalLibraryDirectories) .\x86\Release/writer.pdb Console false .\x64\Release/writer.tlb OnlyExplicitInline ..\..\..\include;..\..\tools\toolutil;%(AdditionalIncludeDirectories) MultiThreadedDLL true .\x64\Release/writer.pch .\x64\Release/ .\x64\Release/ .\x64\Release/ Level3 Default icutu.lib;%(AdditionalDependencies) .\x64\Release\writer.exe ../../../lib64;%(AdditionalLibraryDirectories) .\x64\Release\writer.pdb Console false PK!mە\ udata/reader.cnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * Copyright (C) 1999-2009, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* * file name: reader.c * encoding: UTF-8 * tab size: 8 (not used) * indentation:4 * * created on: 2000sep5 * created by: Vladimir Weinstein */ /******************************************************************************* * Derived from Madhu Katragadda gentest *******************************************************************************/ #include #include #include #ifdef WIN32 #include #else #include #endif #include "unicode/utypes.h" #include "unicode/putil.h" #include "unicode/udata.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 */ }; 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" as path */ strcpy(curPathBuffer, currdir); 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; } PK!wD'D'udata/reader.vcxprojnu[ {BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28} Application false MultiByte .\x86\Debug\ .\x86\Debug\ $(ProjectName) .\x64\Debug\ .\x64\Debug\ $(ProjectName) .\x86\Release\ .\x86\Release\ $(ProjectName) .\x64\Release\ .\x64\Release\ $(ProjectName) .\reader_Win32_Debug/reader.tlb Disabled ..\..\..\include;..\..\tools\toolutil;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL .\reader_Win32_Debug/reader.pch .\reader_Win32_Debug/ .\reader_Win32_Debug/ .\reader_Win32_Debug/ Level3 EditAndContinue Default icuucd.lib;%(AdditionalDependencies) .\reader_Win32_Debug/reader.exe ../../../lib;%(AdditionalLibraryDirectories) true .\reader_Win32_Debug/reader.pdb Console false .\reader_x64_Debug/reader.tlb ..\..\..\include;..\..\tools\toolutil;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL .\reader_x64_Debug/reader.pch .\reader_x64_Debug/ .\reader_x64_Debug/ .\reader_x64_Debug/ Level3 ProgramDatabase Default icuucd.lib;%(AdditionalDependencies) .\reader_x64_Debug/reader.exe ../../../lib64;%(AdditionalLibraryDirectories) true .\reader_x64_Debug/reader.pdb Console false .\reader_Win32_Release/reader.tlb OnlyExplicitInline ..\..\..\include;..\..\tools\toolutil;%(AdditionalIncludeDirectories) MultiThreadedDLL true .\reader_Win32_Release/reader.pch .\reader_Win32_Release/ .\reader_Win32_Release/ .\reader_Win32_Release/ Level3 Default icuuc.lib;%(AdditionalDependencies) .\reader_Win32_Release/reader.exe ../../../lib;%(AdditionalLibraryDirectories) .\reader_Win32_Release/reader.pdb Console false .\reader_x64_Release/reader.tlb OnlyExplicitInline ..\..\..\include;..\..\tools\toolutil;%(AdditionalIncludeDirectories) MultiThreadedDLL true .\reader_x64_Release/reader.pch .\reader_x64_Release/ .\reader_x64_Release/ .\reader_x64_Release/ Level3 Default icuuc.lib;%(AdditionalDependencies) .\reader_x64_Release/reader.exe true ../../../lib64;%(AdditionalLibraryDirectories) .\reader_x64_Release/reader.pdb Console false ..\..\..\include;..\..\tools\toolutil;..\..\icu\include ..\..\..\include;..\..\tools\toolutil;..\..\icu\include PK!7Zudata/udata.slnnu[Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reader", "reader.vcxproj", "{BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "writer", "writer.vcxproj", "{40A90302-F173-4629-A003-F571D2D93D16}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}.Debug|x64.Build.0 = Debug|x64 {BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}.Release|Win32.ActiveCfg = Release|Win32 {BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}.Release|Win32.Build.0 = Release|Win32 {BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}.Release|x64.ActiveCfg = Release|x64 {BFEFC070-C5A9-42E3-BAAE-A51FB2C4BA28}.Release|x64.Build.0 = Release|x64 {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}.Debug|x64.ActiveCfg = Debug|x64 {40A90302-F173-4629-A003-F571D2D93D16}.Debug|x64.Build.0 = Debug|x64 {40A90302-F173-4629-A003-F571D2D93D16}.Release|Win32.ActiveCfg = Release|Win32 {40A90302-F173-4629-A003-F571D2D93D16}.Release|Win32.Build.0 = Release|Win32 {40A90302-F173-4629-A003-F571D2D93D16}.Release|x64.ActiveCfg = Release|x64 {40A90302-F173-4629-A003-F571D2D93D16}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK!Yooudata/writer.vcxproj.filtersnu[ {95d01528-6508-4b1e-8aae-1c97e5b51225} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {354349b6-2a7e-4803-8654-f1123e58d086} h;hpp;hxx;hm;inl {629cf2c5-7334-4b9c-9592-17e16293f7f0} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files PK!P|g g udata/writer.cnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * Copyright (C) 1999-2006, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* * file name: writer.c * encoding: UTF-8 * 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 #include #ifdef WIN32 #include #else #include #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; size_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 %zu\n", dataLength, size); exit(U_INTERNAL_PROGRAM_ERROR); } return 0; } PK!+: udata/readme.txtnu[Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License Copyright (c) 2002-2010, 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 IMPORTANT: On some systems, the reader and writer executables may not be in the same directory. If this is the case, this will likely cause a problem with reader looking for the .dat file in the wrong directory). 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 /source runConfigureICU --prefix [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 /source/samples/udata gmake ICU_PATH= ICU_PREFIX=/source/samples/udata gmake ICU_PREFIX= check -or- export LD_LIBRARY_PATH=/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. PK! )dtptngsample/dtptngsample.vcxproj.filtersnu[ {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms Source Files PK!#-ff!dtptngsample/dtptngsample.vcxprojnu[ {115886F0-7DFB-4B8B-BE79-83162EE8713B} samples Application true Unicode Application true Unicode Application false true Unicode Application false true Unicode .\x86\Debug\ .\x86\Debug\ $(ProjectName) .\x64\Debug\ .\x64\Debug\ $(ProjectName) .\x86\Release\ .\x86\Release\ $(ProjectName) .\x64\Release\ .\x64\Release\ $(ProjectName) Level3 ..\..\common;..\..\..\include;%(AdditionalIncludeDirectories) true .\x86\debug/dtptngsample.exe icuucd.lib;icuind.lib;icuiod.lib;%(AdditionalDependencies) ..\..\..\lib;%(AdditionalLibraryDirectories) Level3 ..\..\common;..\..\..\include;%(AdditionalIncludeDirectories) .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ true .\x64\debug/dtptngsample.exe icuucd.lib;icuind.lib;icuiod.lib;%(AdditionalDependencies) ..\..\..\lib64;%(AdditionalLibraryDirectories) Level3 MaxSpeed true true ..\..\..\include;..\..\common;%(AdditionalIncludeDirectories) true true icuuc.lib;icuin.lib;icuio.lib;%(AdditionalDependencies) ..\..\..\lib;%(AdditionalLibraryDirectories) Level3 MaxSpeed true true ..\..\..\include;..\..\common;%(AdditionalIncludeDirectories) .\x64\Release/ .\x64\Release/ .\x64\Release/ true true icuuc.lib;icuin.lib;icuio.lib;%(AdditionalDependencies) ..\..\..\lib64;%(AdditionalLibraryDirectories) PK!$dtptngsample/dtptngsample.cppnu[// © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /******************************************************************** * COPYRIGHT: * Copyright (c) 2008-2014, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ //! [getBestPatternExample1] #include #include "unicode/smpdtfmt.h" #include "unicode/dtptngen.h" #include "unicode/ustdio.h" //! [getBestPatternExample1] using namespace std; using namespace icu; static void getBestPatternExample() { u_printf("========================================================================\n"); u_printf(" getBestPatternExample()\n"); u_printf("\n"); u_printf(" Use DateTimePatternGenerator to create customized date/time pattern:\n"); u_printf(" yQQQQ,yMMMM, MMMMd, hhmm, jjmm per locale\n"); u_printf("========================================================================\n"); //! [getBestPatternExample] UnicodeString skeletons [] = { UnicodeString("yQQQQ"), // year + full name of quarter, i.e., 4th quarter 1999 UnicodeString("yMMMM"), // year + full name of month, i.e., October 1999 UnicodeString("MMMMd"), // full name of month + day of the month, i.e., October 25 UnicodeString("hhmm"), // 12-hour-cycle format, i.e., 1:32 PM UnicodeString("jjmm"), // preferred hour format for the given locale, i.e., 24-hour-cycle format for fr_FR 0, }; Locale locales[] = { Locale ("en_US"), Locale ("fr_FR"), Locale ("zh_CN"), }; const char* filename = "sample.txt"; /* open a UTF-8 file for writing */ UFILE* f = u_fopen(filename, "w", NULL,"UTF-8"); UnicodeString dateReturned; UErrorCode status =U_ZERO_ERROR; Calendar *cal = Calendar::createInstance(status); cal->set (1999,9,13,23,58,59); UDate date = cal->getTime(status); u_fprintf(f, "%-20S%-20S%-20S%-20S\n", UnicodeString("Skeleton").getTerminatedBuffer(),UnicodeString("en_US").getTerminatedBuffer(),UnicodeString("fr_FR").getTerminatedBuffer(),UnicodeString("zh_CN").getTerminatedBuffer()); for (int i=0;skeletons[i]!=NULL;i++) { u_fprintf(f, "%-20S",skeletons[i].getTerminatedBuffer()); for (int j=0;jgetBestPattern(skeletons[i],status); // Constructs a SimpleDateFormat with the best pattern generated above and the given locale SimpleDateFormat *sdf = new SimpleDateFormat(pattern,locales[j],status); dateReturned.remove(); // Get the format of the given date sdf->format(date,dateReturned,status); /* write Unicode string to file */ u_fprintf(f, "%-20S", dateReturned.getTerminatedBuffer()); delete dtfg; delete sdf; } u_fprintf(f,"\n"); } /* close the file resource */ u_fclose(f); delete cal; //! [getBestPatternExample] } static void addPatternExample() { u_printf("========================================================================\n"); u_printf(" addPatternExample()\n"); u_printf("\n"); u_printf(" Use addPattern API to add new '. von' to existing pattern\n"); u_printf("========================================================================\n"); //! [addPatternExample] UErrorCode status =U_ZERO_ERROR; UnicodeString conflictingPattern,dateReturned, pattern; Locale locale=Locale::getFrance(); Calendar *cal = Calendar::createInstance(status); cal->set (1999,9,13,23,58,59); UDate date = cal->getTime(status); // Create an DateTimePatternGenerator instance for the given locale DateTimePatternGenerator *dtfg= DateTimePatternGenerator::createInstance(locale,status); SimpleDateFormat *sdf = new SimpleDateFormat(dtfg->getBestPattern("MMMMddHmm",status),locale,status); // Add '. von' to the existing pattern dtfg->addPattern("dd'. von' MMMM", true, conflictingPattern,status); // Apply the new pattern sdf->applyPattern(dtfg->getBestPattern("MMMMddHmm",status)); dateReturned = sdf->format(date, dateReturned, status); pattern =sdf->toPattern(pattern); u_printf("%s\n", "New Pattern for FRENCH: "); u_printf("%S\n", pattern.getTerminatedBuffer()); u_printf("%s\n", "Date Time in new Pattern: "); u_printf("%S\n", dateReturned.getTerminatedBuffer()); delete dtfg; delete sdf; delete cal; //! [addPatternExample] /* output of the sample code: ************************************************************************************************ New Pattern for FRENCH: dd. 'von' MMMM HH:mm Date Time in new Pattern: 13. von octobre 23:58 *************************************************************************************************/ } static void replaceFieldTypesExample() { // Use repalceFieldTypes API to replace zone 'zzzz' with 'vvvv' u_printf("========================================================================\n"); u_printf(" replaceFieldTypeExample()\n"); u_printf("\n"); u_printf(" Use replaceFieldTypes API to replace zone 'zzzz' with 'vvvv'\n"); u_printf("========================================================================\n"); //! [replaceFieldTypesExample] UFILE *out = u_finit(stdout, NULL, "UTF-8"); UErrorCode status =U_ZERO_ERROR; UnicodeString pattern,dateReturned; Locale locale =Locale::getFrance(); Calendar *cal = Calendar::createInstance(status); cal->set (1999,9,13,23,58,59); UDate date = cal->getTime(status); TimeZone *zone = TimeZone::createTimeZone(UnicodeString("Europe/Paris")); DateTimePatternGenerator *dtfg = DateTimePatternGenerator::createInstance(locale,status); SimpleDateFormat *sdf = new SimpleDateFormat("EEEE d MMMM y HH:mm:ss zzzz",locale,status); sdf->setTimeZone(*zone); pattern = sdf->toPattern(pattern); u_fprintf(out, "%S\n", UnicodeString("Pattern before replacement:").getTerminatedBuffer()); u_fprintf(out, "%S\n", pattern.getTerminatedBuffer()); dateReturned.remove(); dateReturned = sdf->format(date, dateReturned, status); u_fprintf(out, "%S\n", UnicodeString("Date/Time format in fr_FR:").getTerminatedBuffer()); u_fprintf(out, "%S\n", dateReturned.getTerminatedBuffer()); // Replace zone "zzzz" in the pattern with "vvvv" UnicodeString newPattern = dtfg->replaceFieldTypes(pattern, "vvvv", status); // Apply the new pattern sdf->applyPattern(newPattern); dateReturned.remove(); dateReturned = sdf->format(date, dateReturned, status); u_fprintf(out, "%S\n", UnicodeString("Pattern after replacement:").getTerminatedBuffer()); u_fprintf(out, "%S\n", newPattern.getTerminatedBuffer()); u_fprintf(out, "%S\n", UnicodeString("Date/Time format in fr_FR:").getTerminatedBuffer()); u_fprintf(out, "%S\n", dateReturned.getTerminatedBuffer()); delete sdf; delete dtfg; delete zone; delete cal; u_fclose(out); //! [replaceFieldTypesExample] } int main (int argc, char* argv[]) { getBestPatternExample(); addPatternExample(); replaceFieldTypesExample(); return 0; } PK!ugrep/ugrep.slnnu[Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ugrep", "ugrep.vcxproj", "{63166CEB-02CC-472C-B3B7-E6C559939BDA}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {63166CEB-02CC-472C-B3B7-E6C559939BDA}.Debug|x64.Build.0 = Debug|x64 {63166CEB-02CC-472C-B3B7-E6C559939BDA}.Release|Win32.ActiveCfg = Release|Win32 {63166CEB-02CC-472C-B3B7-E6C559939BDA}.Release|Win32.Build.0 = Release|Win32 {63166CEB-02CC-472C-B3B7-E6C559939BDA}.Release|x64.ActiveCfg = Release|x64 {63166CEB-02CC-472C-B3B7-E6C559939BDA}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK!ޅugrep/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # Copyright (c) 2000-2010 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 CHECK_ARGS=BOM readme.txt #### rules # Load in standard makefile definitions include ../defs.mk # the actual rules (this is a simple sample) include ../rules.mk PK!@-u(u(ugrep/ugrep.vcxprojnu[ {63166CEB-02CC-472C-B3B7-E6C559939BDA} Application false MultiByte <_ProjectFileVersion>10.0.30319.1 .\x86\Release\ .\x86\Release\ false .\x64\Release\ .\x64\Release\ false .\x86\Debug\ .\x86\Debug\ .\x64\Debug\ .\x64\Debug\ .\x86\Release/ugrep.tlb MaxSpeed AnySuitable ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDLL true .\x86\Release/ugrep.pch .\x86\Release/ .\x86\Release/ .\x86\Release/ Level3 true Default /FIXED:NO %(AdditionalOptions) icuuc.lib;icuin.lib;%(AdditionalDependencies) .\x86\Release/ugrep.exe true ../../../lib;%(AdditionalLibraryDirectories) .\x86\Release/ugrep.pdb Console false .\x64\Release/ugrep.tlb MaxSpeed AnySuitable ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDLL true .\x64\Release/ugrep.pch .\x64\Release/ .\x64\Release/ .\x64\Release/ Level3 true Default /FIXED:NO %(AdditionalOptions) icuuc.lib;icuin.lib;%(AdditionalDependencies) .\x64\Release/ugrep.exe true ../../../lib64;%(AdditionalLibraryDirectories) .\x64\Release/ugrep.pdb Console false .\x86\Debug/ugrep.tlb Disabled ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL .\x86\Debug/ugrep.pch .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ Level3 true EditAndContinue Default icuucd.lib;icuind.lib;%(AdditionalDependencies) .\x86\Debug/ugrep.exe true ../../../lib;%(AdditionalLibraryDirectories) true .\x86\Debug/ugrep.pdb Console false .\x64\Debug/ugrep.tlb Disabled ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL .\x64\Debug/ugrep.pch .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ Level3 ProgramDatabase Default icuucd.lib;icuind.lib;%(AdditionalDependencies) .\x64\Debug/ugrep.exe ../../../lib64;%(AdditionalLibraryDirectories) true .\x64\Debug/ugrep.pdb Console false PK!SQ`ppugrep/ugrep.vcxproj.filtersnu[ {af0effd9-5d29-4822-a68e-133434a44d37} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {95b681c8-65fd-4e97-ba1e-6622b8d29661} h;hpp;hxx;hm;inl {e3f8ffc7-59ba-43ea-b607-7db8fa13080b} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files PK!:;99ugrep/ugrep.cppnu[/************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ************************************************************************** ************************************************************************** * * Copyright (C) 2002-2010, 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 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 #include #include #include "unicode/utypes.h" #include "unicode/ustring.h" #include "unicode/regex.h" #include "unicode/ucnv.h" #include "unicode/uclean.h" using namespace icu; // // The following variables contain parameters 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 command 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); lineStartreset(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 occurred 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 = static_cast(fread(charBuf, 1, rawFileLen, file)); if (t != rawFileLen) { fprintf(stderr, "Error reading file \"%s\"\n", fileName); fclose(file); 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 forward 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); } PK!9 9 ugrep/readme.txtnu[Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License 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 /source runConfigureICU --prefix [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 /bin cd /source/samples/ugrep gmake To Run on Unixes cd /source/samples/ugrep export LD_LIBRARY_PATH=/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. PK!6.rules.mknu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # Copyright (c) 2002-2012 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) -licui18n -licuuc $(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: $(ALL_SUBDIR) $(RESTARGET) $(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) PK![MMustring/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # 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 PK!ʹustring/ustring.slnnu[Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ustring", "ustring.vcxproj", "{FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}.Debug|x64.Build.0 = Debug|x64 {FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}.Release|Win32.ActiveCfg = Release|Win32 {FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}.Release|Win32.Build.0 = Release|Win32 {FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}.Release|x64.ActiveCfg = Release|x64 {FF92E6C1-BACA-41AD-BB6D-ECA19C05573E}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK!ʊYrrustring/ustring.vcxproj.filtersnu[ {db876e6b-bc8f-42c4-87ea-ce2103aa8083} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {b2781636-f094-4ad5-ae54-d1d1cd35789d} h;hpp;hxx;hm;inl {cc4ad0cf-56aa-411d-a9fb-75442955c3a9} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files PK! %%ustring/ustring.vcxprojnu[ {FF92E6C1-BACA-41AD-BB6D-ECA19C05573E} Application false MultiByte <_ProjectFileVersion>10.0.30319.1 .\x86\Release\ .\x86\Release\ false .\x64\Release\ .\x64\Release\ false .\x86\Debug\ .\x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true ..\..\..\include;%(AdditionalIncludeDirectories) Level3 .\x86\Release/ustring.tlb OnlyExplicitInline MultiThreadedDLL true .\x86\Release/ustring.pch .\x86\Release/ .\x86\Release/ .\x86\Release/ Default icuuc.lib;%(AdditionalDependencies) .\x86\Release/ustring.exe ..\..\..\lib;%(AdditionalLibraryDirectories) .\x86\Release/ustring.pdb Console false .\x64\Release/ustring.tlb OnlyExplicitInline ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDLL true .\x64\Release/ustring.pch .\x64\Release/ .\x64\Release/ .\x64\Release/ Default icuuc.lib;%(AdditionalDependencies) .\x64\Release/ustring.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) .\x64\Release/ustring.pdb Console false .\x86\Debug/ustring.tlb MultiThreadedDebugDLL .\x86\Debug/ustring.pch .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ EditAndContinue Default icuucd.lib;%(AdditionalDependencies) .\x86\Debug/ustring.exe ..\..\..\lib;%(AdditionalLibraryDirectories) true .\x86\Debug/ustring.pdb Console false .\x64\Debug/ustring.tlb MultiThreadedDebugDLL .\x64\Debug/ustring.pch .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ ProgramDatabase Default icuucd.lib;%(AdditionalDependencies) .\x64\Debug/ustring.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) true .\x64\Debug/ustring.pdb Console false PK!Duuustring/readme.txtnu[Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License 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 /source runConfigureICU --prefix [other options] gmake all 2. Install ICU, gmake install 3. Compile cd /source/samples/ustring gmake ICU_PREFIX=/source/samples/ustring gmake ICU_PREFIX= check -or- export LD_LIBRARY_PATH=/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. PK!%lv^^ustring/ustring.cppnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * Copyright (C) 2000-2014, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* * file name: ustring.c * encoding: UTF-8 * 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. */ #define __STDC_FORMAT_MACROS 1 #include #include #include "unicode/utypes.h" #include "unicode/uchar.h" #include "unicode/locid.h" #include "unicode/ustring.h" #include "unicode/ucnv.h" #include "unicode/unistr.h" using namespace icu; #ifndef UPRV_LENGTHOF #define UPRV_LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) #endif // 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; i0; /* 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 "AC" in the buffer... */ u_strcpy(buffer, text); buffer[1]=0xdf; /* sharp s, case-compares equal to "ss" */ printUString("should be \"AC\": ", 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" * "iI " * " " * "" */ 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" * "iI " * " " * "" */ 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, UPRV_LENGTHOF(readonly)); // * UnicodeString with allocated contents // build a longer string that will not fit into the object's buffer one+=UnicodeString(writeable, UPRV_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, UPRV_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 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, UPRV_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; } PK!>7[nnstrsrch/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # 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 PK!r{'{'strsrch/strsrch.vcxprojnu[ {E97790D1-7ABE-4C8E-9627-251ABEAA3EEC} Application false MultiByte <_ProjectFileVersion>10.0.30319.1 .\x86\Debug\ .\x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true .\x86\Release\ .\x86\Release\ false .\x64\Release\ .\x64\Release\ false .\x86\Debug/strsrch.tlb Disabled ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDebug .\x86\Debug/strsrch.pch .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ true Level3 EditAndContinue Default icuind.lib;icuucd.lib;%(AdditionalDependencies) .\x86\Debug/strsrch.exe true ..\..\..\lib;%(AdditionalLibraryDirectories) true .\x86\Debug/strsrch.pdb Console false .\x64\Debug/strsrch.tlb ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreadedDebug .\x64\Debug/strsrch.pch .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ true Level3 ProgramDatabase Default icuind.lib;icuucd.lib;%(AdditionalDependencies) .\x64\Debug/strsrch.exe ..\..\..\lib64;%(AdditionalLibraryDirectories) true .\x64\Debug/strsrch.pdb Console false .\x86\Release/strsrch.tlb OnlyExplicitInline ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreaded true .\x86\Release/strsrch.pch .\x86\Release/ .\x86\Release/ .\x86\Release/ Level3 true Default icuin.lib;icuuc.lib;%(AdditionalDependencies) .\x86\Release/strsrch.exe ..\..\..\lib;%(AdditionalLibraryDirectories) .\x86\Release/strsrch.pdb Console false .\x64\Release/strsrch.tlb OnlyExplicitInline ..\..\..\include;%(AdditionalIncludeDirectories) MultiThreaded true .\x64\Release/strsrch.pch .\x64\Release/ .\x64\Release/ .\x64\Release/ Level3 true Default icuin.lib;icuuc.lib;%(AdditionalDependencies) .\x64\Release/strsrch.exe true ..\..\..\lib64;%(AdditionalLibraryDirectories) .\x64\Release/strsrch.pdb Console false PK!:%%strsrch/strsrch.cppnu[/************************************************************************* * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ************************************************************************* ************************************************************************* * 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 #include #include #include #include #include #include /** * 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; } PK!=Gstrsrch/strsrch.slnnu[Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "strsrch", "strsrch.vcxproj", "{E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}.Debug|x64.Build.0 = Debug|x64 {E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}.Release|Win32.ActiveCfg = Release|Win32 {E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}.Release|Win32.Build.0 = Release|Win32 {E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}.Release|x64.ActiveCfg = Release|x64 {E97790D1-7ABE-4C8E-9627-251ABEAA3EEC}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK!$rrstrsrch/strsrch.vcxproj.filtersnu[ {1729c67a-c387-461a-8ea5-4f4c55da17a0} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {18ae9e20-0bfa-47a4-9fe1-e379df6f8ad1} h;hpp;hxx;hm;inl {80c9cc6e-85a0-44a2-b79a-0f811bd64103} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files PK!\p strsrch/readme.txtnu[Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License 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 /source runConfigureICU --prefix [other options] gmake all 2. Install ICU, gmake install To Run on Unixes cd /source/samples/strsrch gmake check -or- export LD_LIBRARY_PATH=/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. PK!y  readme.txtnu[## Copyright (C) 2016 and later: Unicode, Inc. and others. ## License & terms of use: http://www.unicode.org/copyright.html#License ## ## Copyright (c) 2002-2010, 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++. csdet - demonstrates using ICU's CharSet Detection API 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 (reader/writer in 'all' MSVC solution) 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: Windows MSVC: - build ICU - open 'all' project file in 'all' subdirectory - build project - sample executables will be located in /x86/Debug folders of each sample subdirectory 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. PK!f` cal/Makefilenu[## Copyright (C) 2016 and later: Unicode, Inc. and others. ## License & terms of use: http://www.unicode.org/copyright.html#License ## ## Makefile.in for ICU - samples/cal ## Copyright (c) 1999-2011, International Business Machines Corporation and ## others. All Rights Reserved. ## Source directory information 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_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.cc) $(OUTOPT)$@ $^ $(LIBS) $(POST_BUILD_STEP) ifeq (,$(MAKECMDGOALS)) -include $(DEPS) else ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),) -include $(DEPS) endif endif PK!*YY cal/cal.cnu[/* *********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** ********************************************************************** * Copyright (C) 1998-2012, International Business Machines Corporation * and others. All Rights Reserved. ********************************************************************** * * File date.c * * Modification History: * * Date Name Description * 06/16/99 stephen Creation. ******************************************************************************* */ #include #include #include #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 idx = (i + firstIndex) % arrayLength; int32_t size = 1 + udat_getSymbols(fmt, type, idx + lowestIndex, NULL, 0, status); array[idx] = (UChar *) malloc(sizeof(UChar) * size); *status = U_ZERO_ERROR; udat_getSymbols(fmt, type, idx + lowestIndex, array[idx], 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_PATTERN,UDAT_PATTERN,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_PATTERN,UDAT_PATTERN,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 PK!'%%%cal/cal.vcxprojnu[ Application false MultiByte {F7659D77-09CF-4FE9-ACEE-927287AA9509} <_ProjectFileVersion>10.0.30319.1 .\x86\Release\ .\x86\Release\ false .\x64\Release\ .\x64\Release\ false .\x86\Debug\ .\x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true ..\..\..\include;%(AdditionalIncludeDirectories) Level3 false .\x86\Release/cal.tlb OnlyExplicitInline MultiThreadedDLL true .\x86\Release/cal.pch .\x86\Release/ .\x86\Release/ .\x86\Release/ Default icuuc.lib;icuin.lib;%(AdditionalDependencies) .\x86\Release/cal.exe ../../../lib;%(AdditionalLibraryDirectories) .\x86\Release/cal.pdb Console false .\x64\Release/cal.tlb OnlyExplicitInline MultiThreadedDLL true .\x64\Release/cal.pch .\x64\Release/ .\x64\Release/ .\x64\Release/ Default icuuc.lib;icuin.lib;%(AdditionalDependencies) .\x64\Release/cal.exe ../../../lib64;%(AdditionalLibraryDirectories) .\x64\Release/cal.pdb Console false .\x86\Debug/cal.tlb EnableFastChecks MultiThreadedDebugDLL .\x86\Debug/cal.pch .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ true EditAndContinue Default icuucd.lib;icuind.lib;%(AdditionalDependencies) .\x86\Debug/cal.exe ../../../lib;%(AdditionalLibraryDirectories) true .\x86\Debug/cal.pdb Console false .\x64\Debug/cal.tlb MultiThreadedDebugDLL .\x64\Debug/cal.pch .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ true ProgramDatabase Default icuucd.lib;icuind.lib;%(AdditionalDependencies) .\x64\Debug/cal.exe ../../../lib64;%(AdditionalLibraryDirectories) true .\x64\Debug/cal.pdb Console false PK!99cal/cal.vcxproj.filtersnu[ {3e036a59-b898-49e5-9d06-4878387b4a02} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {ace55cd2-56c0-4c6d-965b-8866c5396b04} h;hpp;hxx;hm;inl {823558d3-c303-4670-9e92-d8f5c02e39e2} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files Source Files Header Files PK!7cal/Makefile.innu[## Copyright (C) 2016 and later: Unicode, Inc. and others. ## License & terms of use: http://www.unicode.org/copyright.html#License ## ## Makefile.in for ICU - samples/cal ## Copyright (c) 1999-2011, 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_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.cc) $(OUTOPT)$@ $^ $(LIBS) $(POST_BUILD_STEP) ifeq (,$(MAKECMDGOALS)) -include $(DEPS) else ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),) -include $(DEPS) endif endif PK! cal/uprint.cnu[/* *********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** ********************************************************************** * 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); } PK!#FI cal/cal.slnnu[Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cal", "cal.vcxproj", "{F7659D77-09CF-4FE9-ACEE-927287AA9509}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {F7659D77-09CF-4FE9-ACEE-927287AA9509}.Debug|x64.Build.0 = Debug|x64 {F7659D77-09CF-4FE9-ACEE-927287AA9509}.Release|Win32.ActiveCfg = Release|Win32 {F7659D77-09CF-4FE9-ACEE-927287AA9509}.Release|Win32.Build.0 = Release|Win32 {F7659D77-09CF-4FE9-ACEE-927287AA9509}.Release|x64.ActiveCfg = Release|x64 {F7659D77-09CF-4FE9-ACEE-927287AA9509}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK!Tcal/readme.txtnu[Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License 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 /source runConfigureICU --prefix [other options] gmake all 2. Install ICU, gmake install To Run on Unixes cd /source/samples/cal gmake check -or- export LD_LIBRARY_PATH=/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. PK!;V cal/uprint.hnu[/* *********************************************************************** * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License *********************************************************************** ********************************************************************** * 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 #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 */ PK!˰props/props.slnnu[Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "props", "props.vcxproj", "{ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}.Debug|x64.Build.0 = Debug|x64 {ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}.Release|Win32.ActiveCfg = Release|Win32 {ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}.Release|Win32.Build.0 = Release|Win32 {ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}.Release|x64.ActiveCfg = Release|x64 {ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK!/Qppprops/props.vcxproj.filtersnu[ {2e5ed8fa-dbb6-411e-906e-128c69e6ab1f} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {07db40cb-b9b6-43df-b10e-240fb0d4747b} h;hpp;hxx;hm;inl {4526d88f-8075-44ec-8845-dcb0bfbb23fa} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files PK!jjprops/Makefilenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # 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 PK!.**props/props.vcxprojnu[ {ABE4CD17-8ED8-4DE6-ABDE-CDEFC220CF60} Application false MultiByte <_ProjectFileVersion>10.0.30319.1 .\x86\Release\ .\x86\Release\ false .\x64\Release\ .\x64\Release\ false .\x86\Debug\ .\x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true .\x86\Release/props.tlb OnlyExplicitInline ..\..\..\include;%(AdditionalIncludeDirectories) true MultiThreadedDebugDLL true true .\x86\Release/props.pch .\x86\Release/ .\x86\Release/ .\x86\Release/ Level3 true Default icuuc.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) .\x86\Release/props.exe true ..\..\..\lib;%(AdditionalLibraryDirectories) .\x86\Release/props.pdb Console false X64 .\x64\Release/props.tlb OnlyExplicitInline ..\..\..\include;%(AdditionalIncludeDirectories) true MultiThreadedDebugDLL true true .\x64\Release/props.pch .\x64\Release/ .\x64\Release/ .\x64\Release/ Level3 true Default icuuc.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) .\x64\Release/props.exe true ..\..\..\lib64;%(AdditionalLibraryDirectories) .\x64\Release/props.pdb Console false .\x86\Debug/props.tlb Disabled ..\..\..\include;%(AdditionalIncludeDirectories) EnableFastChecks MultiThreadedDebugDLL true .\x86\Debug/props.pch .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ Level3 true EditAndContinue Default icuucd.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) .\x86\Debug/props.exe true ..\..\..\lib;%(AdditionalLibraryDirectories) true .\x86\Debug/props.pdb Console false X64 .\x64\Debug/props.tlb Disabled ..\..\..\include;%(AdditionalIncludeDirectories) EnableFastChecks MultiThreadedDebugDLL true .\x64\Debug/props.pch .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ Level3 true ProgramDatabase Default icuucd.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) .\x64\Debug/props.exe true ..\..\..\lib64;%(AdditionalLibraryDirectories) true .\x64\Debug/props.pdb Console false PK!Fyiiprops/readme.txtnu[Copyright (C) 2016 and later: Unicode, Inc. and others. License & terms of use: http://www.unicode.org/copyright.html#License 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 /source runConfigureICU --prefix [other options] gmake all 2. Install ICU, gmake install 3. Compile cd /source/samples/props gmake ICU_PREFIX=/source/samples/props gmake ICU_PREFIX= check -or- export LD_LIBRARY_PATH=/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. PK!y  props/props.cppnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * Copyright (C) 2000, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* * file name: props.cpp * encoding: UTF-8 * 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. */ #define __STDC_FORMAT_MACROS 1 #include #include #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+%04" PRId32 "\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+%04" PRId32 "\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 ///////////////////////////////////////////////////////////////////////////// #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 \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 PK!U`PAAlayout/FontTableCache.hnu[/* ************************************************************************* * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ************************************************************************* ********************************************************************** * Copyright (C) 2003-2008, 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; virtual void freeFontTable(const void *table) const; private: void add(LETag tableTag, const void *table); FontTableCacheEntry *fTableCache; le_int32 fTableCacheCurr; le_int32 fTableCacheSize; }; #endif PK!)Ӏ layout/Makefilenu[## Copyright (C) 2016 and later: Unicode, Inc. and others. ## License & terms of use: http://www.unicode.org/copyright.html#License ## ## Makefile.in for ICU - samples/layout ## Copyright (c) 2001-2011, International Business Machines Corporation and ## others. All Rights Reserved. ## Source directory information srcdir = . top_srcdir = ../.. top_builddir = ../.. include $(top_builddir)/icudefs.mk ## Platform-specific setup include $(top_srcdir)/config/mh-linux ## 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_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/layoutex -I$(top_srcdir)/layout -I$(top_srcdir) -g LIBS = $(LIBICULX) $(LIBICULE) $(LIBICUUC) $(LIBICUI18N) -lpthread -ldl -lm `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 PK!nUUlayout/paragraph.cppnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * Copyright (C) 1999-2015, 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)) { delete paragraphLayout; 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]; } for (le_int32 paragraph = 0; paragraph < fParagraphCount; paragraph += 1) { delete fParagraphLayout[paragraph]; } LE_DELETE_ARRAY(fLines); LE_DELETE_ARRAY(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; } PK!:LLlayout/GDIFontMap.cppnu[/* ****************************************************************************** * © 2016 and later: Unicode, Inc. and others. * * License & terms of use: http://www.unicode.org/copyright.html#License * ****************************************************************************** ****************************************************************************** * Copyright (C) 1998-2003, International Business Machines Corporation and * * others. All Rights Reserved. * ****************************************************************************** */ #include #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; } PK!layout/rsurface.cppnu[/* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * * (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 PK! !!layout/cgnomelayout.cnu[ /* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ****************************************************************************** * * * Copyright (C) 1999-2007, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** * */ #include #include #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); } PK!d ܫlayout/gdiglue.cppnu[/* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved * */ #include #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 PK!q]22layout/GnomeGUISupport.cppnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * 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 #else #include #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 } PK!Ġ::layout/cmaps.hnu[/* ****************************************************************************** * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ****************************************************************************** ****************************************************************************** * * * 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 PK!rrlayout/gsupport.hnu[/* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * * (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 PK!HIi!!layout/gnomelayout.cppnu[ /* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ****************************************************************************** * * * 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 #include #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); } PK!lB̆layout/arraymem.hnu[/* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved * */ #ifndef __ARRAYMEM_H #define __ARRAYMEM_H #include #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 PK!8^^layout/GDIGUISupport.cppnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * 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 #include "GDIGUISupport.h" void GDIGUISupport::postErrorMessage(const char *message, const char *title) { MessageBoxA(NULL, message, title, MB_ICONERROR); } PK!1nS layout/Makefile.innu[## Copyright (C) 2016 and later: Unicode, Inc. and others. ## License & terms of use: http://www.unicode.org/copyright.html#License ## ## Makefile.in for ICU - samples/layout ## Copyright (c) 2001-2011, 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_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 PK!;[layout/Sample.txtnu[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: บทที่๑พายุไซโคลนโดโรธีอาศัยอยู่ท่ามกลางทุ่งใหญ่ในแคนซัสกับลุงเฮนรีชาวไร่และป้าเอ็มภรรยาชาวไร่บ้านของพวกเขาหลังเล็กเพราะไม้สร้างบ้านต้องขนมาด้วยเกวียนเป็นระยะทางหลายไมล์ PK!>b&b&layout/GDIFontInstance.cppnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * Copyright (C) 1999-2008, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* * file name: GDIFontInstance.cpp * * created on: 08/09/2000 * created by: Eric R. Mader */ #include #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) { fUnitsPerEM = otm.otmEMSquare; fAscent = otm.otmTextMetrics.tmAscent; fDescent = otm.otmTextMetrics.tmDescent; fLeading = otm.otmTextMetrics.tmExternalLeading; } else { const HEADTable *headTable = NULL; const HHEATable *hheaTable = NULL; // read unitsPerEm from 'head' table headTable = (const HEADTable *) readFontTable(LE_HEAD_TABLE_TAG); if (headTable == NULL) { status = LE_MISSING_FONT_TABLE_ERROR; goto restore; } fUnitsPerEM = SWAPW(headTable->unitsPerEm); freeFontTable((const void *)headTable); hheaTable = (HHEATable *) readFontTable(LE_HHEA_TABLE_TAG); if (hheaTable == NULL) { status = LE_MISSING_FONT_TABLE_ERROR; goto restore; } fAscent = (le_int32) yUnitsToPoints((float) SWAPW(hheaTable->ascent)); fDescent = (le_int32) yUnitsToPoints((float) SWAPW(hheaTable->descent)); fLeading = (le_int32) yUnitsToPoints((float) SWAPW(hheaTable->lineGap)); freeFontTable((const void *) hheaTable); } 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 } PK!ilayout/UnicodeReader.hnu[/* ****************************************************************************** * © 2016 and later: Unicode, Inc. and others. * * License & terms of use: http://www.unicode.org/copyright.html#License * ****************************************************************************** ****************************************************************************** * 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 PK!}mlayout/ucreader.cppnu[/* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * * (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 PK!|layout/GnomeGUISupport.hnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * 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 PK!ߛ__layout/RenderingSurface.hnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * 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 PK!7rzzlayout/GUISupport.hnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * 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 PK!a“layout/GDIGUISupport.hnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * 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 PK!˘olayout/pflow.hnu[/* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * * (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 PK!}L'L'layout/clayout.cnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * 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 #include #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; } PK!O܈layout/FontMap.Gnomenu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # 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 PK!羵layout/GnomeFontInstance.cppnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * 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 #include #include FT_FREETYPE_H #include FT_GLYPH_H #include FT_RENDER_H #include FT_TRUETYPE_TABLES_H #include #include #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); } PK!layout/resource.hnu[//{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. // © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html#License // Corporation and others. All Rights Reserved. // 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 PK!ʪf((layout/GnomeFontInstance.hnu[ /* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * 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 #include #include FT_FREETYPE_H #include FT_GLYPH_H #include #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 PK!cԧjjlayout/UnicodeReader.cppnu[/* ****************************************************************************** * © 2016 and later: Unicode, Inc. and others. * * License & terms of use: http://www.unicode.org/copyright.html#License * ****************************************************************************** ****************************************************************************** * Copyright (C) 1998-2005, International Business Machines Corporation and * * others. All Rights Reserved. * ****************************************************************************** */ #include #include #include #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; } PK! ў$layout/ScriptCompositeFontInstance.hnu[/* * %W% %E% * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * * (C) Copyright IBM Corp. 1998-2011 - 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 offset 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 * LEFontInstance which represent a physical font. It returns * this and indicates that the entire string can be rendered. * * This method will return a valid LEFontInstance unless you * have passed illegal parameters, or an internal error has been encountered. * For composite fonts, it may return the warning LE_NO_SUBFONT_WARNING * to indicate that the returned font may not be able to render all of * the text. Whenever a valid font is returned, the offset 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 arabScriptCode 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 * LE_NO_SUBFONT_WARNING if the subfont which * was returned cannot render all of the text. * * @return an LEFontInstance for the sub font which can render the characters, or * NULL if there is an error. * * @see LEScripts.h */ 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 */ 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. */ virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } /** * ICU "poor man's RTTI", returns a UClassID for this class. */ 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 PK!Z!layout/layout.slnnu[Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "layout", "layout.vcxproj", "{497500ED-DE1D-4B20-B529-F41B5A0FBEEB}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 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}.Debug|x64.ActiveCfg = Debug|x64 {497500ED-DE1D-4B20-B529-F41B5A0FBEEB}.Debug|x64.Build.0 = Debug|x64 {497500ED-DE1D-4B20-B529-F41B5A0FBEEB}.Release|Win32.ActiveCfg = Release|Win32 {497500ED-DE1D-4B20-B529-F41B5A0FBEEB}.Release|Win32.Build.0 = Release|Win32 {497500ED-DE1D-4B20-B529-F41B5A0FBEEB}.Release|x64.ActiveCfg = Release|x64 {497500ED-DE1D-4B20-B529-F41B5A0FBEEB}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal PK![ &layout/GnomeFontMap.cppnu[/* ****************************************************************************** * © 2016 and later: Unicode, Inc. and others. * * License & terms of use: http://www.unicode.org/copyright.html#License * ****************************************************************************** ****************************************************************************** * Copyright (C) 1998-2006, International Business Machines Corporation and * * others. All Rights Reserved. * ****************************************************************************** */ #include #include #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; } PK!OPlayout/gdiglue.hnu[/* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved * */ #ifndef __GDIGLUE_H #define __GDIGLUE_H #include #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 PK!Cv!layout/rsurface.hnu[/* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * * (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 PK!?gw< < layout/layout.vcxproj.filtersnu[ {d95d859b-6ae7-4ac2-953c-511411f74b77} cpp;c;cxx;rc;def;r;odl;idl;hpj;bat {8e82936c-dd21-49c1-9174-d88411b4b9c7} h;hpp;hxx;hm;inl {d7b63b8f-73c9-48ca-b0cb-fa6a537901c4} ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files PK!r layout/Surface.hnu[/* * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * * 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); }; PK!W644layout/layout.vcxprojnu[ {497500ED-DE1D-4B20-B529-F41B5A0FBEEB} Application false MultiByte <_ProjectFileVersion>10.0.30319.1 .\x86\Release\ .\x86\Release\ false .\x64\Release\ .\x64\Release\ false .\x86\Debug\ .\x86\Debug\ true .\x64\Debug\ .\x64\Debug\ true .\x86\Release/layout.tlb OnlyExplicitInline ..\..\..\include;..\..\..\include\layout;..\..\common;%(AdditionalIncludeDirectories) WINVER=0x0601;_WIN32_WINNT=0x0601;NDEBUG;_CONSOLE;WIN32;UNICODE;_CRT_SECURE_NO_DEPRECATE;LE_USE_CMEMORY;%(PreprocessorDefinitions) true MultiThreadedDLL true true .\x86\Release/layout.pch .\x86\Release/ .\x86\Release/ .\x86\Release/ Level3 true Default NDEBUG;%(PreprocessorDefinitions) 0x0409 ..\..\..\lib\iculx.lib;..\..\..\lib\icule.lib;..\..\..\lib\icuuc.lib;..\..\..\lib\icuin.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) .\x86\Release/layout.exe true .\x86\Release/layout.pdb Windows false X64 .\x64\Release/layout.tlb OnlyExplicitInline ..\..\..\include;..\..\..\include\layout;..\..\common;%(AdditionalIncludeDirectories) NDEBUG;_CONSOLE;WIN64;WIN32;UNICODE;_CRT_SECURE_NO_DEPRECATE;LE_USE_CMEMORY;%(PreprocessorDefinitions) true MultiThreadedDLL true true .\x64\Release/layout.pch .\x64\Release/ .\x64\Release/ .\x64\Release/ Level3 true Default NDEBUG;%(PreprocessorDefinitions) 0x0409 ..\..\..\lib64\iculx.lib;..\..\..\lib64\icule.lib;..\..\..\lib64\icuuc.lib;..\..\..\lib64\icuin.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) .\x64\Release/layout.exe true .\x64\Release/layout.pdb Windows false MachineX64 .\x86\Debug/layout.tlb Disabled ..\..\..\include;..\..\..\include\layout;..\..\common;%(AdditionalIncludeDirectories) WINVER=0x0601;_WIN32_WINNT=0x0601;_DEBUG;WIN32;UNICODE;LE_USE_CMEMORY;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL true .\x86\Debug/layout.pch .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ Level3 true EditAndContinue Default _DEBUG;%(PreprocessorDefinitions) 0x0409 ..\..\..\lib\iculxd.lib;..\..\..\lib\iculed.lib;..\..\..\lib\icuucd.lib;..\..\..\lib\icuind.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) .\x86\Debug/layout.exe true true .\x86\Debug/layout.pdb Windows false X64 .\x64\Debug/layout.tlb Disabled ..\..\..\include;..\..\..\include\layout;..\..\common;%(AdditionalIncludeDirectories) _DEBUG;WIN64;WIN32;UNICODE;LE_USE_CMEMORY;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL true .\x64\Debug/layout.pch .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ Level3 true ProgramDatabase Default _DEBUG;%(PreprocessorDefinitions) 0x0409 ..\..\..\lib64\iculxd.lib;..\..\..\lib64\iculed.lib;..\..\..\lib64\icuucd.lib;..\..\..\lib64\icuind.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) .\x64\Debug/layout.exe true true .\x64\Debug/layout.pdb Windows false MachineX64 PK!l8rlayout/FontMap.GDInu[# Copyright (C) 2016 and later: Unicode, Inc. and others. # License & terms of use: http://www.unicode.org/copyright.html#License # # Copyright (C) 2001-2010, 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: Courier MonoThai DEFAULT: Code2000 PK!9layout/paragraph.hnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * 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 PK!B70'0'layout/layout.cppnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * 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 #include #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; } PK!flayout/gnomeglue.cppnu[/* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved * */ #include #include #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 PK!cf%%layout/pflow.cnu[/* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * * (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; } PK!ihhlayout/GDIFontInstance.hnu[ /* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * 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 #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 PK!a &layout/ScriptCompositeFontInstance.cppnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ******************************************************************************* * * 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); } PK!4^layout/ucreader.hnu[/* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * * (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 PK!yhlayout/GnomeFontMap.hnu[/* ******************************************************************************* * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ******************************************************************************* ****************************************************************************** * Copyright (C) 1998-2006, International Business Machines Corporation and * * others. All Rights Reserved. * ****************************************************************************** */ #ifndef __GNOMEFONTMAP_H #define __GNOMEFONTMAP_H #include #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 PK!ߝ layout/sfnt.hnu[/* ****************************************************************************** * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ****************************************************************************** ****************************************************************************** * * * 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 PK!t]]layout/FontMap.cppnu[/* ****************************************************************************** * © 2016 and later: Unicode, Inc. and others. * * License & terms of use: http://www.unicode.org/copyright.html#License * ****************************************************************************** ****************************************************************************** * Copyright (C) 1998-2006, International Business Machines Corporation and * * others. All Rights Reserved. * ****************************************************************************** */ #include #include #include #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; } } } PK!Sޯ{ { layout/FontTableCache.cppnu[/* ************************************************************************* * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License ************************************************************************* ************************************************************************* * Copyright (C) 2003 - 2008, 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) { freeFontTable(fTableCache[i].table); fTableCache[i].tag = 0; fTableCache[i].table = NULL; } fTableCacheCurr = 0; LE_DELETE_ARRAY(fTableCache); fTableCache = NULL; } void FontTableCache::freeFontTable(const void *table) const { LE_DELETE_ARRAY(table); } 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; } PK!ϒP44layout/cmaps.cppnu[/* ******************************************************************************* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * ******************************************************************************* ****************************************************************************** * * * 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 } PK!A5/3||layout/Surface.cppnu[/* * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * * 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); } PK!pELLlayout/readme.htmlnu[ Readme file for the ICU LayoutEngine demo

What is the layout demo?

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.

How do I build the layout demo?

First, you need to build ICU, including the LayoutEngine.

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.

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"

To build the demo on Windows, just open the layout project in <icu>\source\samples\layout and build it.

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.

How do I run the demo?

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:

First, download the Thai font. Go to freelang.net and click on the link for the Courier Thai font. This will download a .ZIP file. Extract the Courpro.ttf font. On Windows, copy this font file to your Fonts folder (note the name of the font after it is installed), on Linux, copy this font file to the directory from which you'll run the layout demo.

Next is the Hindi font. Download the font from Raghindi. On Linux, you can download the font into the directory from which you'll run the layout demo. On Windows, you'll need to install it in your Fonts folder.

There's still one more font to get, the Code2000 Unicode font. Go to James Kass' Unicode Support In Your Browser 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.

Note: 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.

Be sure that your FontMap.GDI (on Windows) or FontMap.Gnome file (on Linux) contains accurate font names for each script type. For example, the following is a valid FontMap.GDI (assuming you have the correct fonts):

DEVANAGARI: Raghindi
THAI: Courier MonoThai
DEFAULT: Code2000

Note that only the Code2000 default font is strictly necessary, and that the other two can simply be commented out by a '#' if you do not wish to use them.

Also note that the FontMap and the sample.txt files have to be in the same directory as the layout executable.

That's it! Now all you have to do is run letest (CTRL+F5 in Visual C++, or "./gnomelayout" in Linux)

How can I customize the layout demo?

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.

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.

Here is the list of legal script names:

ARABIC
ARMENIAN
BENGALI
BOPOMOFO
BUHID
CANADIAN_ABORIGINAL
CHEROKEE
CYRILLIC
DESERET
DEVANAGARI
ETHIOPIC
GEORGIAN
GOTHIC
GREEK
GUJARATI
GURMUKHI
HAN
HANGUL
HANUNOO
HEBREW
HIRAGANA
KANNADA
KATAKANA
KHMER
LATIN
MALAYALAM
MONGOLIAN
MYANMAR
OGHAM
OLD_ITALIC
ORIYA
RUNIC
SINHALA
SYRIAC
TAGALOG
TAGBANWA

TAMIL
TELUGU
THAANA
THAI
TIBETAN
YI

You can also use the script name "DEFAULT" to represent all scripts which you don't explicitly list in the FontMap file.

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.


PK!|>layout/gnomeglue.hnu[/* * * © 2016 and later: Unicode, Inc. and others. * License & terms of use: http://www.unicode.org/copyright.html#License * * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved * */ #ifndef __GNOMEGLUE_H #define __GNOMEGLUE_H #include #include #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 PK!M~__layout/FontMap.hnu[/* ****************************************************************************** * © 2016 and later: Unicode, Inc. and others. * * License & terms of use: http://www.unicode.org/copyright.html#License * ****************************************************************************** ****************************************************************************** * 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 PK!Nlayout/GDIFontMap.hnu[/* ****************************************************************************** * © 2016 and later: Unicode, Inc. and others. * * License & terms of use: http://www.unicode.org/copyright.html#License * ****************************************************************************** ****************************************************************************** * Copyright (C) 1998-2003, International Business Machines Corporation and * * others. All Rights Reserved. * ****************************************************************************** */ #ifndef __GDIFONTMAP_H #define __GDIFONTMAP_H #include #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 PK!k±-dtitvfmtsample/dtitvfmtsample.vcxproj.filtersnu[ {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms Source Files PK!j%dtitvfmtsample/dtitvfmtsample.vcxprojnu[ {8945255B-473B-4C47-9425-E92384338CAA} samples Application true Unicode Application true Unicode Application false true Unicode Application false true Unicode .\x86\Debug\ .\x86\Debug\ $(ProjectName) .\x64\Debug\ .\x64\Debug\ $(ProjectName) .\x86\Release\ .\x86\Release\ $(ProjectName) .\x64\Release\ .\x64\Release\ $(ProjectName) Level3 ..\..\..\include;%(AdditionalIncludeDirectories) .\x86\Debug/ .\x86\Debug/ .\x86\Debug/ true .\x86\Debug/dtitvfmtsample.exe icuucd.lib;icuind.lib;icuiod.lib;%(AdditionalDependencies) ..\..\..\lib;%(AdditionalLibraryDirectories) Level3 ..\..\..\include;%(AdditionalIncludeDirectories) .\x64\Debug/ .\x64\Debug/ .\x64\Debug/ true .\x64\Debug/dtitvfmtsample.exe icuucd.lib;icuind.lib;icuiod.lib;%(AdditionalDependencies) ..\..\..\lib64;%(AdditionalLibraryDirectories) Level3 MaxSpeed true true ..\..\..\include;%(AdditionalIncludeDirectories) .\x86\Release/ .\x86\Release/ .\x86\Release/ true true icuuc.lib;icuin.lib;icuio.lib;%(AdditionalDependencies) ..\..\..\lib;%(AdditionalLibraryDirectories) Level3 MaxSpeed true true ..\..\..\include;%(AdditionalIncludeDirectories) .\x64\Release/ .\x64\Release/ .\x64\Release/ true true icuuc.lib;icuin.lib;icuio.lib;%(AdditionalDependencies) ..\..\..\lib64;%(AdditionalLibraryDirectories) PK!޿4!dtitvfmtsample/dtitvfmtsample.cppnu[// © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /****************************************************************************** * Copyright (C) 2008-2014, International Business Machines Corporation and * others. All Rights Reserved. ******************************************************************************* */ //! [dtitvfmtPreDefined1] #include #include "unicode/dtitvfmt.h" #include "unicode/ustdio.h" //! [dtitvfmtPreDefined1] using namespace std; using namespace icu; static void dtitvfmtPreDefined() { u_printf("===============================================================================\n"); u_printf(" dtitvfmtPreDefined()\n"); u_printf("\n"); u_printf(" Use DateIntervalFormat to get date interval format for pre-defined skeletons:\n"); u_printf(" yMMMd, MMMMd, jm per locale\n"); u_printf("===============================================================================\n"); //! [dtitvfmtPreDefined] UFILE *out = u_finit(stdout, NULL, "UTF-8"); UErrorCode status =U_ZERO_ERROR; // create 3 Date Intervals UnicodeString data[] = { UnicodeString("2007-10-10 10:10:10"), UnicodeString("2008-10-10 10:10:10"), UnicodeString("2008-11-10 10:10:10"), UnicodeString("2008-11-10 15:10:10") }; Calendar *cal = Calendar::createInstance(status); cal->set(2007,10,10,10,10,10); UDate date1 = cal->getTime(status); cal->set(2008,10,10,10,10,10); UDate date2 = cal->getTime(status); cal->set(2008,11,10,10,10,10); UDate date3 = cal->getTime(status); cal->set(2008,11,10,15,10,10); UDate date4 = cal->getTime(status); DateInterval* dtitvsample[] = { new DateInterval(date1,date2), new DateInterval(date2,date3), new DateInterval(date3,date4), }; UnicodeString skeletons[] = { UnicodeString("yMMMd"), UnicodeString("MMMMd"), UnicodeString("jm"), 0, }; u_fprintf(out,"%-10s%-22s%-22s%-35s%-35s\n", "Skeleton","from","to","Date Interval in en_US","Date Interval in Ja"); int i=0; UnicodeString formatEn,formatJa; FieldPosition pos=0; for (int j=0;skeletons[j]!=NULL ;j++) { u_fprintf(out,"%-10S%-22S%-22S",skeletons[j].getTerminatedBuffer(),data[i].getTerminatedBuffer(),data[i+1].getTerminatedBuffer()); //create a DateIntervalFormat instance for given skeleton, locale DateIntervalFormat* dtitvfmtEn = DateIntervalFormat::createInstance(skeletons[j], Locale::getEnglish(),status); DateIntervalFormat* dtitvfmtJa = DateIntervalFormat::createInstance(skeletons[j], Locale::getJapanese(),status); formatEn.remove(); formatJa.remove(); //get the DateIntervalFormat dtitvfmtEn->format(dtitvsample[i],formatEn,pos,status); dtitvfmtJa->format(dtitvsample[i],formatJa,pos,status); u_fprintf(out,"%-35S%-35S\n", formatEn.getTerminatedBuffer(),formatJa.getTerminatedBuffer()); delete dtitvfmtEn; delete dtitvfmtJa; i++; } u_fclose(out); //! [dtitvfmtPreDefined] } static void dtitvfmtCustomized() { u_printf("===============================================================================\n"); u_printf("\n"); u_printf(" dtitvfmtCustomized()\n"); u_printf("\n"); u_printf(" Use DateIntervalFormat to create customized date interval format for yMMMd, Hm"); u_printf("\n"); u_printf("================================================================================\n"); //! [dtitvfmtCustomized] UFILE *out = u_finit(stdout, NULL, "UTF-8"); UErrorCode status =U_ZERO_ERROR; UnicodeString data[] = { UnicodeString("2007-9-10 10:10:10"), UnicodeString("2007-10-10 10:10:10"), UnicodeString("2007-10-10 22:10:10") }; // to create 2 Date Intervals Calendar *cal1 = Calendar::createInstance(status); cal1->set(2007,9,10,10,10,10); Calendar *cal2 = Calendar::createInstance(status); cal2->set(2007,10,10,10,10,10); Calendar *cal3 = Calendar::createInstance(status); cal3->set(2007,10,10,22,10,10); DateInterval* dtitvsample[] = { new DateInterval(cal1->getTime(status),cal2->getTime(status)), new DateInterval(cal2->getTime(status),cal3->getTime(status)) }; UnicodeString skeletons[] = { UnicodeString("yMMMd"), UnicodeString("Hm"), 0, }; u_printf("%-10s%-22s%-22s%-45s%-35s\n", "Skeleton", "from","to", "Date Interval in en_US","Date Interval in Ja"); // Create an empty DateIntervalInfo object DateIntervalInfo dtitvinf = DateIntervalInfo(status); // Set Date Time internal pattern for MONTH, HOUR_OF_DAY dtitvinf.setIntervalPattern("yMMMd", UCAL_MONTH, "y 'Diff' MMM d --- MMM d",status); dtitvinf.setIntervalPattern("Hm", UCAL_HOUR_OF_DAY, "yyyy MMM d HH:mm ~ HH:mm",status); // Set fallback interval pattern dtitvinf.setFallbackIntervalPattern("{0} ~~~ {1}",status); // Get the DateIntervalFormat with the custom pattern UnicodeString formatEn,formatJa; FieldPosition pos=0; for (int i=0;i<2;i++){ for (int j=0;skeletons[j]!=NULL;j++) { u_fprintf(out,"%-10S%-22S%-22S", skeletons[i].getTerminatedBuffer(),data[j].getTerminatedBuffer(), data[j+1].getTerminatedBuffer()); DateIntervalFormat* dtitvfmtEn = DateIntervalFormat::createInstance(skeletons[i],Locale::getEnglish(),dtitvinf,status); DateIntervalFormat* dtitvfmtJa = DateIntervalFormat::createInstance(skeletons[i],Locale::getJapanese(),dtitvinf,status); formatEn.remove(); formatJa.remove(); dtitvfmtEn->format(dtitvsample[j],formatEn,pos,status); dtitvfmtJa->format(dtitvsample[j],formatJa,pos,status); u_fprintf(out,"%-45S%-35S\n", formatEn.getTerminatedBuffer(),formatJa.getTerminatedBuffer()); } } u_fclose(out); //! [dtitvfmtCustomized] } int main (int argc, char* argv[]) { dtitvfmtPreDefined(); dtitvfmtCustomized(); return 0; } PK!ԿV Makefilenu[PK!(xGll% citer/Makefilenu[PK!Y<citer/citer.cppnu[PK!2f)6$citer/citer.vcxproj.filtersnu[PK!D(citer/citer.vcxprojnu[PK!(F׮Hciter/readme.txtnu[PK!僙Qdefs.mknu[PK!>|R=BBVplurfmtsample/plurfmtsample.cppnu[PK!έ+*hplurfmtsample/plurfmtsample.vcxproj.filtersnu[PK! dTufortune/resources/Makefilenu[PK!C4(\ufortune/resources/fortune_resources.maknu[PK!{$cufortune/resources/res-file-list.txtnu[PK!C,,scufortune/resources/root.txtnu[PK!`@@ufortune/resources/es.txtnu[PK!' ' ucnv/data06.txtnu[PK! 8 @ucnv/Makefilenu[PK!8sCC#ucnv/data01.txtnu[PK!)G,Eucnv/data02.binnu[PK!ܶM8%8%ucnv/ucnv.vcxprojnu[PK!{ [ucnv/ucnv.slnnu[PK!m^ Fucnv/flagcb.hnu[PK!ε2tt ucnv/convsamp.cppnu[PK!g## ~ucnv/flagcb.cnu[PK!c; 2ucnv/readme.txtnu[PK! @@6ucnv/ucnv.vcxproj.filtersnu[PK!;!R Makefile.innu[PK!K(wwdatefmt/util.hnu[PK!ԁVVdatefmt/Makefilenu[PK!,S8  >datefmt/answers/main_3.cppnu[PK!m. datefmt/answers/main_2.cppnu[PK! ccdatefmt/answers/main_1.cppnu[PK!4datefmt/answers/main_0.cppnu[PK! ~datefmt/datefmt.slnnu[PK![}Wdatefmt/datefmt.vcxproj.filtersnu[PK!ILL61&1&datefmt/datefmt.vcxprojnu[PK!cb>>Ndatefmt/README.TXTnu[PK!lC C *datefmt/main.cppnu[PK!< Q7datefmt/util.cppnu[PK!,__@all/samplecheck.batnu[PK!JJ 3_all/all.slnnu[PK! XOlegacy/Makefilenu[PK!"blegacy/legacy.slnnu[PK!. %%legacy/legacy.vcxproj.filtersnu[PK!Qh 0legacy/oldcol.cppnu[PK!Nu+ + Xlegacy/newcol.cppnu[PK!99legacy/legacy.vcxprojnu[PK! legacy/READMEnu[PK!lMl% % legacy/legacy.cppnu[PK!BHY*uciter8/uit_len8.hnu[PK!, % %¸uciter8/uciter8.vcxprojnu[PK!cbreak/break.slnnu[PK!#mJssbreak/Makefilenu[PK!{~~break/break.cppnu[PK!eѷobreak/ubreak.cnu[PK!dbreak/break.vcxproj.filtersnu[PK!w break/readme.txtnu[PK! _2A%A%break/break.vcxprojnu[PK!I_jj 9csdet/Makefilenu[PK!:T~ ;csdet/csdet.vcxprojnu[PK!0ጂ\csdet/csdet.vcxproj.filtersnu[PK!.><`` k`csdet/csdet.cnu[PK!C)icsdet/readme.txtnu[PK!<ڗ  rdate/Makefilenu[PK!`֌-'' xdate/date.cnu[PK!5Y&&Πdate/date.vcxprojnu[PK!?date/Makefile.innu[PK! 22 date/uprint.cnu[PK!(c  date/date.slnnu[PK! u5 5 date/readme.txtnu[PK!lȸ ldate/uprint.hnu[PK!DO::date/date.vcxproj.filtersnu[PK!dd uresb/resources.vcxproj.filtersnu[PK!wkuresb/Makefilenu[PK!Βw22uresb/uresb.slnnu[PK!SǶ!!>uresb/resources.vcxprojnu[PK!E_Db;#uresb/resources.maknu[PK!R 8&uresb/sr.txtnu[PK!e?Y].uresb/root.txtnu[PK!c''c6uresb/uresb.vcxprojnu[PK!,p5*5* C^uresb/uresb.cnu[PK! uresb/en.txtnu[PK!W  uresb/readme.txtnu[PK!:Wnnuresb/uresb.vcxproj.filtersnu[PK!~koo msgfmt/util.hnu[PK!?MVqqbmsgfmt/Makefilenu[PK!##msgfmt/answers/main_3.cppnu[PK!h~msgfmt/answers/main_2.cppnu[PK!`__رmsgfmt/answers/main_1.cppnu[PK!msgfmt/answers/main_0.cppnu[PK!8a&&Umsgfmt/msgfmt.vcxprojnu[PK!numfmt/main.cppnu[PK!B @cnumfmt/capi.cnu[PK!/.Oi1nnumfmt/util.cppnu[PK!cGu u ~numfmt/readme.txtnu[PK!oo:udata/reader.vcxproj.filtersnu[PK!Rtudata/Makefilenu[PK!0'%'%ɓudata/writer.vcxprojnu[PK!mە\ 4udata/reader.cnu[PK!wD'D'udata/reader.vcxprojnu[PK!7Zudata/udata.slnnu[PK!Yoo\udata/writer.vcxproj.filtersnu[PK!P|g g udata/writer.cnu[PK!+:  udata/readme.txtnu[PK! ) dtptngsample/dtptngsample.vcxproj.filtersnu[PK!#-ff! dtptngsample/dtptngsample.vcxprojnu[PK!$[2 dtptngsample/dtptngsample.cppnu[PK!O ugrep/ugrep.slnnu[PK!ޅpT ugrep/Makefilenu[PK!@-u(u(3W ugrep/ugrep.vcxprojnu[PK!SQ`pp ugrep/ugrep.vcxproj.filtersnu[PK!:;99 ugrep/ugrep.cppnu[PK!9 9 ~ ugrep/readme.txtnu[PK!6. rules.mknu[PK![MME ustring/Makefilenu[PK!ʹ ustring/ustring.slnnu[PK!ʊYrr ustring/ustring.vcxproj.filtersnu[PK! %% ustring/ustring.vcxprojnu[PK!Duu ustring/readme.txtnu[PK!%lv^^ ustring/ustring.cppnu[PK!>7[nnf strsrch/Makefilenu[PK!r{'{'bi strsrch/strsrch.vcxprojnu[PK!:%%$ strsrch/strsrch.cppnu[PK!=G strsrch/strsrch.slnnu[PK!$rr strsrch/strsrch.vcxproj.filtersnu[PK!\p  strsrch/readme.txtnu[PK!y   readme.txtnu[PK!f` ` cal/Makefilenu[PK!*YY C cal/cal.cnu[PK!'%%%5 cal/cal.vcxprojnu[PK!99.[ cal/cal.vcxproj.filtersnu[PK!7_ cal/Makefile.innu[PK! f cal/uprint.cnu[PK!#FI n cal/cal.slnnu[PK!Ts cal/readme.txtnu[PK!;V | cal/uprint.hnu[PK!˰ props/props.slnnu[PK!/Qpp props/props.vcxproj.filtersnu[PK!jj props/Makefilenu[PK!.**Q props/props.vcxprojnu[PK!Fyii5 props/readme.txtnu[PK!y  ޿ props/props.cppnu[PK!3{z z / layout/LayoutSample.rcnu[PK!U`PAA layout/FontTableCache.hnu[PK!)Ӏ w layout/Makefilenu[PK!nUUb layout/paragraph.cppnu[PK!:LL layout/GDIFontMap.cppnu[PK! layout/rsurface.cppnu[PK! !! layout/cgnomelayout.cnu[PK!d ܫ0 layout/gdiglue.cppnu[PK!q]227 layout/GnomeGUISupport.cppnu[PK!Ġ:: < layout/cmaps.hnu[PK!rrD layout/gsupport.hnu[PK!HIi!!8F layout/gnomelayout.cppnu[PK!lB̆{h layout/arraymem.hnu[PK!8^^Bk layout/GDIGUISupport.cppnu[PK!1nS n layout/Makefile.innu[PK!;[z layout/Sample.txtnu[PK!>b&b& layout/GDIFontInstance.cppnu[PK!ig layout/UnicodeReader.hnu[PK!}m layout/ucreader.cppnu[PK!|Ԯ layout/GnomeGUISupport.hnu[PK!ߛ__ݲ layout/RenderingSurface.hnu[PK!7rzz layout/GUISupport.hnu[PK!a“B layout/GDIGUISupport.hnu[PK!˘o= layout/pflow.hnu[PK!}L'L'' layout/clayout.cnu[PK!O܈ layout/FontMap.Gnomenu[PK!羵 layout/GnomeFontInstance.cppnu[PK! layout/resource.hnu[PK!ʪf((L layout/GnomeFontInstance.hnu[PK!cԧjj layout/UnicodeReader.cppnu[PK! ў$p& layout/ScriptCompositeFontInstance.hnu[PK!Z!b? layout/layout.slnnu[PK![ &UD layout/GnomeFontMap.cppnu[PK!OP/J layout/gdiglue.hnu[PK!Cv!FN layout/rsurface.hnu[PK!?gw< < P layout/layout.vcxproj.filtersnu[PK!r  ] layout/Surface.hnu[PK!W644g_ layout/layout.vcxprojnu[PK!l8rJ layout/FontMap.GDInu[PK!96 layout/paragraph.hnu[PK!B70'0'0 layout/layout.cppnu[PK!f layout/gnomeglue.cppnu[PK!cf%%w layout/pflow.cnu[PK!ihh layout/GDIFontInstance.hnu[PK!a &wlayout/ScriptCompositeFontInstance.cppnu[PK!4^layout/ucreader.hnu[PK!yh~layout/GnomeFontMap.hnu[PK!ߝ layout/sfnt.hnu[PK!t]]u)layout/FontMap.cppnu[PK!Sޯ{ { Glayout/FontTableCache.cppnu[PK!ϒP44Playout/cmaps.cppnu[PK!A5/3||Lflayout/Surface.cppnu[PK!pELL jlayout/readme.htmlnu[PK!|>layout/gnomeglue.hnu[PK!M~__layout/FontMap.hnu[PK!NSlayout/GDIFontMap.hnu[PK!k±-dtitvfmtsample/dtitvfmtsample.vcxproj.filtersnu[PK!j%dtitvfmtsample/dtitvfmtsample.vcxprojnu[PK!޿4!dtitvfmtsample/dtitvfmtsample.cppnu[PKS