[tz] [PROPOSED PATCH 3/3] tzselect now uses UTF-8 if available

Paul Eggert eggert at cs.ucla.edu
Sun May 3 06:25:27 UTC 2015


* NEWS: Document this.
* tzselect.ksh (utf8_locale): New var.
Use it to select a UTF-8 locale if available.
---
 NEWS         |  4 ++++
 tzselect.ksh | 12 ++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/NEWS b/NEWS
index 407258d..b77cd03 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,10 @@ Unreleased, experimental changes
     The file 'iso3166.tab' now uses UTF-8, so that its entries can better
     spell the names of Åland Islands, Côte d'Ivoire, and Réunion.
 
+  Changes affecting code
+
+    tzselect aligns UTF-8 columns better, if a UTF-8 locale is available.
+
 
 Release 2015d - 2015-04-24 08:09:46 -0700
 
diff --git a/tzselect.ksh b/tzselect.ksh
index 3acdebd..b288cdf 100644
--- a/tzselect.ksh
+++ b/tzselect.ksh
@@ -44,6 +44,18 @@ REPORT_BUGS_TO=tz at iana.org
 	exit 1
 }
 
+# Use a UTF-8 locale if available, as the data contain UTF-8,
+# and the shell aligns columns better that way.
+# Check the UTF-8 of U+12345 CUNEIFORM SIGN URU TIMES KI.
+utf8_locale='BEGIN { u12345 = "\360\222\215\205"; exit length(u12345) != 1 }'
+$AWK "$utf8_locale" ||
+    for locale in en_US.utf8 en_US.UTF-8 C.utf8; do
+	(LC_ALL=$locale $AWK "$utf8_locale") 2>/dev/null && {
+	    export LC_ALL=$locale
+	    break
+	}
+    done
+
 coord=
 location_limit=10
 zonetabtype=zone1970
-- 
2.1.4



More information about the tz mailing list