ICU-22691 Delete abandoned sample code.

This commit is contained in:
Fredrik Roubert 2024-03-19 16:34:06 +01:00 committed by Fredrik Roubert
parent b3032aba0c
commit 2a6bc212d4
225 changed files with 3 additions and 22465 deletions

View file

@ -2,12 +2,6 @@ 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}") = "cal", "..\samples\cal\cal.vcxproj", "{F7659D77-09CF-4FE9-ACEE-927287AA9509}"
ProjectSection(ProjectDependencies) = postProject
{0178B127-6269-407D-B112-93877BB62776} = {0178B127-6269-407D-B112-93877BB62776}
{73C0A65B-D1F2-4DE1-B3A6-15DAD2C23F3D} = {73C0A65B-D1F2-4DE1-B3A6-15DAD2C23F3D}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cintltst", "..\test\cintltst\cintltst.vcxproj", "{3D1246AE-1B32-479B-BECA-AEFA97BE2321}"
ProjectSection(ProjectDependencies) = postProject
{0178B127-6269-407D-B112-93877BB62776} = {0178B127-6269-407D-B112-93877BB62776}
@ -27,12 +21,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ctestfw", "..\tools\ctestfw
{73C0A65B-D1F2-4DE1-B3A6-15DAD2C23F3D} = {73C0A65B-D1F2-4DE1-B3A6-15DAD2C23F3D}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "date", "..\samples\date\date.vcxproj", "{38B5751A-C6F9-4409-950C-F4F9DA17275F}"
ProjectSection(ProjectDependencies) = postProject
{0178B127-6269-407D-B112-93877BB62776} = {0178B127-6269-407D-B112-93877BB62776}
{73C0A65B-D1F2-4DE1-B3A6-15DAD2C23F3D} = {73C0A65B-D1F2-4DE1-B3A6-15DAD2C23F3D}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "derb", "..\tools\genrb\derb.vcxproj", "{D3065ADB-8820-4CC7-9B6C-9510833961A3}"
ProjectSection(ProjectDependencies) = postProject
{C2B04507-2521-4801-BF0D-5FD79D6D518C} = {C2B04507-2521-4801-BF0D-5FD79D6D518C}
@ -212,18 +200,6 @@ Global
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F7659D77-09CF-4FE9-ACEE-927287AA9509}.Debug|ARM.ActiveCfg = Debug|Win32
{F7659D77-09CF-4FE9-ACEE-927287AA9509}.Debug|ARM64.ActiveCfg = Debug|Win32
{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|ARM.ActiveCfg = Release|Win32
{F7659D77-09CF-4FE9-ACEE-927287AA9509}.Release|ARM64.ActiveCfg = Release|Win32
{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
{3D1246AE-1B32-479B-BECA-AEFA97BE2321}.Debug|ARM.ActiveCfg = Debug|ARM
{3D1246AE-1B32-479B-BECA-AEFA97BE2321}.Debug|ARM.Build.0 = Debug|ARM
{3D1246AE-1B32-479B-BECA-AEFA97BE2321}.Debug|ARM64.ActiveCfg = Debug|ARM64
@ -272,18 +248,6 @@ Global
{ECA6B435-B4FA-4F9F-BF95-F451D078FC47}.Release|Win32.Build.0 = Release|Win32
{ECA6B435-B4FA-4F9F-BF95-F451D078FC47}.Release|x64.ActiveCfg = Release|x64
{ECA6B435-B4FA-4F9F-BF95-F451D078FC47}.Release|x64.Build.0 = Release|x64
{38B5751A-C6F9-4409-950C-F4F9DA17275F}.Debug|ARM.ActiveCfg = Debug|Win32
{38B5751A-C6F9-4409-950C-F4F9DA17275F}.Debug|ARM64.ActiveCfg = Debug|Win32
{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|ARM.ActiveCfg = Release|Win32
{38B5751A-C6F9-4409-950C-F4F9DA17275F}.Release|ARM64.ActiveCfg = Release|Win32
{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
{D3065ADB-8820-4CC7-9B6C-9510833961A3}.Debug|ARM.ActiveCfg = Debug|ARM
{D3065ADB-8820-4CC7-9B6C-9510833961A3}.Debug|ARM.Build.0 = Debug|ARM
{D3065ADB-8820-4CC7-9B6C-9510833961A3}.Debug|ARM64.ActiveCfg = Debug|ARM64

View file

@ -344,8 +344,6 @@ ucnv_compareNames(const char *name1, const char *name2);
* other than its an alias starting with the letters "cp". Please do not
* associate any meaning to these aliases.</p>
*
* \snippet samples/ucnv/convsamp.cpp ucnv_open
*
* @param converterName Name of the coded character set table.
* This may have options appended to the string.
* IANA alias character set names, IBM CCSIDs starting with "ibm-",
@ -1986,7 +1984,6 @@ ucnv_usesFallback(const UConverter *cnv);
* instead of the input signature bytes.
* <p>
* Usage:
* \snippet samples/ucnv/convsamp.cpp ucnv_detectUnicodeSignature
*
* @param source The source string in which the signature should be detected.
* @param sourceLength Length of the input string, or -1 if terminated with a NUL byte.

View file

@ -1355,8 +1355,7 @@ AC_CONFIG_FILES([icudefs.mk \
test/perf/utrie2perf/Makefile \
test/perf/leperf/Makefile \
test/fuzzer/Makefile \
samples/Makefile samples/date/Makefile \
samples/cal/Makefile samples/layout/Makefile])
samples/Makefile])
AC_OUTPUT
if test -z "$PYTHON";

View file

@ -344,11 +344,6 @@ public:
* @param status output param set to success/failure code on exit
* @return a date time interval formatter which the caller owns.
* @stable ICU 4.0
* <p>
* <h4>Sample code</h4>
* \snippet samples/dtitvfmtsample/dtitvfmtsample.cpp dtitvfmtPreDefined1
* \snippet samples/dtitvfmtsample/dtitvfmtsample.cpp dtitvfmtPreDefined
* <p>
*/
static DateIntervalFormat* U_EXPORT2 createInstance(
@ -410,11 +405,6 @@ public:
* @param status output param set to success/failure code on exit
* @return a date time interval formatter which the caller owns.
* @stable ICU 4.0
* <p>
* <h4>Sample code</h4>
* \snippet samples/dtitvfmtsample/dtitvfmtsample.cpp dtitvfmtPreDefined1
* \snippet samples/dtitvfmtsample/dtitvfmtsample.cpp dtitvfmtCustomized
* <p>
*/
static DateIntervalFormat* U_EXPORT2 createInstance(
const UnicodeString& skeleton,

View file

@ -211,11 +211,6 @@ public:
* @return conflicting status. The value could be UDATPG_NO_CONFLICT,
* UDATPG_BASE_CONFLICT or UDATPG_CONFLICT.
* @stable ICU 3.8
* <p>
* <h4>Sample code</h4>
* \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1
* \snippet samples/dtptngsample/dtptngsample.cpp addPatternExample
* <p>
*/
UDateTimePatternConflict addPattern(const UnicodeString& pattern,
UBool override,
@ -388,11 +383,6 @@ public:
* @return bestPattern
* The best pattern found from the given skeleton.
* @stable ICU 3.8
* <p>
* <h4>Sample code</h4>
* \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1
* \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample
* <p>
*/
UnicodeString getBestPattern(const UnicodeString& skeleton, UErrorCode& status);
@ -436,11 +426,6 @@ public:
* which must not indicate a failure before the function call.
* @return pattern adjusted to match the skeleton fields widths and subtypes.
* @stable ICU 3.8
* <p>
* <h4>Sample code</h4>
* \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1
* \snippet samples/dtptngsample/dtptngsample.cpp replaceFieldTypesExample
* <p>
*/
UnicodeString replaceFieldTypes(const UnicodeString& pattern,
const UnicodeString& skeleton,

View file

@ -190,11 +190,6 @@ public:
* @param status output param set to success/failure code on exit, which
* must not indicate a failure before the function call.
* @stable ICU 4.0
* <p>
* <h4>Sample code</h4>
* \snippet samples/plurfmtsample/plurfmtsample.cpp PluralFormatExample1
* \snippet samples/plurfmtsample/plurfmtsample.cpp PluralFormatExample
* <p>
*/
PluralFormat(const Locale& locale, const PluralRules& rules, UErrorCode& status);

View file

@ -22,8 +22,8 @@ include @platform_make_fragment@
## Files to remove for 'make clean'
CLEANFILES = *~
SUBDIRS = date cal
ALLSUBDIRS = cal citer coll csdet date datecal ufortune uresb datefmt msgfmt numfmt props strsrch translit uciter8 ucnv udata ustring dtitvfmtsample dtptngsample plurfmtsample
SUBDIRS =
ALLSUBDIRS = coll strsrch translit
## List of phony targets
.PHONY : all all-local all-recursive install install-local \

View file

@ -2,56 +2,14 @@ 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
@ -60,86 +18,6 @@ Global
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
@ -156,28 +34,6 @@ Global
{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
@ -186,38 +42,6 @@ Global
{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
@ -226,38 +50,6 @@ Global
{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

View file

@ -42,120 +42,18 @@ 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% =========================================================================
@ -168,43 +66,6 @@ if ERRORLEVEL 1 goto :SampleError
%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% =========================================================================
@ -212,22 +73,6 @@ 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

View file

@ -1,25 +0,0 @@
# Copyright (C) 2016 and later: Unicode, Inc. and others.
# License & terms of use: http://www.unicode.org/copyright.html
#
# 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

View file

@ -1,150 +0,0 @@
/*
*******************************************************************************
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* Copyright (C) 2002-2003, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
*/
#include <stdio.h>
#include <unicode/brkiter.h>
#include <stdlib.h>
using namespace icu;
U_CFUNC int c_main();
void printUnicodeString(const UnicodeString &s) {
char charBuf[1000];
s.extract(0, s.length(), charBuf, sizeof(charBuf) - 1, nullptr);
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()
{
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();
}

View file

@ -1,25 +0,0 @@
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

View file

@ -1,153 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{DEEADF02-9C14-4854-A395-E505D2904D65}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<!-- The following import will include the 'default' configuration options for VS projects. -->
<Import Project="..\..\allinone\Build.Windows.ProjectConfiguration.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x86\Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x86\Release\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x86\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x86\Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
</PropertyGroup>
<!-- Options that are common to *all* project configurations -->
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Midl>
<TypeLibraryName>.\x86\Release/break.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeaderOutputFile>.\x86\Release/break.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\x86\Release/</AssemblerListingLocation>
<ObjectFileName>.\x86\Release/</ObjectFileName>
<ProgramDataBaseFileName>.\x86\Release/</ProgramDataBaseFileName>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>icuuc.lib;icuin.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x86\Release/break.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ProgramDatabaseFile>.\x86\Release/break.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TypeLibraryName>.\x64\Release/break.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeaderOutputFile>.\x64\Release/break.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\x64\Release/</AssemblerListingLocation>
<ObjectFileName>.\x64\Release/</ObjectFileName>
<ProgramDataBaseFileName>.\x64\Release/</ProgramDataBaseFileName>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>icuuc.lib;icuin.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x64\Release/break.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ProgramDatabaseFile>.\x64\Release/break.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Midl>
<TypeLibraryName>.\x86\Debug/break.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeaderOutputFile>.\x86\Debug/break.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\x86\Debug/</AssemblerListingLocation>
<ObjectFileName>.\x86\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\x86\Debug/</ProgramDataBaseFileName>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>icuucd.lib;icuind.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x86\Debug/break.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>.\x86\Debug/break.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TypeLibraryName>.\x64\Debug/break.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeaderOutputFile>.\x64\Debug/break.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\x64\Debug/</AssemblerListingLocation>
<ObjectFileName>.\x64\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\x64\Debug/</ProgramDataBaseFileName>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>icuucd.lib;icuind.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x64\Debug/break.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>.\x64\Debug/break.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="break.cpp" />
<ClCompile Include="ubreak.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{3cfd1084-1652-4648-bb97-9b38a2780005}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{34cb1edc-aa5a-4702-b867-a867ebe8496c}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{6aea4120-7995-4705-b3b7-7013af485c18}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="break.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ubreak.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View file

@ -1,63 +0,0 @@
Copyright (C) 2016 and later: Unicode, Inc. and others.
License & terms of use: http://www.unicode.org/copyright.html
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 <icu directory>/source
runConfigureICU <platform-name> --prefix <icu install directory> [other options]
gmake all
2. Install ICU,
gmake install
3. Compile
cd <icu directory>/source/samples/break
gmake ICU_PREFIX=<icu install directory)
To Run on Unixes
cd <icu directory>/source/samples/break
gmake ICU_PREFIX=<icu install directory> check
-or-
export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
break
Note: The name of the LD_LIBRARY_PATH variable is different on some systems.
If in doubt, run the sample using "gmake check", and note the name of
the variable that is used there. LD_LIBRARY_PATH is the correct name
for Linux and Solaris.

View file

@ -1,134 +0,0 @@
/*
*******************************************************************************
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* Copyright (C) 2002, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
*/
#include <stdio.h>
#include <stdlib.h>
#include <unicode/ustring.h>
#include <unicode/ubrk.h>
U_CFUNC int c_main(void);
void printTextRange(UChar* str, int32_t start, int32_t end)
{
char charBuf[1000];
UChar savedEndChar;
savedEndChar = str[end];
str[end] = 0;
u_austrncpy(charBuf, str+start, sizeof(charBuf)-1);
charBuf[sizeof(charBuf)-1]=0;
printf("string[%2d..%2d] \"%s\"\n", start, end-1, charBuf);
str[end] = savedEndChar;
}
/* Print each element in order: */
void printEachForward( UBreakIterator* boundary, UChar* str) {
int32_t end;
int32_t start = ubrk_first(boundary);
for (end = ubrk_next(boundary); end != UBRK_DONE; start = end, end =
ubrk_next(boundary)) {
printTextRange(str, start, end );
}
}
/* Print each element in reverse order: */
void printEachBackward( UBreakIterator* boundary, UChar* str) {
int32_t start;
int32_t end = ubrk_last(boundary);
for (start = ubrk_previous(boundary); start != UBRK_DONE; end = start,
start =ubrk_previous(boundary)) {
printTextRange( str, start, end );
}
}
/* Print first element */
void printFirst(UBreakIterator* boundary, UChar* str) {
int32_t end;
int32_t start = ubrk_first(boundary);
end = ubrk_next(boundary);
printTextRange( str, start, end );
}
/* Print last element */
void printLast(UBreakIterator* boundary, UChar* str) {
int32_t start;
int32_t end = ubrk_last(boundary);
start = ubrk_previous(boundary);
printTextRange(str, start, end );
}
/* Print the element at a specified position */
void printAt(UBreakIterator* boundary, int32_t pos , UChar* str) {
int32_t start;
int32_t end = ubrk_following(boundary, pos);
start = ubrk_previous(boundary);
printTextRange(str, start, end );
}
/* Creating and using text boundaries*/
int c_main( void ) {
UBreakIterator *boundary;
char cStringToExamine[] = "Aaa bbb ccc. Ddd eee fff.";
UChar stringToExamine[sizeof(cStringToExamine)+1];
UErrorCode status = U_ZERO_ERROR;
printf("\n\n"
"C Boundary Analysis\n"
"-------------------\n\n");
printf("Examining: %s\n", cStringToExamine);
u_uastrcpy(stringToExamine, cStringToExamine);
/*print each sentence in forward and reverse order*/
boundary = ubrk_open(UBRK_SENTENCE, "en_us", stringToExamine,
-1, &status);
if (U_FAILURE(status)) {
printf("ubrk_open error: %s\n", u_errorName(status));
exit(1);
}
printf("\n----- Sentence Boundaries, forward: -----------\n");
printEachForward(boundary, stringToExamine);
printf("\n----- Sentence Boundaries, backward: ----------\n");
printEachBackward(boundary, stringToExamine);
ubrk_close(boundary);
/*print each word in order*/
boundary = ubrk_open(UBRK_WORD, "en_us", stringToExamine,
u_strlen(stringToExamine), &status);
printf("\n----- Word Boundaries, forward: -----------\n");
printEachForward(boundary, stringToExamine);
printf("\n----- Word Boundaries, backward: ----------\n");
printEachBackward(boundary, stringToExamine);
/*print first element*/
printf("\n----- first: -------------\n");
printFirst(boundary, stringToExamine);
/*print last element*/
printf("\n----- last: --------------\n");
printLast(boundary, stringToExamine);
/*print word at charpos 10 */
printf("\n----- at pos 10: ---------\n");
printAt(boundary, 10 , stringToExamine);
ubrk_close(boundary);
printf("\nEnd of C boundary analysis\n");
return 0;
}

View file

@ -1,78 +0,0 @@
## Copyright (C) 2016 and later: Unicode, Inc. and others.
## License & terms of use: http://www.unicode.org/copyright.html
##
## 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

View file

@ -1,766 +0,0 @@
/*
***********************************************************************
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
***********************************************************************
**********************************************************************
* 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 <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "unicode/uloc.h"
#include "unicode/udat.h"
#include "unicode/ucal.h"
#include "unicode/ustring.h"
#include "unicode/uclean.h"
#include "uprint.h"
#if UCONFIG_NO_FORMATTING
int main(int argc, char **argv)
{
printf("%s: Sorry, UCONFIG_NO_FORMATTING was turned on (see uconfig.h). No formatting can be done. \n", argv[0]);
return 0;
}
#else
/* Protos */
static void usage(void);
static void version(void);
static void cal(int32_t month, int32_t year,
UBool useLongNames, UErrorCode *status);
static void get_symbols(const UDateFormat *fmt,
UDateFormatSymbolType type,
UChar *array[],
int32_t arrayLength,
int32_t lowestIndex,
int32_t firstIndex,
UErrorCode *status);
static void free_symbols(UChar *array[],
int32_t arrayLength);
static void get_days(const UDateFormat *fmt,
UChar *days [], UBool useLongNames,
int32_t fdow, UErrorCode *status);
static void free_days(UChar *days[]);
static void get_months(const UDateFormat *fmt,
UChar *months [], UBool useLongNames,
UErrorCode *status);
static void free_months(UChar *months[]);
static void indent(int32_t count, FILE *f);
static void print_days(UChar *days [], FILE *f, UErrorCode *status);
static void print_month(UCalendar *c,
UChar *days [],
UBool useLongNames, int32_t fdow,
UErrorCode *status);
static void print_year(UCalendar *c,
UChar *days [], UChar *months [],
UBool useLongNames, int32_t fdow,
UErrorCode *status);
/* The version of cal */
#define CAL_VERSION "1.0"
/* Number of days in a week */
#define DAY_COUNT 7
/* Number of months in a year (yes, 13) */
#define MONTH_COUNT 13
/* Separation between months in year view */
#define MARGIN_WIDTH 4
/* Size of stack buffers */
#define BUF_SIZE 64
/* Patterm string - "MMM yyyy" */
static const UChar sShortPat [] = { 0x004D, 0x004D, 0x004D, 0x0020,
0x0079, 0x0079, 0x0079, 0x0079 };
/* Pattern string - "MMMM yyyy" */
static const UChar sLongPat [] = { 0x004D, 0x004D, 0x004D, 0x004D, 0x0020,
0x0079, 0x0079, 0x0079, 0x0079 };
int
main(int argc,
char **argv)
{
int printUsage = 0;
int printVersion = 0;
UBool useLongNames = 0;
int optInd = 1;
char *arg;
int32_t month = -1, year = -1;
UErrorCode status = U_ZERO_ERROR;
/* parse the options */
for(optInd = 1; optInd < argc; ++optInd) {
arg = argv[optInd];
/* version info */
if(strcmp(arg, "-v") == 0 || strcmp(arg, "--version") == 0) {
printVersion = 1;
}
/* usage info */
else if(strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) {
printUsage = 1;
}
/* use long day names */
else if(strcmp(arg, "-l") == 0 || strcmp(arg, "--long") == 0) {
useLongNames = 1;
}
/* POSIX.1 says all arguments after -- are not options */
else if(strcmp(arg, "--") == 0) {
/* skip the -- */
++optInd;
break;
}
/* unrecognized option */
else if(strncmp(arg, "-", strlen("-")) == 0) {
printf("cal: invalid option -- %s\n", arg+1);
printUsage = 1;
}
/* done with options, display cal */
else {
break;
}
}
/* Get the month and year to display, if specified */
if(optInd != argc) {
/* Month and year specified */
if(argc - optInd == 2) {
sscanf(argv[optInd], "%d", (int*)&month);
sscanf(argv[optInd + 1], "%d", (int*)&year);
/* Make sure the month value is legal */
if(month < 0 || month > 12) {
printf("icucal: Bad value for month -- %d\n", (int)month);
/* Display usage */
printUsage = 1;
}
/* Adjust because months are 0-based */
--month;
}
/* Only year specified */
else {
sscanf(argv[optInd], "%d", (int*)&year);
}
}
/* print usage info */
if(printUsage) {
usage();
return 0;
}
/* print version info */
if(printVersion) {
version();
return 0;
}
/* print the cal */
cal(month, year, useLongNames, &status);
/* ICU cleanup. Deallocate any memory ICU may be holding. */
u_cleanup();
return (U_FAILURE(status) ? 1 : 0);
}
/* Usage information */
static void
usage(void)
{
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(void)
{
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

View file

@ -1,25 +0,0 @@
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

View file

@ -1,157 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{F7659D77-09CF-4FE9-ACEE-927287AA9509}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<!-- The following import will include the 'default' configuration options for VS projects. -->
<Import Project="..\..\allinone\Build.Windows.ProjectConfiguration.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x86\Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x86\Release\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x86\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x86\Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
</PropertyGroup>
<!-- Options that are common to *all* project configurations -->
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Midl>
<TypeLibraryName>.\x86\Release/cal.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeaderOutputFile>.\x86\Release/cal.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\x86\Release/</AssemblerListingLocation>
<ObjectFileName>.\x86\Release/</ObjectFileName>
<ProgramDataBaseFileName>.\x86\Release/</ProgramDataBaseFileName>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>icuuc.lib;icuin.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x86\Release/cal.exe</OutputFile>
<AdditionalLibraryDirectories>../../../lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ProgramDatabaseFile>.\x86\Release/cal.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TypeLibraryName>.\x64\Release/cal.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeaderOutputFile>.\x64\Release/cal.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\x64\Release/</AssemblerListingLocation>
<ObjectFileName>.\x64\Release/</ObjectFileName>
<ProgramDataBaseFileName>.\x64\Release/</ProgramDataBaseFileName>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>icuuc.lib;icuin.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x64\Release/cal.exe</OutputFile>
<AdditionalLibraryDirectories>../../../lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ProgramDatabaseFile>.\x64\Release/cal.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Midl>
<TypeLibraryName>.\x86\Debug/cal.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeaderOutputFile>.\x86\Debug/cal.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\x86\Debug/</AssemblerListingLocation>
<ObjectFileName>.\x86\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\x86\Debug/</ProgramDataBaseFileName>
<BrowseInformation>true</BrowseInformation>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>icuucd.lib;icuind.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x86\Debug/cal.exe</OutputFile>
<AdditionalLibraryDirectories>../../../lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>.\x86\Debug/cal.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TypeLibraryName>.\x64\Debug/cal.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeaderOutputFile>.\x64\Debug/cal.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\x64\Debug/</AssemblerListingLocation>
<ObjectFileName>.\x64\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\x64\Debug/</ProgramDataBaseFileName>
<BrowseInformation>true</BrowseInformation>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>icuucd.lib;icuind.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x64\Debug/cal.exe</OutputFile>
<AdditionalLibraryDirectories>../../../lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>.\x64\Debug/cal.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="cal.c" />
<ClCompile Include="uprint.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="uprint.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{3e036a59-b898-49e5-9d06-4878387b4a02}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{ace55cd2-56c0-4c6d-965b-8866c5396b04}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{823558d3-c303-4670-9e92-d8f5c02e39e2}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="cal.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="uprint.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="uprint.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View file

@ -1,61 +0,0 @@
Copyright (C) 2016 and later: Unicode, Inc. and others.
License & terms of use: http://www.unicode.org/copyright.html
Copyright (c) 2002-2005, International Business Machines Corporation and others. All Rights Reserved.
icucal: a sample program which displays the calendar.
This sample demonstrates
Formatting a calendar
Outputting text in the default codepage to the console
Files:
cal.c Main source file
uprint.h codepage output convenience header
uprint.h codepage output convenience implementation
cal.sln Windows MSVC workspace. Double-click this to get started.
cal.vcproj Windows MSVC project file
To Build icucal on Windows
1. Install and build ICU
2. In MSVC, open the workspace file icu\samples\cal\cal.sln
3. Choose a Debug or Release build.
4. Build.
To Run on Windows
1. Start a command shell window
2. Add ICU's bin directory to the path, e.g.
set PATH=c:\icu\bin;%PATH%
(Use the path to where ever ICU is on your system.)
3. cd into the cal directory, e.g.
cd c:\icu\source\samples\cal\debug
4. Run it
cal
To Build on Unixes
1. Build ICU. icucal is built automatically by default unless samples are turned off.
Specify an ICU install directory when running configure,
using the --prefix option. The steps to build ICU will look something
like this:
cd <icu directory>/source
runConfigureICU <platform-name> --prefix <icu install directory> [other options]
gmake all
2. Install ICU,
gmake install
To Run on Unixes
cd <icu directory>/source/samples/cal
gmake check
-or-
export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
cal
Note: The name of the LD_LIBRARY_PATH variable is different on some systems.
If in doubt, run the sample using "gmake check", and note the name of
the variable that is used there. LD_LIBRARY_PATH is the correct name
for Linux and Solaris.

View file

@ -1,80 +0,0 @@
/*
***********************************************************************
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
***********************************************************************
**********************************************************************
* 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 <stdbool.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);
}

View file

@ -1,30 +0,0 @@
/*
***********************************************************************
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
***********************************************************************
**********************************************************************
* Copyright (C) 1998-2004, International Business Machines Corporation
* and others. All Rights Reserved.
**********************************************************************
*
* File uprint.h
*
* Modification History:
*
* Date Name Description
* 06/14/99 stephen Creation.
*******************************************************************************
*/
#ifndef UPRINT_H
#define UPRINT_H 1
#include <stdio.h>
#include "unicode/utypes.h"
/* Print a ustring to the specified FILE* in the default codepage */
U_CFUNC void uprint(const UChar *s, FILE *f, UErrorCode *status);
#endif /* ! UPRINT_H */

View file

@ -1,27 +0,0 @@
# Copyright (C) 2016 and later: Unicode, Inc. and others.
# License & terms of use: http://www.unicode.org/copyright.html
#
# 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

View file

@ -1,92 +0,0 @@
/*
*******************************************************************************
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* Copyright (C) 2003-2004, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
*/
#include <unicode/unistr.h>
#include <unicode/ustdio.h>
#include <unicode/brkiter.h>
#include <stdlib.h>
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()
{
UFILE *out;
UErrorCode status = U_ZERO_ERROR;
out = u_finit(stdout, nullptr, nullptr);
if(!out) {
fprintf(stderr, "Could not initialize (finit()) over stdout! \n");
return 1;
}
ucnv_setFromUCallBack(u_fgetConverter(out), UCNV_FROM_U_CALLBACK_ESCAPE,
nullptr, nullptr, nullptr, &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" */
char16_t lowercase[] = {0x69, 0x73, 0x74, 0x61, 0x6e, 0x62, 0x75, 0x6c, 0};
/* uppercase = "LATIN CAPITAL I WITH DOT ABOVE STANBUL" */
char16_t 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;
}

View file

@ -1,25 +0,0 @@
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

View file

@ -1,151 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{2316BE8C-189D-4C8B-B506-9D9EE25AC46D}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<!-- The following import will include the 'default' configuration options for VS projects. -->
<Import Project="..\..\allinone\Build.Windows.ProjectConfiguration.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x86\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x86\Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x86\Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x86\Release\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
</PropertyGroup>
<!-- Options that are common to *all* project configurations -->
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Midl>
<TypeLibraryName>.\x86\Debug/case.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeaderOutputFile>.\x86\Debug/case.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\x86\Debug/</AssemblerListingLocation>
<ObjectFileName>.\x86\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\x86\Debug/</ProgramDataBaseFileName>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>icuucd.lib;icuind.lib;icuiod.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x86\Debug/case.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ProgramDatabaseFile>.\x86\Debug/case.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TypeLibraryName>.\x64\Debug/case.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeaderOutputFile>.\x64\Debug/case.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\x64\Debug/</AssemblerListingLocation>
<ObjectFileName>.\x64\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\x64\Debug/</ProgramDataBaseFileName>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>icuucd.lib;icuind.lib;icuiod.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x64\Debug/case.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>.\x64\Debug/case.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Midl>
<TypeLibraryName>.\x86\Release/case.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeaderOutputFile>.\x86\Release/case.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\x86\Release/</AssemblerListingLocation>
<ObjectFileName>.\x86\Release/</ObjectFileName>
<ProgramDataBaseFileName>.\x86\Release/</ProgramDataBaseFileName>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>icuuc.lib;icuin.lib;icuio.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x86\Release/case.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ProgramDatabaseFile>.\x86\Release/case.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TypeLibraryName>.\x64\Release/case.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeaderOutputFile>.\x64\Release/case.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\x64\Release/</AssemblerListingLocation>
<ObjectFileName>.\x64\Release/</ObjectFileName>
<ProgramDataBaseFileName>.\x64\Release/</ProgramDataBaseFileName>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>icuuc.lib;icuin.lib;icuio.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x64\Release/case.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ProgramDatabaseFile>.\x64\Release/case.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="case.cpp" />
<ClCompile Include="ucase.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{43ee3899-8fc9-43ee-afb1-56fc646637b4}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{f8bfa07a-99cc-427e-900b-d224ca9d1a65}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{4a483140-b33a-4ddb-a2b5-e481b417d590}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="case.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ucase.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View file

@ -1,64 +0,0 @@
Copyright (C) 2016 and later: Unicode, Inc. and others.
License & terms of use: http://www.unicode.org/copyright.html
Copyright (c) 2003-2005, International Business Machines Corporation and others. All Rights Reserved.
case: case mapping
This sample demonstrates
Using ICU to convert between different cases
Files:
case.cpp Main source file in C++
ucase.c Main source file in C
case.sln Windows MSVC workspace. Double-click this to get started.
case.vcproj Windows MSVC project file
To Build case on Windows
1. Install and build ICU
2. In MSVC, open the solution file icu\samples\case\case.sln
(or, use the workspace All, in icu\samples\all\all.sln )
3. Choose a Debug or Release build.
4. Build.
To Run on Windows
1. Start a command shell window
2. Add ICU's bin directory to the path, e.g.
set PATH=c:\icu\bin;%PATH%
(Use the path to where ever ICU is on your system.)
3. cd into the case directory, e.g.
cd c:\icu\source\samples\case\debug
4. Run it
case
To Build on Unixes
1. Build ICU.
Specify an ICU install directory when running configure,
using the --prefix option. The steps to build ICU will look something
like this:
cd <icu directory>/source
runConfigureICU <platform-name> --prefix <icu install directory> [other options]
gmake all
2. Install ICU,
gmake install
3. Compile
cd <icu directory>/source/samples/case
gmake ICU_PREFIX=<icu install directory)
To Run on Unixes
cd <icu directory>/source/samples/case
gmake ICU_PREFIX=<icu install directory> check
-or-
export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
case
Note: The name of the LD_LIBRARY_PATH variable is different on some systems.
If in doubt, run the sample using "gmake check", and note the name of
the variable that is used there. LD_LIBRARY_PATH is the correct name
for Linux and Solaris.

View file

@ -1,94 +0,0 @@
/*
*******************************************************************************
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* Copyright (C) 2003-2004, International Business Machines
* Corporation and others. All Rights Reserved.
*
****
*
* Case folding examples, in C
*
*******************************************************************************
*/
#include <stdio.h>
#include <stdlib.h>
#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;
}

View file

@ -1,25 +0,0 @@
# Copyright (C) 2016 and later: Unicode, Inc. and others.
# License & terms of use: http://www.unicode.org/copyright.html
#
# 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

View file

@ -1,206 +0,0 @@
/*
*******************************************************************************
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* 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 <stdio.h>
#include <unicode/brkiter.h>
#include <unicode/ustdio.h>
#include <stdlib.h>
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", (char16_t) 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 char16_t *testText = testString.getTerminatedBuffer();
UCharCharacterIterator iter(testText, u_strlen(testText));
UCharCharacterIterator* test2 = 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 = ");
char16_t 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 char16_t *testText = testString.getTerminatedBuffer();
StringCharacterIterator iter(testText, u_strlen(testText));
StringCharacterIterator* test2 = 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: ");
char16_t 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()
{
UErrorCode status = U_ZERO_ERROR;
out = u_finit(stdout, nullptr, nullptr);
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;
}

View file

@ -1,121 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{247E2681-6C84-408B-B40C-5DB50BC5E18F}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<!-- The following import will include the 'default' configuration options for VS projects. -->
<Import Project="..\..\allinone\Build.Windows.ProjectConfiguration.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\Release\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MinimalRebuild>true</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>icuucd.lib;icuind.lib;icuiod.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x86\Debug\citer.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)citer.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MinimalRebuild>true</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>icuucd.lib;icuind.lib;icuiod.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x64\Debug\citer.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)citer.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>icuuc.lib;icuin.lib;icuio.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x86\Release\citer.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>icuuc.lib;icuin.lib;icuio.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x64\Release\citer.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="citer.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="citer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View file

@ -1,63 +0,0 @@
Copyright (C) 2016 and later: Unicode, Inc. and others.
License & terms of use: http://www.unicode.org/copyright.html
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 <icu directory>/source
runConfigureICU <platform-name> --prefix <icu install directory> [other options]
gmake all
2. Install ICU,
gmake install
3. Compile
cd <icu directory>/source/samples/citer
gmake ICU_PREFIX=<icu install directory)
To Run on Unixes
cd <icu directory>/source/samples/citer
gmake ICU_PREFIX=<icu install directory> check
-or-
export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
citer
Note: The name of the LD_LIBRARY_PATH variable is different on some systems.
If in doubt, run the sample using "gmake check", and note the name of
the variable that is used there. LD_LIBRARY_PATH is the correct name
for Linux and Solaris.

View file

@ -1,25 +0,0 @@
# Copyright (C) 2016 and later: Unicode, Inc. and others.
# License & terms of use: http://www.unicode.org/copyright.html
#
# 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

View file

@ -1,77 +0,0 @@
/*
********************************************************************************
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
********************************************************************************
********************************************************************************
* Copyright (C) 2005-2006, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
#include "unicode/utypes.h"
#include "unicode/ucsdet.h"
#include <string.h>
#include <stdio.h>
#define BUFFER_SIZE 8192
int main(int argc, char *argv[])
{
static char buffer[BUFFER_SIZE];
int32_t arg;
if( argc <= 1 ) {
printf("Usage: %s [filename]...\n", argv[0]);
return -1;
}
for(arg = 1; arg < argc; arg += 1) {
FILE *file;
char *filename = argv[arg];
int32_t inputLength, match, matchCount = 0;
UCharsetDetector* csd;
const UCharsetMatch **csm;
UErrorCode status = U_ZERO_ERROR;
if (arg > 1) {
printf("\n");
}
file = fopen(filename, "rb");
if (file == NULL) {
printf("Cannot open file \"%s\"\n\n", filename);
continue;
}
printf("%s:\n", filename);
inputLength = (int32_t) fread(buffer, 1, BUFFER_SIZE, file);
fclose(file);
csd = ucsdet_open(&status);
ucsdet_setText(csd, buffer, inputLength, &status);
csm = ucsdet_detectAll(csd, &matchCount, &status);
for(match = 0; match < matchCount; match += 1) {
const char *name = ucsdet_getName(csm[match], &status);
const char *lang = ucsdet_getLanguage(csm[match], &status);
int32_t confidence = ucsdet_getConfidence(csm[match], &status);
if (lang == NULL || strlen(lang) == 0) {
lang = "**";
}
printf("%s (%s) %d\n", name, lang, confidence);
}
ucsdet_close(csd);
}
return 0;
}

View file

@ -1,128 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{683745AD-3BC2-4B89-898B-93490D7F2757}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<!-- The following import will include the 'default' configuration options for VS projects. -->
<Import Project="..\..\allinone\Build.Windows.ProjectConfiguration.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">x86\Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">x86\Release\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>../../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>icuucd.lib;icuind.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)csdet.exe</OutputFile>
<AdditionalLibraryDirectories>../../../lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)csdet.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>icuucd.lib;icuind.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)csdet.exe</OutputFile>
<AdditionalLibraryDirectories>../../../lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)csdet.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>../../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>icuuc.lib;icuin.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)csdet.exe</OutputFile>
<AdditionalLibraryDirectories>../../../lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalIncludeDirectories>../../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>icuuc.lib;icuin.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)csdet.exe</OutputFile>
<AdditionalLibraryDirectories>../../../lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="csdet.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="csdet.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View file

@ -1,63 +0,0 @@
Copyright (C) 2016 and later: Unicode, Inc. and others.
License & terms of use: http://www.unicode.org/copyright.html
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 <icu directory>/source
runConfigureICU <platform-name> --prefix <icu install directory> [other options]
gmake all
2. Install ICU,
gmake install
3. Compile
cd <icu directory>/source/samples/uresb
gmake ICU_PREFIX=<icu install directory) ICU_PATH=<icu source directory>
To Run on Unixes
cd <icu directory>/source/samples/uresb
gmake ICU_PREFIX=<icu install directory> check
-or-
export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
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.

View file

@ -1,78 +0,0 @@
## Copyright (C) 2016 and later: Unicode, Inc. and others.
## License & terms of use: http://www.unicode.org/copyright.html
##
## 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

View file

@ -1,357 +0,0 @@
/*
*************************************************************************
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*************************************************************************
***********************************************************************
* 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 <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "unicode/utypes.h"
#include "unicode/ustring.h"
#include "unicode/uclean.h"
#include "unicode/ucnv.h"
#include "unicode/udat.h"
#include "unicode/ucal.h"
#include "uprint.h"
int main(int argc, char **argv);
#if UCONFIG_NO_FORMATTING || 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(void)
{
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>, --format <format> Use <format> as the display format.");
puts(" (Special formats: \"%\" alone is Millis since 1970, \"%%\" alone is Seconds since 1970)");
puts(" -r <seconds> Use <seconds> as the time (Epoch 1970) rather than now.");
puts(" -R <millis> Use <millis> as the time (Epoch 1970) rather than now.");
puts(" -P <string> Parse <string> as the time, output in millis format.");
puts(" -L <string> Use the locale <string> instead of the default ICU locale.");
}
/* Version information */
static void
version(void)
{
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

View file

@ -1,25 +0,0 @@
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

View file

@ -1,154 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{38B5751A-C6F9-4409-950C-F4F9DA17275F}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<!-- The following import will include the 'default' configuration options for VS projects. -->
<Import Project="..\..\allinone\Build.Windows.ProjectConfiguration.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x86\Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x86\Release\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x86\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x86\Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Midl>
<TypeLibraryName>.\x86\Release/date.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<AssemblerListingLocation>.\x86\Release/</AssemblerListingLocation>
<ObjectFileName>.\x86\Release/</ObjectFileName>
<ProgramDataBaseFileName>.\x86\Release/</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<CompileAs>Default</CompileAs>
<PrecompiledHeaderFile />
</ClCompile>
<Link>
<AdditionalDependencies>icuuc.lib;icuin.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x86\Release/date.exe</OutputFile>
<AdditionalLibraryDirectories>../../../lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ProgramDatabaseFile>.\x86\Release/date.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TypeLibraryName>.\x64\Release/date.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<AssemblerListingLocation>.\x64\Release/</AssemblerListingLocation>
<ObjectFileName>.\x64\Release/</ObjectFileName>
<ProgramDataBaseFileName>.\x64\Release/</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<CompileAs>Default</CompileAs>
<PrecompiledHeaderFile />
</ClCompile>
<Link>
<AdditionalDependencies>icuuc.lib;icuin.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x64\Release/date.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ProgramDatabaseFile>.\x64\Release/date.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Midl>
<TypeLibraryName>.\x86\Debug/date.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<AssemblerListingLocation>.\x86\Debug/</AssemblerListingLocation>
<ObjectFileName>.\x86\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\x86\Debug/</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<PrecompiledHeaderFile />
</ClCompile>
<Link>
<AdditionalDependencies>icuucd.lib;icuind.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x86\Debug/date.exe</OutputFile>
<AdditionalLibraryDirectories>../../../lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>.\x86\Debug/date.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TypeLibraryName>.\x64\Debug/date.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<AssemblerListingLocation>.\x64\Debug/</AssemblerListingLocation>
<ObjectFileName>.\x64\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\x64\Debug/</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<PrecompiledHeaderFile />
</ClCompile>
<Link>
<AdditionalDependencies>icuucd.lib;icuind.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x64\Debug/date.exe</OutputFile>
<AdditionalLibraryDirectories>../../../lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>.\x64\Debug/date.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="date.c" />
<ClCompile Include="uprint.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="uprint.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{5d1a92f4-cd62-4008-981f-9b9ce42ff51d}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{384d6dc3-d172-42ad-b155-2995c3a6821a}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{b7a5bc57-56cb-42af-9127-0a3369186ee8}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="date.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="uprint.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="uprint.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View file

@ -1,61 +0,0 @@
Copyright (C) 2016 and later: Unicode, Inc. and others.
License & terms of use: http://www.unicode.org/copyright.html
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 <icu directory>/source
runConfigureICU <platform-name> --prefix <icu install directory> [other options]
gmake all
2. Install ICU,
gmake install
To Run on Unixes
cd <icu directory>/source/samples/date
gmake check
-or-
export LD_LIBRARY_PATH=<icu install directory>/lib:.:$LD_LIBRARY_PATH
date
Note: The name of the LD_LIBRARY_PATH variable is different on some systems.
If in doubt, run the sample using "gmake check", and note the name of
the variable that is used there. LD_LIBRARY_PATH is the correct name
for Linux and Solaris.

View file

@ -1,81 +0,0 @@
/*
***********************************************************************
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
***********************************************************************
**********************************************************************
* 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 <stdbool.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);
}

View file

@ -1,30 +0,0 @@
/*
********************************************************************************
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
********************************************************************************
**********************************************************************
* Copyright (C) 1998-2004, International Business Machines Corporation
* and others. All Rights Reserved.
**********************************************************************
*
* File uprint.h
*
* Modification History:
*
* Date Name Description
* 06/14/99 stephen Creation.
*******************************************************************************
*/
#ifndef UPRINT_H
#define UPRINT_H 1
#include <stdio.h>
#include "unicode/utypes.h"
/* Print a ustring to the specified FILE* in the default codepage */
U_CFUNC void uprint(const UChar *s, FILE *f, UErrorCode *status);
#endif /* ! UPRINT_H */

View file

@ -1,27 +0,0 @@
# Copyright (C) 2016 and later: Unicode, Inc. and others.
# License & terms of use: http://www.unicode.org/copyright.html
#
# 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

View file

@ -1,75 +0,0 @@
/*
*******************************************************************************
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* Copyright (C) 2002-2012, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
*/
#include "unicode/calendar.h"
#include "unicode/gregocal.h"
#include <stdio.h>
using namespace icu;
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()
{
puts("Date-Calendar sample program");
cpp_main();
c_main();
return 0;
}

View file

@ -1,61 +0,0 @@
/*
*******************************************************************************
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* Copyright (C) 2002-2003, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
*/
#include "unicode/ucal.h"
#include <stdio.h>
void c_main()
{
puts("----");
puts("C Sample");
UErrorCode status = U_ZERO_ERROR;
int32_t i;
UCalendar *cal = ucal_open(NULL, -1, NULL, UCAL_GREGORIAN, &status);
if (U_FAILURE(status)) {
puts("Couldn't create GregorianCalendar");
return;
}
/* set up the date */
ucal_set(cal, UCAL_YEAR, 2000);
ucal_set(cal, UCAL_MONTH, UCAL_FEBRUARY); /* FEBRUARY */
ucal_set(cal, UCAL_DATE, 26);
ucal_set(cal, UCAL_HOUR_OF_DAY, 23);
ucal_set(cal, UCAL_MINUTE, 0);
ucal_set(cal, UCAL_SECOND, 0);
ucal_set(cal, UCAL_MILLISECOND, 0);
/* Iterate through the days and print it out. */
for (i = 0; i < 30; i++) {
/* print out the date. */
/* You should use the udat_* API to properly format it */
printf("year: %d, month: %d (%d in the implementation), day: %d\n",
ucal_get(cal, UCAL_YEAR, &status),
ucal_get(cal, UCAL_MONTH, &status) + 1,
ucal_get(cal, UCAL_MONTH, &status),
ucal_get(cal, UCAL_DATE, &status));
if (U_FAILURE(status)) {
puts("Calendar::get failed");
return;
}
/* Add a day to the date */
ucal_add(cal, UCAL_DATE, 1, &status);
if (U_FAILURE(status))
{
puts("Calendar::add failed");
return;
}
}
ucal_close(cal);
}

View file

@ -1,23 +0,0 @@
# Copyright (C) 2016 and later: Unicode, Inc. and others.
# License & terms of use: http://www.unicode.org/copyright.html
#
# 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

View file

@ -1,107 +0,0 @@
Copyright (C) 2016 and later: Unicode, Inc. and others.
License & terms of use: http://www.unicode.org/copyright.html
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!

View file

@ -1,70 +0,0 @@
/********************************************************************
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*************************************************************************
*************************************************************************
* COPYRIGHT:
* Copyright (c) 1999-2003, International Business Machines Corporation and
* others. All Rights Reserved.
*************************************************************************/
#include "unicode/unistr.h"
#include "unicode/calendar.h"
#include "unicode/datefmt.h"
#include "unicode/uclean.h"
#include <stdio.h>
#include <stdlib.h>
#include "util.h"
/**
* If the ID supplied to TimeZone is not a valid system ID,
* TimeZone::createTimeZone() will return a GMT zone object. In order
* to detect this error, we check the ID of the returned zone against
* the ID we requested. If they don't match, we fail with an error.
*/
TimeZone* createZone(const UnicodeString& id) {
UnicodeString str;
TimeZone* zone = TimeZone::createTimeZone(id);
if (zone->getID(str) != id) {
delete zone;
printf("Error: TimeZone::createTimeZone(");
uprintf(id);
printf(") returned zone with ID ");
uprintf(str);
printf("\n");
exit(1);
}
return zone;
}
int main(int argc, char **argv) {
UErrorCode status = U_ZERO_ERROR;
UnicodeString str;
// The languages in which we will display the date
static char* LANGUAGE[] = {
"en", "de", "fr"
};
static const int32_t N_LANGUAGE = sizeof(LANGUAGE)/sizeof(LANGUAGE[0]);
// The time zones in which we will display the time
static char* TIMEZONE[] = {
"America/Los_Angeles",
"America/New_York",
"Europe/Paris",
"Europe/Berlin"
};
static const int32_t N_TIMEZONE = sizeof(TIMEZONE)/sizeof(TIMEZONE[0]);
for (int32_t i=0; i<N_LANGUAGE; ++i) {
Locale loc(LANGUAGE[i]);
// Display the formatted date string
printf("Date (%s)\n", LANGUAGE[i]);
}
printf("Exiting successfully\n");
u_cleanup();
return 0;
}

View file

@ -1,68 +0,0 @@
/********************************************************************
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*************************************************************************
*************************************************************************
* COPYRIGHT:
* Copyright (c) 1999-2003, International Business Machines Corporation and
* others. All Rights Reserved.
*************************************************************************/
#include "unicode/unistr.h"
#include "unicode/calendar.h"
#include "unicode/datefmt.h"
#include <stdio.h>
#include <stdlib.h>
#include "util.h"
/**
* If the ID supplied to TimeZone is not a valid system ID,
* TimeZone::createTimeZone() will return a GMT zone object. In order
* to detect this error, we check the ID of the returned zone against
* the ID we requested. If they don't match, we fail with an error.
*/
TimeZone* createZone(const UnicodeString& id) {
UnicodeString str;
TimeZone* zone = TimeZone::createTimeZone(id);
if (zone->getID(str) != id) {
delete zone;
printf("Error: TimeZone::createTimeZone(");
uprintf(id);
printf(") returned zone with ID ");
uprintf(str);
printf("\n");
exit(1);
}
return zone;
}
int main(int argc, char **argv) {
UErrorCode status = U_ZERO_ERROR;
UnicodeString str;
// The languages in which we will display the date
static char* LANGUAGE[] = {
"en", "de", "fr"
};
static const int32_t N_LANGUAGE = sizeof(LANGUAGE)/sizeof(LANGUAGE[0]);
// The time zones in which we will display the time
static char* TIMEZONE[] = {
"America/Los_Angeles",
"America/New_York",
"Europe/Paris",
"Europe/Berlin"
};
static const int32_t N_TIMEZONE = sizeof(TIMEZONE)/sizeof(TIMEZONE[0]);
for (int32_t i=0; i<N_LANGUAGE; ++i) {
Locale loc(LANGUAGE[i]);
// Display the formatted date string
printf("Date (%s)\n", LANGUAGE[i]);
}
printf("Exiting successfully\n");
return 0;
}

View file

@ -1,91 +0,0 @@
/********************************************************************
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*************************************************************************
*************************************************************************
* COPYRIGHT:
* Copyright (c) 1999-2003, International Business Machines Corporation and
* others. All Rights Reserved.
*************************************************************************/
#include "unicode/unistr.h"
#include "unicode/calendar.h"
#include "unicode/datefmt.h"
#include <stdio.h>
#include <stdlib.h>
#include "util.h"
/**
* If the ID supplied to TimeZone is not a valid system ID,
* TimeZone::createTimeZone() will return a GMT zone object. In order
* to detect this error, we check the ID of the returned zone against
* the ID we requested. If they don't match, we fail with an error.
*/
TimeZone* createZone(const UnicodeString& id) {
UnicodeString str;
TimeZone* zone = TimeZone::createTimeZone(id);
if (zone->getID(str) != id) {
delete zone;
printf("Error: TimeZone::createTimeZone(");
uprintf(id);
printf(") returned zone with ID ");
uprintf(str);
printf("\n");
exit(1);
}
return zone;
}
int main(int argc, char **argv) {
Calendar *cal;
TimeZone *zone;
DateFormat *fmt;
UErrorCode status = U_ZERO_ERROR;
UnicodeString str;
UDate date;
// The languages in which we will display the date
static char* LANGUAGE[] = {
"en", "de", "fr"
};
static const int32_t N_LANGUAGE = sizeof(LANGUAGE)/sizeof(LANGUAGE[0]);
// The time zones in which we will display the time
static char* TIMEZONE[] = {
"America/Los_Angeles",
"America/New_York",
"Europe/Paris",
"Europe/Berlin"
};
static const int32_t N_TIMEZONE = sizeof(TIMEZONE)/sizeof(TIMEZONE[0]);
// Create a calendar
cal = Calendar::createInstance(status);
check(status, "Calendar::createInstance");
zone = createZone("GMT"); // Create a GMT zone
cal->adoptTimeZone(zone);
cal->clear();
cal->set(1999, Calendar::JUNE, 4);
date = cal->getTime(status);
check(status, "Calendar::getTime");
for (int32_t i=0; i<N_LANGUAGE; ++i) {
Locale loc(LANGUAGE[i]);
// Create a formatter for DATE
fmt = DateFormat::createDateInstance(DateFormat::kFull, loc);
// Format the date
str.remove();
fmt->format(date, str, status);
// Display the formatted date string
printf("Date (%s): ", LANGUAGE[i]);
uprintf(escape(str));
printf("\n\n");
}
printf("Exiting successfully\n");
return 0;
}

View file

@ -1,100 +0,0 @@
/********************************************************************
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*************************************************************************
*************************************************************************
* COPYRIGHT:
* Copyright (c) 1999-2003, International Business Machines Corporation and
* others. All Rights Reserved.
*************************************************************************/
#include "unicode/unistr.h"
#include "unicode/calendar.h"
#include "unicode/datefmt.h"
#include <stdio.h>
#include <stdlib.h>
#include "util.h"
/**
* If the ID supplied to TimeZone is not a valid system ID,
* TimeZone::createTimeZone() will return a GMT zone object. In order
* to detect this error, we check the ID of the returned zone against
* the ID we requested. If they don't match, we fail with an error.
*/
TimeZone* createZone(const UnicodeString& id) {
UnicodeString str;
TimeZone* zone = TimeZone::createTimeZone(id);
if (zone->getID(str) != id) {
delete zone;
printf("Error: TimeZone::createTimeZone(");
uprintf(id);
printf(") returned zone with ID ");
uprintf(str);
printf("\n");
exit(1);
}
return zone;
}
int main(int argc, char **argv) {
Calendar *cal;
TimeZone *zone;
DateFormat *fmt;
UErrorCode status = U_ZERO_ERROR;
UnicodeString str;
UDate date;
// The languages in which we will display the date
static char* LANGUAGE[] = {
"en", "de", "fr"
};
static const int32_t N_LANGUAGE = sizeof(LANGUAGE)/sizeof(LANGUAGE[0]);
// The time zones in which we will display the time
static char* TIMEZONE[] = {
"America/Los_Angeles",
"America/New_York",
"Europe/Paris",
"Europe/Berlin"
};
static const int32_t N_TIMEZONE = sizeof(TIMEZONE)/sizeof(TIMEZONE[0]);
// Create a calendar
cal = Calendar::createInstance(status);
check(status, "Calendar::createInstance");
zone = createZone("GMT"); // Create a GMT zone
cal->adoptTimeZone(zone);
cal->clear();
cal->set(1999, Calendar::JUNE, 4);
date = cal->getTime(status);
check(status, "Calendar::getTime");
for (int32_t i=0; i<N_LANGUAGE; ++i) {
Locale loc(LANGUAGE[i]);
// Create a formatter for DATE and TIME
fmt = DateFormat::createDateTimeInstance(
DateFormat::kFull, DateFormat::kFull, loc);
for (int32_t j=0; j<N_TIMEZONE; ++j) {
cal->adoptTimeZone(createZone(TIMEZONE[j]));
fmt->setCalendar(*cal);
// Format the date
str.remove();
fmt->format(date, str, status);
// Display the formatted date string
printf("Date (%s, %s): ", LANGUAGE[i], TIMEZONE[j]);
uprintf(escape(str));
printf("\n\n");
}
delete fmt;
}
printf("Exiting successfully\n");
return 0;
}

View file

@ -1,27 +0,0 @@
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}") = "datefmt", "datefmt.vcxproj", "{6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}"
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
{6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Debug|Win32.ActiveCfg = Debug|Win32
{6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Debug|Win32.Build.0 = Debug|Win32
{6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Debug|x64.ActiveCfg = Debug|x64
{6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Debug|x64.Build.0 = Debug|x64
{6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Release|Win32.ActiveCfg = Release|Win32
{6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Release|Win32.Build.0 = Release|Win32
{6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Release|x64.ActiveCfg = Release|x64
{6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View file

@ -1,152 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{6D592DB7-B9C8-4B1B-A1C1-F9A9EB4FD4E4}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<!-- The following import will include the 'default' configuration options for VS projects. -->
<Import Project="..\..\allinone\Build.Windows.ProjectConfiguration.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x86\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x86\Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x86\Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x86\Release\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Midl>
<TypeLibraryName>.\x86\Debug/datefmt.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeaderOutputFile>.\x86\Debug/datefmt.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\x86\Debug/</AssemblerListingLocation>
<ObjectFileName>.\x86\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\x86\Debug/</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>icuucd.lib;icuind.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x86\Debug/datefmt.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>.\x86\Debug/datefmt.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TypeLibraryName>.\x64\Debug/datefmt.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeaderOutputFile>.\x64\Debug/datefmt.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\x64\Debug/</AssemblerListingLocation>
<ObjectFileName>.\x64\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\x64\Debug/</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>icuucd.lib;icuind.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x64\Debug/datefmt.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>.\x64\Debug/datefmt.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Midl>
<TypeLibraryName>.\x86\Release/datefmt.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeaderOutputFile>.\x86\Release/datefmt.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\x86\Release/</AssemblerListingLocation>
<ObjectFileName>.\x86\Release/</ObjectFileName>
<ProgramDataBaseFileName>.\x86\Release/</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>icuuc.lib;icuin.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x86\Release/datefmt.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ProgramDatabaseFile>.\x86\Release/datefmt.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TypeLibraryName>.\x64\Release/datefmt.tlb</TypeLibraryName>
</Midl>
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<PrecompiledHeaderOutputFile>.\x64\Release/datefmt.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\x64\Release/</AssemblerListingLocation>
<ObjectFileName>.\x64\Release/</ObjectFileName>
<ProgramDataBaseFileName>.\x64\Release/</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<CompileAs>Default</CompileAs>
</ClCompile>
<Link>
<AdditionalDependencies>icuuc.lib;icuin.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>.\x64\Release/datefmt.exe</OutputFile>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ProgramDatabaseFile>.\x64\Release/datefmt.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
<ClCompile Include="util.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{a5cbb044-7694-4d1d-98c1-bb578ee7f1ea}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{aadf5a92-1812-45ce-90a0-e9db3945d7c5}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{9eff3ddc-6822-4225-81fc-a867b9e592c0}</UniqueIdentifier>
<Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="util.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View file

@ -1,102 +0,0 @@
/*************************************************************************
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*************************************************************************
*************************************************************************
* COPYRIGHT:
* Copyright (c) 1999-2003, International Business Machines Corporation and
* others. All Rights Reserved.
*************************************************************************/
#include "unicode/unistr.h"
#include "unicode/calendar.h"
#include "unicode/datefmt.h"
#include <stdio.h>
#include <stdlib.h>
#include "util.h"
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; i<N_LANGUAGE; ++i) {
Locale loc(LANGUAGE[i]);
// Create a formatter for DATE and TIME
fmt = DateFormat::createDateTimeInstance(
DateFormat::kFull, DateFormat::kFull, loc);
for (int32_t j=0; j<N_TIMEZONE; ++j) {
cal->adoptTimeZone(createZone(TIMEZONE[j]));
fmt->setCalendar(*cal);
// Format the date
str.remove();
fmt->format(date, str, status);
// Display the formatted date string
printf("Date (%s, %s): ", LANGUAGE[i], TIMEZONE[j]);
uprintf(escape(str));
printf("\n\n");
}
delete fmt;
}
printf("Exiting successfully\n");
return 0;
}

View file

@ -1,69 +0,0 @@
/********************************************************************
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*************************************************************************
*************************************************************************
* COPYRIGHT:
* Copyright (c) 1999-2003, International Business Machines Corporation and
* others. All Rights Reserved.
*************************************************************************/
#include "unicode/unistr.h"
#include <stdio.h>
#include <stdlib.h>
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<source.length(); ++i) {
char16_t ch = source[i];
if (ch < 0x09 || (ch > 0x0A && ch < 0x20) || ch > 0x7E) {
target += "\\u";
appendHex(ch, 4, target);
} else {
target += ch;
}
}
target += "\"";
return target;
}
// Print the given string to stdout
void uprintf(const UnicodeString &str) {
char* buf = nullptr;
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;
}

View file

@ -1,22 +0,0 @@
/********************************************************************
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*************************************************************************
*************************************************************************
* 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);

View file

@ -1,27 +0,0 @@
# Copyright (C) 2016 and later: Unicode, Inc. and others.
# License & terms of use: http://www.unicode.org/copyright.html
#
# 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=dtitvfmtsample
# All object files (C or C++)
OBJECTS=dtitvfmtsample.o
#### rules
# Load in standard makefile definitions
include ../defs.mk
LDFLAGS += $(LDFLAGS_USTDIO)
# the actual rules (this is a simple sample)
include ../rules.mk

View file

@ -1,144 +0,0 @@
// © 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 <iostream>
#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, nullptr, "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"),
UnicodeString("")
};
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].isEmpty() ;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, nullptr, "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"),
UnicodeString("")
};
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].isEmpty();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;
}

View file

@ -1,140 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{8945255B-473B-4C47-9425-E92384338CAA}</ProjectGuid>
<RootNamespace>samples</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<!-- The following import will include the 'default' configuration options for VS projects. -->
<Import Project="..\..\allinone\Build.Windows.ProjectConfiguration.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>.\x86\Debug\</OutDir>
<IntDir>.\x86\Debug\</IntDir>
<TargetName>$(ProjectName)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>.\x64\Debug\</OutDir>
<IntDir>.\x64\Debug\</IntDir>
<TargetName>$(ProjectName)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>.\x86\Release\</OutDir>
<IntDir>.\x86\Release\</IntDir>
<TargetName>$(ProjectName)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>.\x64\Release\</OutDir>
<IntDir>.\x64\Release\</IntDir>
<TargetName>$(ProjectName)</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AssemblerListingLocation>.\x86\Debug/</AssemblerListingLocation>
<ObjectFileName>.\x86\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\x86\Debug/</ProgramDataBaseFileName>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OutputFile>.\x86\Debug/dtitvfmtsample.exe</OutputFile>
<AdditionalDependencies>icuucd.lib;icuind.lib;icuiod.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AssemblerListingLocation>.\x64\Debug/</AssemblerListingLocation>
<ObjectFileName>.\x64\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\x64\Debug/</ProgramDataBaseFileName>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OutputFile>.\x64\Debug/dtitvfmtsample.exe</OutputFile>
<AdditionalDependencies>icuucd.lib;icuind.lib;icuiod.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AssemblerListingLocation>.\x86\Release/</AssemblerListingLocation>
<ObjectFileName>.\x86\Release/</ObjectFileName>
<ProgramDataBaseFileName>.\x86\Release/</ProgramDataBaseFileName>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>icuuc.lib;icuin.lib;icuio.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AssemblerListingLocation>.\x64\Release/</AssemblerListingLocation>
<ObjectFileName>.\x64\Release/</ObjectFileName>
<ProgramDataBaseFileName>.\x64\Release/</ProgramDataBaseFileName>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>icuuc.lib;icuin.lib;icuio.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="dtitvfmtsample.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dtitvfmtsample.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View file

@ -1,27 +0,0 @@
# Copyright (C) 2016 and later: Unicode, Inc. and others.
# License & terms of use: http://www.unicode.org/copyright.html
#
# 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=dtptngsample
# All object files (C or C++)
OBJECTS=dtptngsample.o
#### rules
# Load in standard makefile definitions
include ../defs.mk
LDFLAGS += $(LDFLAGS_USTDIO)
# the actual rules (this is a simple sample)
include ../rules.mk

View file

@ -1,166 +0,0 @@
// © 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 <iostream>
#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", nullptr,"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].isEmpty();i++) {
u_fprintf(f, "%-20S",skeletons[i].getTerminatedBuffer());
for (int j=0;j<sizeof(locales)/sizeof(locales[0]);j++) {
// create a DateTimePatternGenerator instance for given locale
DateTimePatternGenerator *dtfg= DateTimePatternGenerator::createInstance(locales[j],status);
// use getBestPattern method to get the best pattern for the given skeleton
UnicodeString pattern = dtfg->getBestPattern(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, nullptr, "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;
}

View file

@ -1,134 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{115886F0-7DFB-4B8B-BE79-83162EE8713B}</ProjectGuid>
<RootNamespace>samples</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<!-- The following import will include the 'default' configuration options for VS projects. -->
<Import Project="..\..\allinone\Build.Windows.ProjectConfiguration.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>.\x86\Debug\</OutDir>
<IntDir>.\x86\Debug\</IntDir>
<TargetName>$(ProjectName)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>.\x64\Debug\</OutDir>
<IntDir>.\x64\Debug\</IntDir>
<TargetName>$(ProjectName)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>.\x86\Release\</OutDir>
<IntDir>.\x86\Release\</IntDir>
<TargetName>$(ProjectName)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>.\x64\Release\</OutDir>
<IntDir>.\x64\Release\</IntDir>
<TargetName>$(ProjectName)</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>..\..\common;..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OutputFile>.\x86\debug/dtptngsample.exe</OutputFile>
<AdditionalDependencies>icuucd.lib;icuind.lib;icuiod.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>..\..\common;..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AssemblerListingLocation>.\x64\Debug/</AssemblerListingLocation>
<ObjectFileName>.\x64\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\x64\Debug/</ProgramDataBaseFileName>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OutputFile>.\x64\debug/dtptngsample.exe</OutputFile>
<AdditionalDependencies>icuucd.lib;icuind.lib;icuiod.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\..\..\include;..\..\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>icuuc.lib;icuin.lib;icuio.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\..\..\include;..\..\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AssemblerListingLocation>.\x64\Release/</AssemblerListingLocation>
<ObjectFileName>.\x64\Release/</ObjectFileName>
<ProgramDataBaseFileName>.\x64\Release/</ProgramDataBaseFileName>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>icuuc.lib;icuin.lib;icuio.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="dtptngsample.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dtptngsample.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View file

@ -1,14 +0,0 @@
# Copyright (C) 2016 and later: Unicode, Inc. and others.
# License & terms of use: http://www.unicode.org/copyright.html
#
# 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

View file

@ -1,11 +0,0 @@
# Copyright (C) 2016 and later: Unicode, Inc. and others.
# License & terms of use: http://www.unicode.org/copyright.html
#
# 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

View file

@ -1,294 +0,0 @@
/*
******************************************************************************
* © 2016 and later: Unicode, Inc. and others. *
* License & terms of use: http://www.unicode.org/copyright.html *
******************************************************************************
******************************************************************************
* Copyright (C) 1998-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "unicode/utypes.h"
#include "unicode/uscript.h"
#include "layout/LETypes.h"
#include "layout/LEScripts.h"
#include "layout/LEFontInstance.h"
#include "GUISupport.h"
#include "FontMap.h"
using icu::LEFontInstance;
using icu::scriptCodeCount;
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] = nullptr;
fFontInstances[i] = nullptr;
}
/**/
if (LE_FAILURE(status)) {
return;
}
char *c, *scriptName, *fontName, *line, buffer[BUFFER_SIZE];
FILE *file;
file = fopen(fileName, "r");
if (file == nullptr) {
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) != nullptr) {
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] != nullptr) {
delete[] (char *) fFontNames[font];
}
}
for (font = 0; font < fFontCount; font += 1) {
if (fFontInstances[font] != nullptr) {
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 reuse 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 nullptr;
}
if (scriptCode <= -1 || scriptCode >= scriptCodeCount) {
status = LE_ILLEGAL_ARGUMENT_ERROR;
return nullptr;
}
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 nullptr;
}
if (fFontInstances[fontIndex] == nullptr) {
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 nullptr;
}
}
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] == nullptr) {
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;
}
}
}

View file

@ -1,73 +0,0 @@
/*
******************************************************************************
* © 2016 and later: Unicode, Inc. and others. *
* License & terms of use: http://www.unicode.org/copyright.html *
******************************************************************************
******************************************************************************
* 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"
using icu::LEFontInstance;
using icu::scriptCodeCount;
#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

View file

@ -1,95 +0,0 @@
/*
*************************************************************************
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*************************************************************************
*************************************************************************
* 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 == nullptr) {
fTableCacheSize = 0;
return;
}
for (int i = 0; i < fTableCacheSize; i += 1) {
fTableCache[i].tag = 0;
fTableCache[i].table = nullptr;
}
}
FontTableCache::~FontTableCache()
{
for (int i = fTableCacheCurr - 1; i >= 0; i -= 1) {
freeFontTable(fTableCache[i].table);
fTableCache[i].tag = 0;
fTableCache[i].table = nullptr;
}
fTableCacheCurr = 0;
LE_DELETE_ARRAY(fTableCache);
fTableCache = nullptr;
}
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 = nullptr;
}
fTableCacheSize = newSize;
}
fTableCache[fTableCacheCurr].tag = tableTag;
fTableCache[fTableCacheCurr].table = table;
fTableCacheCurr += 1;
}

View file

@ -1,43 +0,0 @@
/*
*************************************************************************
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*************************************************************************
**********************************************************************
* 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

View file

@ -1,408 +0,0 @@
/*
*******************************************************************************
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* 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 <windows.h>
#include "layout/LETypes.h"
#include "layout/LESwaps.h"
#include "layout/LEFontInstance.h"
#include "GDIFontInstance.h"
#include "sfnt.h"
#include "cmaps.h"
GDISurface::GDISurface(HDC theHDC)
: fHdc(theHDC), fCurrentFont(nullptr)
{
// nothing else to do
}
GDISurface::~GDISurface()
{
// nothing to do
}
void GDISurface::setHDC(HDC theHDC)
{
fHdc = theHDC;
fCurrentFont = nullptr;
}
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(nullptr),
fPointSize(pointSize), fUnitsPerEM(0), fAscent(0), fDescent(0), fLeading(0),
fDeviceScaleX(1), fDeviceScaleY(1), fMapper(nullptr)
{
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, nullptr, MWT_IDENTITY);
SetViewportOrgEx(hdc, 0, 0, nullptr);
SetWindowOrgEx(hdc, 0, 0, nullptr);
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 == nullptr) {
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(nullptr),
fPointSize(pointSize), fUnitsPerEM(0), fAscent(0), fDescent(0), fLeading(0),
fDeviceScaleX(1), fDeviceScaleY(1), fMapper(nullptr)
{
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, nullptr, MWT_IDENTITY);
SetViewportOrgEx(hdc, 0, 0, nullptr);
SetWindowOrgEx(hdc, 0, 0, nullptr);
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 == nullptr) {
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 = nullptr;
const HHEATable *hheaTable = nullptr;
// read unitsPerEm from 'head' table
headTable = (const HEADTable *) readFontTable(LE_HEAD_TABLE_TAG);
if (headTable == nullptr) {
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 == nullptr) {
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 != nullptr) {
// FIXME: call RemoveObject first?
DeleteObject(fFont);
}
delete fMapper;
fMapper = nullptr;
}
LEErrorCode GDIFontInstance::initMapper()
{
LETag cmapTag = LE_CMAP_TABLE_TAG;
const CMAPTable *cmap = (const CMAPTable *) readFontTable(cmapTag);
if (cmap == nullptr) {
return LE_MISSING_FONT_TABLE_ERROR;
}
fMapper = CMAPMapper::createUnicodeMapper(cmap);
if (fMapper == nullptr) {
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, nullptr, 0);
void *result = nullptr;
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, nullptr, &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
}

View file

@ -1,162 +0,0 @@
/*
*******************************************************************************
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* Copyright (C) 1999-2003, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: GDIFontInstance.h
*
* created on: 08/09/2000
* created by: Eric R. Mader
*/
#ifndef __GDIFONTINSTANCE_H
#define __GDIFONTINSTANCE_H
#include <windows.h>
#include "layout/LETypes.h"
#include "layout/LEFontInstance.h"
#include "RenderingSurface.h"
#include "FontTableCache.h"
#include "cmaps.h"
class GDIFontInstance;
class GDISurface : public RenderingSurface
{
public:
GDISurface(HDC theHDC);
virtual ~GDISurface();
virtual void drawGlyphs(const LEFontInstance *font, const LEGlyphID *glyphs, le_int32 count,
const float *positions, le_int32 x, le_int32 y, le_int32 width, le_int32 height);
void setFont(const GDIFontInstance *font);
HDC getHDC() const;
void setHDC(HDC theHDC);
private:
HDC fHdc;
const GDIFontInstance *fCurrentFont;
};
inline HDC GDISurface::getHDC() const
{
return fHdc;
}
class GDIFontInstance : public LEFontInstance, protected FontTableCache
{
protected:
GDISurface *fSurface;
HFONT fFont;
le_int32 fPointSize;
le_int32 fUnitsPerEM;
le_int32 fAscent;
le_int32 fDescent;
le_int32 fLeading;
float fDeviceScaleX;
float fDeviceScaleY;
CMAPMapper *fMapper;
virtual const void *readFontTable(LETag tableTag) const;
virtual LEErrorCode initMapper();
public:
GDIFontInstance(GDISurface *surface, TCHAR *faceName, le_int16 pointSize, LEErrorCode &status);
GDIFontInstance(GDISurface *surface, const char *faceName, le_int16 pointSize, LEErrorCode &status);
//GDIFontInstance(GDISurface *surface, le_int16 pointSize);
virtual ~GDIFontInstance();
HFONT getFont() const;
virtual const void *getFontTable(LETag tableTag) const;
virtual le_int32 getUnitsPerEM() const;
virtual le_int32 getAscent() const;
virtual le_int32 getDescent() const;
virtual le_int32 getLeading() const;
virtual LEGlyphID mapCharToGlyph(LEUnicode32 ch) const;
virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const;
virtual le_bool getGlyphPoint(LEGlyphID glyph, le_int32 pointNumber, LEPoint &point) const;
float getXPixelsPerEm() const;
float getYPixelsPerEm() const;
float getScaleFactorX() const;
float getScaleFactorY() const;
};
inline HFONT GDIFontInstance::getFont() const
{
return fFont;
}
inline le_int32 GDIFontInstance::getUnitsPerEM() const
{
return fUnitsPerEM;
}
inline le_int32 GDIFontInstance::getAscent() const
{
return fAscent;
}
inline le_int32 GDIFontInstance::getDescent() const
{
return fDescent;
}
inline le_int32 GDIFontInstance::getLeading() const
{
return fLeading;
}
inline LEGlyphID GDIFontInstance::mapCharToGlyph(LEUnicode32 ch) const
{
return fMapper->unicodeToGlyph(ch);
}
inline float GDIFontInstance::getXPixelsPerEm() const
{
return (float) fPointSize;
}
inline float GDIFontInstance::getYPixelsPerEm() const
{
return (float) fPointSize;
}
inline float GDIFontInstance::getScaleFactorX() const
{
return fDeviceScaleX;
}
inline float GDIFontInstance::getScaleFactorY() const
{
return fDeviceScaleY;
}
#endif

View file

@ -1,43 +0,0 @@
/*
******************************************************************************
* © 2016 and later: Unicode, Inc. and others. *
* License & terms of use: http://www.unicode.org/copyright.html *
******************************************************************************
******************************************************************************
* Copyright (C) 1998-2003, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
#include <windows.h>
#include "layout/LEFontInstance.h"
#include "GDIFontInstance.h"
#include "GUISupport.h"
#include "FontMap.h"
#include "GDIFontMap.h"
GDIFontMap::GDIFontMap(GDISurface *surface, const char *fileName, le_int16 pointSize, GUISupport *guiSupport, LEErrorCode &status)
: FontMap(fileName, pointSize, guiSupport, status), fSurface(surface)
{
// nothing to do?
}
GDIFontMap::~GDIFontMap()
{
// anything?
}
const LEFontInstance *GDIFontMap::openFont(const char *fontName, le_int16 pointSize, LEErrorCode &status)
{
LEFontInstance *result = new GDIFontInstance(fSurface, fontName, pointSize, status);
if (LE_FAILURE(status)) {
delete result;
result = nullptr;
}
return result;
}

View file

@ -1,42 +0,0 @@
/*
******************************************************************************
* © 2016 and later: Unicode, Inc. and others. *
* License & terms of use: http://www.unicode.org/copyright.html *
******************************************************************************
******************************************************************************
* Copyright (C) 1998-2003, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
#ifndef __GDIFONTMAP_H
#define __GDIFONTMAP_H
#include <windows.h>
#include "unicode/uscript.h"
#include "layout/LETypes.h"
#include "layout/LEFontInstance.h"
#include "FontMap.h"
#include "GUISupport.h"
#include "GDIFontInstance.h"
#define BUFFER_SIZE 128
class GDIFontMap : public FontMap
{
public:
GDIFontMap(GDISurface *surface, const char *fileName, le_int16 pointSize, GUISupport *guiSupport, LEErrorCode &status);
virtual ~GDIFontMap();
protected:
virtual const LEFontInstance *openFont(const char *fontName, le_int16 pointSize, LEErrorCode &status);
private:
GDISurface *fSurface;
};
#endif

View file

@ -1,28 +0,0 @@
/*
*******************************************************************************
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* Copyright (C) 1999-2001, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: GDIGUISupport.h
*
* created on: 11/06/2001
* created by: Eric R. Mader
*/
#include <windows.h>
#include "GDIGUISupport.h"
void GDIGUISupport::postErrorMessage(const char *message, const char *title)
{
MessageBoxA(nullptr, message, title, MB_ICONERROR);
}

View file

@ -1,34 +0,0 @@
/*
*******************************************************************************
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* 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

View file

@ -1,32 +0,0 @@
/*
*******************************************************************************
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* 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

View file

@ -1,208 +0,0 @@
/*
*******************************************************************************
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* Copyright (C) 1999-2007, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: GnomeFontInstance.cpp
*
* created on: 08/30/2001
* created by: Eric R. Mader
*/
#include <gnome.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include FT_RENDER_H
#include FT_TRUETYPE_TABLES_H
#include <cairo.h>
#include <cairo-ft.h>
#include "layout/LETypes.h"
#include "layout/LESwaps.h"
#include "GnomeFontInstance.h"
#include "sfnt.h"
#include "cmaps.h"
using icu::LEFontInstance;
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(nullptr)
{
FT_Error error;
fFace = nullptr;
fCairoFace = nullptr;
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 != nullptr) {
FT_Done_Face(fFace);
}
}
LEErrorCode GnomeFontInstance::initMapper()
{
LETag cmapTag = LE_CMAP_TABLE_TAG;
const CMAPTable *cmap = (const CMAPTable *) readFontTable(cmapTag);
if (cmap == nullptr) {
return LE_MISSING_FONT_TABLE_ERROR;
}
fMapper = CMAPMapper::createUnicodeMapper(cmap);
if (fMapper == nullptr) {
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 = nullptr;
FT_Load_Sfnt_Table(fFace, tableTag, 0, nullptr, &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;
}
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);
}

View file

@ -1,174 +0,0 @@
/*
*******************************************************************************
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* Copyright (C) 1999-2006, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: GnomeFontInstance.h
*
* created on: 08/30/2001
* created by: Eric R. Mader
*/
#ifndef __GNOMEFONTINSTANCE_H
#define __GNOMEFONTINSTANCE_H
#include <gnome.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include <cairo.h>
#include "layout/LETypes.h"
#include "layout/LEFontInstance.h"
#include "RenderingSurface.h"
#include "FontTableCache.h"
#include "cmaps.h"
using icu::LEFontInstance;
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

View file

@ -1,47 +0,0 @@
/*
******************************************************************************
* © 2016 and later: Unicode, Inc. and others. *
* License & terms of use: http://www.unicode.org/copyright.html *
******************************************************************************
******************************************************************************
* Copyright (C) 1998-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
#include <stdio.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include "layout/LEFontInstance.h"
#include "GnomeFontInstance.h"
#include "GUISupport.h"
#include "FontMap.h"
#include "GnomeFontMap.h"
using icu::LEFontInstance;
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 = nullptr;
}
return result;
}

View file

@ -1,44 +0,0 @@
/*
*******************************************************************************
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*******************************************************************************
******************************************************************************
* Copyright (C) 1998-2006, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
#ifndef __GNOMEFONTMAP_H
#define __GNOMEFONTMAP_H
#include <ft2build.h>
#include FT_FREETYPE_H
#include "unicode/uscript.h"
#include "layout/LETypes.h"
#include "layout/LEFontInstance.h"
#include "GUISupport.h"
#include "FontMap.h"
using icu::LEFontInstance;
#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

View file

@ -1,43 +0,0 @@
/*
*******************************************************************************
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* Copyright (C) 1999-2001, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: GnomeGUISupport.cpp
*
* created on: 11/06/2001
* created by: Eric R. Mader
*/
#if 1
#include <gnome.h>
#else
#include <stdio.h>
#endif
#include "GnomeGUISupport.h"
void GnomeGUISupport::postErrorMessage(const char *message, const char *title)
{
#if 1
gchar *s;
GtkWidget *error;
s = g_strconcat(title, ":\n", message, nullptr);
error = gnome_error_dialog(s);
gtk_widget_show(error);
g_free(s);
#else
fprintf(stderr, "%s: %s\n", title, message);
#endif
}

View file

@ -1,34 +0,0 @@
/*
*******************************************************************************
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* 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

View file

@ -1,123 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
/*
*******************************************************************************
*
* Copyright (C) 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* Copyright (C) 2002-2003, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
*/
#include <winresrc.h>
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
LAYOUTSAMPLE MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New Sample\tCtrl+N", IDM_FILE_NEWSAMPLE
MENUITEM "&Open...\tCtrl+O", IDM_FILE_OPEN
MENUITEM SEPARATOR
MENUITEM "&Close\tCtrl+W", IDM_FILE_CLOSE
MENUITEM "E&xit\tCtrl+Q", IDM_FILE_EXIT
END
POPUP "&Help"
BEGIN
MENUITEM "&About Layout Sample...", IDM_HELP_ABOUTLAYOUTSAMPLE
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
LAYOUTSAMPLE ACCELERATORS DISCARDABLE
BEGIN
"N", IDM_FILE_NEWSAMPLE, VIRTKEY, CONTROL, NOINVERT
"O", IDM_FILE_OPEN, VIRTKEY, CONTROL, NOINVERT
"Q", IDM_FILE_EXIT, VIRTKEY, CONTROL, NOINVERT
"W", IDM_FILE_CLOSE, VIRTKEY, CONTROL, NOINVERT
END
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"/*\r\n"
"*******************************************************************************\r\n"
"*\r\n"
"* Copyright (C) 2002-2003, International Business Machines\r\n"
"* Corporation and others. All Rights Reserved.\r\n"
"*\r\n"
"*******************************************************************************\r\n"
"*/\r\n"
"#include <winresrc.h>\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -1,110 +0,0 @@
## Copyright (C) 2016 and later: Unicode, Inc. and others.
## License & terms of use: http://www.unicode.org/copyright.html
##
## 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) -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

View file

@ -1,38 +0,0 @@
/*
*******************************************************************************
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* 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"
using icu::LEFontInstance;
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

View file

@ -1 +0,0 @@
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: บทที่๑พายุไซโคลนโดโรธีอาศัยอยู่ท่ามกลางทุ่งใหญ่ในแคนซัสกับลุงเฮนรีชาวไร่และป้าเอ็มภรรยาชาวไร่บ้านของพวกเขาหลังเล็กเพราะไม้สร้างบ้านต้องขนมาด้วยเกวียนเป็นระยะทางหลายไมล์

View file

@ -1,112 +0,0 @@
/*
*******************************************************************************
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
*******************************************************************************
*******************************************************************************
*
* 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"
using icu::LEFontInstance;
using icu::scriptCodeCount;
const char ScriptCompositeFontInstance::fgClassID=0;
ScriptCompositeFontInstance::ScriptCompositeFontInstance(FontMap *fontMap)
: fFontMap(fontMap)
{
// nothing else to do
}
ScriptCompositeFontInstance::~ScriptCompositeFontInstance()
{
delete fFontMap;
fFontMap = nullptr;
}
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 nullptr;
}
if (chars == nullptr || *offset < 0 || limit < 0 || *offset >= limit || script < 0 || script >= scriptCodeCount) {
success = LE_ILLEGAL_ARGUMENT_ERROR;
return nullptr;
}
const LEFontInstance *result = fFontMap->getScriptFont(script, success);
if (LE_FAILURE(success)) {
return nullptr;
}
*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);
}

View file

@ -1,188 +0,0 @@
/*
* %W% %E%
*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
* (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"
using icu::LEFontInstance;
// U_NAMESPACE_BEGIN
class ScriptCompositeFontInstance : public LEFontInstance
{
public:
ScriptCompositeFontInstance(FontMap *fontMap);
virtual ~ScriptCompositeFontInstance();
/**
* Get a physical font which can render the given text. For composite fonts,
* if there is no single physical font which can render all of the text,
* return a physical font which can render an initial substring of the text,
* and set the <code>offset</code> parameter to the end of that substring.
*
* Internally, the LayoutEngine works with runs of text all in the same
* font and script, so it is best to call this method with text which is
* in a single script, passing the script code in as a hint. If you don't
* know the script of the text, you can use zero, which is the script code
* for characters used in more than one script.
*
* The default implementation of this method is intended for instances of
* <code>LEFontInstance</code> which represent a physical font. It returns
* <code>this</code> and indicates that the entire string can be rendered.
*
* This method will return a valid <code>LEFontInstance</code> unless you
* have passed illegal parameters, or an internal error has been encountered.
* For composite fonts, it may return the warning <code>LE_NO_SUBFONT_WARNING</code>
* to indicate that the returned font may not be able to render all of
* the text. Whenever a valid font is returned, the <code>offset</code> parameter
* will be advanced by at least one.
*
* Subclasses which implement composite fonts must override this method.
* Where it makes sense, they should use the script code as a hint to render
* characters from the COMMON script in the font which is used for the given
* script. For example, if the input text is a series of Arabic words separated
* by spaces, and the script code passed in is <code>arabScriptCode</code> you
* should return the font used for Arabic characters for all of the input text,
* including the spaces. If, on the other hand, the input text contains characters
* which cannot be rendered by the font used for Arabic characters, but which can
* be rendered by another font, you should return that font for those characters.
*
* @param chars - the array of Unicode characters.
* @param offset - a pointer to the starting offset in the text. On exit this
* will be set the the limit offset of the text which can be
* rendered using the returned font.
* @param limit - the limit offset for the input text.
* @param script - the script hint.
* @param success - set to an error code if the arguments are illegal, or no font
* can be returned for some reason. May also be set to
* <code>LE_NO_SUBFONT_WARNING</code> if the subfont which
* was returned cannot render all of the text.
*
* @return an <code>LEFontInstance</code> for the sub font which can render the characters, or
* <code>nullptr</code> 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 character 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 nullptr;
}
// 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

View file

@ -1,33 +0,0 @@
/*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
* 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);
}

View file

@ -1,17 +0,0 @@
/*
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*
* 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);
};

View file

@ -1,125 +0,0 @@
/*
******************************************************************************
* © 2016 and later: Unicode, Inc. and others. *
* License & terms of use: http://www.unicode.org/copyright.html *
******************************************************************************
******************************************************************************
* Copyright (C) 1998-2005, International Business Machines Corporation and *
* others. All Rights Reserved. *
******************************************************************************
*/
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include "unicode/utypes.h"
#include "unicode/unistr.h"
#include "layout/LETypes.h"
#include "GUISupport.h"
#include "UnicodeReader.h"
using icu::UnicodeString;
#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 char16_t *UnicodeReader::readFile(const char *fileName, GUISupport *guiSupport, int32_t &charCount)
{
FILE *f;
int32_t fileSize;
char16_t *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 == nullptr ) {
sprintf(errorMessage,"Couldn't open %s: %s \n", fileName, strerror(errno));
guiSupport->postErrorMessage(errorMessage, "Text File Error");
return nullptr;
}
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 nullptr;
}
fileSize -= signatureLength;
fseek(f, signatureLength, SEEK_SET);
byteBuffer = new char[fileSize];
if (byteBuffer == nullptr) {
sprintf(errorMessage,"Couldn't get memory for reading %s: %s \n", fileName, strerror(errno));
guiSupport->postErrorMessage(errorMessage, "Text File Error");
fclose(f);
return nullptr;
}
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 nullptr;
}
fclose(f);
UnicodeString myText(byteBuffer, fileSize, cp);
delete[] byteBuffer;
charCount = myText.length();
charBuffer = LE_NEW_ARRAY(char16_t, charCount + 1);
if (charBuffer == nullptr) {
sprintf(errorMessage,"Couldn't get memory for reading %s: %s \n", fileName, strerror(errno));
guiSupport->postErrorMessage(errorMessage, "Text File Error");
return nullptr;
}
myText.extract(0, myText.length(), charBuffer);
charBuffer[charCount] = 0; // NUL terminate for easier reading in the debugger
return charBuffer;
}

Some files were not shown because too many files have changed in this diff Show more