[tz] [PROPOSED 12/18] tzselect: port to POSIX iconv

Paul Eggert eggert at cs.ucla.edu
Tue Dec 19 07:26:01 UTC 2023


* NEWS: Mention this.
* tzselect.ksh: If iconv does not support support
the GNU //TRANSLIT extension, fall back on POSIX iconv.
This is needed, for example, on Solaris 10.
---
 NEWS         | 3 +++
 tzselect.ksh | 7 +++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index a0d87bf6..4360a4b6 100644
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,9 @@ Unreleased, experimental changes
     tzselect no longer mishandles TZ strings when using mawk 1.4.3,
     which mishandles regular expressions of the form /X{2,}/.
 
+    tzselect no longer mishandles non-UTF-8 locales on platforms
+    where the iconv command lacks the GNU //TRANSLIT extension.
+
     zic no longer mishandles data for Palestine after the year 2075.
     Previously, it incorrectly omitted post-2075 transitions that are
     predicted for just before and just after Ramadan.  (Thanks to Ken
diff --git a/tzselect.ksh b/tzselect.ksh
index 91ba572a..43d91799 100644
--- a/tzselect.ksh
+++ b/tzselect.ksh
@@ -200,8 +200,11 @@ $translit && {
 	(umask 77 && mkdir -- "$tmp")
     };} &&
     trap 'status=$?; rm -fr -- "$tmp"; exit $status' 0 HUP INT PIPE TERM &&
-    (iconv -f UTF-8 -t //TRANSLIT <"$TZ_COUNTRY_TABLE" >$tmp/iso3166.tab) \
-        2>/dev/null &&
+    { (iconv -f UTF-8 -t //TRANSLIT <"$TZ_COUNTRY_TABLE" >$tmp/iso3166.tab) \
+        2>/dev/null ||
+      (iconv -f UTF-8 <"$TZ_COUNTRY_TABLE" >$tmp/iso3166.tab) \
+        2>/dev/null
+    } &&
     TZ_COUNTRY_TABLE=$tmp/iso3166.tab &&
     iconv -f UTF-8 -t //TRANSLIT <"$TZ_ZONE_TABLE" >$tmp/$zonetabtype.tab &&
     TZ_ZONE_TABLE=$tmp/$zonetabtype.tab
-- 
2.40.1




More information about the tz mailing list