diff --git a/tools/release/c/os-mapping/Makefile b/tools/release/c/os-mapping/Makefile new file mode 100644 index 00000000000..c6223879a77 --- /dev/null +++ b/tools/release/c/os-mapping/Makefile @@ -0,0 +1,70 @@ +#***************************************************************************** +# +# Copyright (C) 2006-2008, International Business Machines +# Corporation and others. All Rights Reserved. +# +#***************************************************************************** +# +# FILE NAME : Makefile +# +# Date Name Description +# 03/02/2006 grhoten Creation. +#***************************************************************************** + +## List of phony targets +.PHONY : all all-local install install-local clean clean-local \ +distclean distclean-local install-library install-headers 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_TARGETS = displayLocaleConv testTimezone +#ICU_BASE = /home/build/Build_ICU_HP11iACC +#ICU_BASE = /home/build/Build_ICU_Solaris9CC +ICU_BASE = /home/build/Build_ICU_LinuxRHEL4.2 +#ICU_BASE = /home/build/Build_ICU_MacOSX +#ICU_BASE = /home/build/Build_ICU_AIX5.2VA6 + +all-local: $(ALL_TARGETS) + +displayLocaleConv: displayLocaleConv.c + #aCC +DD64 -I$(ICU_BASE)/icu/source/common/ -L$(ICU_BASE)/icu/source/lib/ -licuuc -licudata -o $@ $< + #CC -xtarget=ultra -xarch=v9 -I$(ICU_BASE)/icu/source/common/ -L$(ICU_BASE)/icu/source/lib/ -licuuc -licudata -o $@ $< + gcc -I $(ICU_BASE)/icu/source/common/ -L$(ICU_BASE)/icu/source/lib/ -licuuc -licudata -o $@ $< + #gcc -I $(ICU_BASE)/icu/source/common/ -L$(ICU_BASE)/icu/source/lib/ -licuuc -licudata -o $@ $< + #xlc -q64 -I $(ICU_BASE)/icu/source/common/ -L$(ICU_BASE)/icu/source/lib/ -licuuc35 -licudata35 -o $@ $< + +testTimezone: testTimezone.c + #aCC +DD64 -I$(ICU_BASE)/icu/source/common/ -I$(ICU_BASE)/icu/source/i18n/ -L$(ICU_BASE)/icu/source/lib/ -licuuc -licudata -o $@ $< + #CC -xtarget=ultra -xarch=v9 -I$(ICU_BASE)/icu/source/common/ -I$(ICU_BASE)/icu/source/i18n/ -L$(ICU_BASE)/icu/source/lib/ -licuuc -licudata -o $@ $< + gcc -I $(ICU_BASE)/icu/source/common/ -I$(ICU_BASE)/icu/source/i18n/ -L$(ICU_BASE)/icu/source/lib/ -licuuc -licudata -o $@ $< + #gcc -I $(ICU_BASE)/icu/source/common/ -I$(ICU_BASE)/icu/source/i18n/ -L$(ICU_BASE)/icu/source/lib/ -licuuc -licudata -o $@ $< + #xlc -q64 -I $(ICU_BASE)/icu/source/common/ -I$(ICU_BASE)/icu/source/i18n/ -L$(ICU_BASE)/icu/source/lib/ -licuuc35 -licudata35 -o $@ $< + + +install-local: install-headers install-library + +install-library: all-local + +install-headers: + +dist-local: + +clean-local: +# test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES) + rm $(OBJECTS) $(ALL_TARGETS) $(SO_VERSION_DATA) + +distclean-local: clean-local + +check-local: + + diff --git a/tools/release/c/os-mapping/displayLocaleConv.c b/tools/release/c/os-mapping/displayLocaleConv.c new file mode 100644 index 00000000000..4380526fd6f --- /dev/null +++ b/tools/release/c/os-mapping/displayLocaleConv.c @@ -0,0 +1,35 @@ +/* +****************************************************************************** +* +* Copyright (C) 2006-2008, International Business Machines +* Corporation and others. All Rights Reserved. +* +****************************************************************************** +* +* FILE NAME : testTimezone.c +* +* Date Name Description +* 03/02/2006 grhoten Creation. +****************************************************************************** +*/ +#include "unicode/putil.h" +#include "unicode/ucnv.h" +#include "unicode/uloc.h" +#include "unicode/ures.h" +#include +#include + +int main(int argc, const char* const argv[]) { + UErrorCode status = U_ZERO_ERROR; + + ures_close(ures_open(NULL, NULL, &status)); + if (status != U_ZERO_ERROR) { + printf("uloc_getDefault = %s\n", uloc_getDefault()); + printf("Locale available in ICU = %s\n", status == U_ZERO_ERROR ? "TRUE" : "FALSE"); + } + if (strcmp(ucnv_getDefaultName(), "US-ASCII") == 0) { + printf("uprv_getDefaultCodepage = %s\n", uprv_getDefaultCodepage()); + printf("ucnv_getDefaultName = %s\n", ucnv_getDefaultName()); + } + return 0; +} diff --git a/tools/release/c/os-mapping/readme.txt b/tools/release/c/os-mapping/readme.txt new file mode 100644 index 00000000000..9dbb63844be --- /dev/null +++ b/tools/release/c/os-mapping/readme.txt @@ -0,0 +1,12 @@ +# +# Copyright (C) 2006-2008, International Business Machines +# Corporation and others. All Rights Reserved. +# + +These tests allow you to see how timezones, locales, charsets and other similar stuff are mapped from the OS values to ICU specific values. + +Some tweaking may be required to get these tools to work. + +If the charset maps to US-ASCII, it may be an indication that the alias or mapping table do not exist in ICU. +If the locale doesn't exist, the test will state that the locale is not available. +If the timezone doesn't match, it will be listed as a difference. \ No newline at end of file diff --git a/tools/release/c/os-mapping/testLocales.sh b/tools/release/c/os-mapping/testLocales.sh new file mode 100755 index 00000000000..a15e098865c --- /dev/null +++ b/tools/release/c/os-mapping/testLocales.sh @@ -0,0 +1,8 @@ +#!/bin/sh +#***************************************************************************** +# +# Copyright (C) 2006-2008, International Business Machines +# Corporation and others. All Rights Reserved. +# +#***************************************************************************** +for loc in `locale -a`; do echo ; echo LC_ALL=$loc ; LC_ALL=$loc ./displayLocaleConv ; done diff --git a/tools/release/c/os-mapping/testTimezone.c b/tools/release/c/os-mapping/testTimezone.c new file mode 100644 index 00000000000..e767ca64bfc --- /dev/null +++ b/tools/release/c/os-mapping/testTimezone.c @@ -0,0 +1,35 @@ +/* +****************************************************************************** +* +* Copyright (C) 2006-2008, International Business Machines +* Corporation and others. All Rights Reserved. +* +****************************************************************************** +* +* FILE NAME : testTimezone.c +* +* Date Name Description +* 03/02/2006 grhoten/mow Creation. +****************************************************************************** +*/ + +#include "unicode/putil.h" +#include "unicode/udat.h" +#include +#include +#include + +int main(int argc, const char* const argv[]) { + UErrorCode status = U_ZERO_ERROR; + char sysTimeStr[256]; + struct tm summerTimeTM; + struct tm winterTimeTM; + + memset(sysTimeStr, 0, sizeof(sysTimeStr)); + memset(&summerTimeTM, 0, sizeof(summerTimeTM)); + memset(&winterTimeTM, 0, sizeof(winterTimeTM)); + + strptime("2006-06-01 12:00", "%Y-%m-%d %H:%M", &summerTimeTM); + strftime(sysTimeStr, sizeof(sysTimeStr)-1, "%Y-%m-%d %H:%M", &summerTimeTM); + puts(sysTimeStr); +} diff --git a/tools/release/c/os-mapping/testTimezones.sh b/tools/release/c/os-mapping/testTimezones.sh new file mode 100755 index 00000000000..0495b519345 --- /dev/null +++ b/tools/release/c/os-mapping/testTimezones.sh @@ -0,0 +1,45 @@ +#!/bin/sh +#***************************************************************************** +# +# Copyright (C) 2006-2008, International Business Machines +# Corporation and others. All Rights Reserved. +# +#***************************************************************************** +timezones=`locate zoneinfo | fgrep -v evolution-data-server` +for tzone in $timezones +do + if [ -f $tzone ]; then + tzname=${tzone#/usr/share/zoneinfo/} + ICUTime=`LD_LIBRARY_PATH=../dev-icu/icu/source/lib/ TZ=$tzname ./checkTimezone` + systemHour=`TZ=$tzname date +%I` + # OS X does not allow %-I so this ugly mess needs to occur + if [ "${systemHour:0:1}" == "0" ]; then + systemHour=${systemHour:1:1} + fi + systemTimeShort=`TZ=$tzname date +%b\ %d,\ %Y` + systemTimeShort="${systemTimeShort} ${systemHour}" + systemTimeAMPM=`TZ=$tzname date +%p` + index1=`expr "$systemTimeShort" : '.*'` + index2=`expr "$ICUTime" : '.*'`-2 + ICUTimeShort=${ICUTime:0:${index1}} + ICUAMPM=${ICUTime:${index2}:2} + systemTime=`TZ=$tzname date +%b\ %d,\ %Y\ %r` + if [ "$systemTimeShort" == "$ICUTimeShort" ] && [ "$systemTimeAMPM" == "$ICUAMPM" ]; then + if [ "$opt1" != "-bad" ]; then + echo TZ=$tzname + echo System: $systemTime + echo ICU: $ICUTime + fi + else + if [ "$opt1" == "-all" ]; then + echo --TZ=$tzname + echo --System: $systemTime + echo --ICU: $ICUTime + else + echo TZ=$tzname + echo System: $systemTime + echo ICU: $ICUTime + fi + fi + fi +done