| 1 |
# Date: Sun, 16 Mar 2008 18:51:14 +0100 |
| 2 |
# From: Hermann Peifer <[email protected]> |
| 3 |
# Subject: [Fwd: Gawk FIELDWIDTHS and multibyte characters] |
| 4 |
# To: [email protected] |
| 5 |
# Message-id: <[email protected]> |
| 6 |
# |
| 7 |
# See below. Regards, Hermann |
| 8 |
# |
| 9 |
# --- Original Message --- |
| 10 |
# |
| 11 |
# Newsgroups: comp.lang.awk |
| 12 |
# From: Hermann Peifer <[email protected]> |
| 13 |
# Date: Sun, 16 Mar 2008 01:23:38 -0700 (PDT) |
| 14 |
# Subject: Gawk FIELDWIDTHS and multibyte characters |
| 15 |
# |
| 16 |
# Hi, |
| 17 |
# |
| 18 |
# It looks to me that Gawk's FIELDWIDTHS extension is not aware of |
| 19 |
# multibyte characters, see my example below. |
| 20 |
# |
| 21 |
# $ cat testdata |
| 22 |
# CDRegion Commune Site |
| 23 |
# SEVästsverige Hallands län Kungsbacka |
| 24 |
# SESmåland med öarna Västra Götalands länGöteborg |
| 25 |
# SEKronoberg Alvesta Stenungsund |
| 26 |
# |
| 27 |
# $ file testdata |
| 28 |
# testdata: UTF-8 Unicode text |
| 29 |
# |
| 30 |
# $ awk 'BEGIN{FIELDWIDTHS = "2 20 20 20"}{print $4}' testdata |
| 31 |
# Site |
| 32 |
# Kungsbacka |
| 33 |
# länGöteborg |
| 34 |
# Stenungsund |
| 35 |
# |
| 36 |
# Can someone confirm? |
| 37 |
# |
| 38 |
# Hermann |
| 39 |
BEGIN { FIELDWIDTHS = "2 20 20 20" } |
| 40 |
{ print $4 } |