From a18c7d163a5338204522b0b856b80e9e3baa7fd6 Mon Sep 17 00:00:00 2001 From: Ivan Bessarabov Date: Sun, 12 Nov 2023 08:17:24 +0000 Subject: [PATCH] =?UTF-8?q?--separator=3D=D0=A4=20is=20working=20as=20expe?= =?UTF-8?q?cted?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/data/separator_unicode/cmd_and_expected_output | 3 +++ tests/data/separator_unicode/separator_unicode.tsv | 2 ++ tsv2table | 6 ++++++ 3 files changed, 11 insertions(+) create mode 100644 tests/data/separator_unicode/cmd_and_expected_output create mode 100644 tests/data/separator_unicode/separator_unicode.tsv diff --git a/tests/data/separator_unicode/cmd_and_expected_output b/tests/data/separator_unicode/cmd_and_expected_output new file mode 100644 index 0000000..0f23100 --- /dev/null +++ b/tests/data/separator_unicode/cmd_and_expected_output @@ -0,0 +1,3 @@ +$ cat $TEST_DIR/separator_unicode.tsv | $TSV2TABLE --separator=Ф +1 | 2 +a | b | c diff --git a/tests/data/separator_unicode/separator_unicode.tsv b/tests/data/separator_unicode/separator_unicode.tsv new file mode 100644 index 0000000..670772f --- /dev/null +++ b/tests/data/separator_unicode/separator_unicode.tsv @@ -0,0 +1,2 @@ +1Ф2 +aФbФc diff --git a/tsv2table b/tsv2table index f3a3d2c..ac8858c 100755 --- a/tsv2table +++ b/tsv2table @@ -6,7 +6,9 @@ use feature qw(say); use utf8; use open qw(:std :utf8); +use Encode qw(decode); use Getopt::Long; +use I18N::Langinfo qw(CODESET langinfo); sub parse_options { @@ -14,6 +16,9 @@ sub parse_options { my $separator; my $help; + my $codeset = langinfo(CODESET); + @ARGV = map { decode $codeset, $_ } @ARGV; + GetOptions ( 'header=s' => \$header, 'separator=s' => \$separator, @@ -81,6 +86,7 @@ https://github.com/bessarabov/tsv2table separator => $separator, }; + return $options; } # my ($type, $non_fractional_length, $fractional_length) = get_type('13.123'); # ('float', 2, 4)