Text::...eGuess(3pm)

πŸ“¦
version 0.25 Β· 2 versions
  • 0.25 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.25 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ NAME ✨

Text::CSV::Encoded::Coder::EncodeGuess β€” it's a Text::CSV::Encoded coder class that uses Encode::Guess πŸ’…

okay bestie, quick vibe check: this is the Text::...eGuess(3pm) page, straight outta User Contributed Perl Documentation. let's go πŸ¦‹


🌸 VERSION 🌸

version 0.25 ✨


πŸŽ€ SYNOPSIS πŸŽ€

use Text::CSV::Encoded  coder_class => 'Text::CSV::Encoded::Coder::EncodeGuess';
use Spreadsheet::ParseExcel;

my $csv = Text::CSV::Encoded->new();

$csv->encoding( ['ucs2', 'ascii'] ); # guessing ucs2 or ascii?
$csv->encoding_to_combine('shiftjis');

my $excel = Spreadsheet::ParseExcel::Workbook->Parse( $file );
my $sheet = $excel->{Worksheet}->[0];

for my $row ( $sheet->{MinRow} .. $sheet->{MaxRow} ) {
    my @fields;

    for my $col ( $sheet->{MinCol} ..  $sheet->{MaxCol} ) {
        my $cell = $sheet->{Cells}[$row][$col];
        push @fields, $cell->{Val};
    }

    $csv->combine( @fields ) or die;
    print $csv->string, "\n";
}

πŸ’– DESCRIPTION πŸ’–

This module is inherited from Text::CSV::Encoded::Coder::Encode. that's it, that's the whole description, she's a nepo baby and we love her for it πŸ‘‘


🫢 USE 🫢

Except for 2 attributes, it's literally the same as Text::CSV::Encoded::Coder::Encode. two little special ones. those are the ones we're about to talk about, so stay with me 🧚

⭐ encoding_in ⭐

$csv = $csv->encoding_in( $encoding_list_ref );

The accessor to an encoding for pre-parsing CSV strings. If no encoding is given, it returns the current $encoding, otherwise it hands you back the object itself. (yes, chainable. slay πŸ’…)

$encoding_list_ref = $csv->encoding_in()

When you pass a list reference, it might guess the encoding from the given list πŸ‘€

$csv->encoding_in( ['shiftjis', 'euc-jp', 'iso-20022-jp'] );
If it cannot guess the encoding, the first encoding of the list is used. no cap, it just defaults to the first one fr fr

πŸ’œ encoding πŸ’œ

$csv = $csv->encoding( $encoding_list_ref );
$encoding_list_ref = $csv->encoding();

You can pass a list reference to this attribute only, and by "only" I mean:

  • For list data consumed by combine().
  • For list reference returned by getline().

In other word β€” in combine and print β€” it might guess an encoding for the passing list data πŸ‘‘ If it cannot guess the encoding, the first encoding of the list is used. same deal as above, bestie 🀝


πŸ¦‹ SEE ALSO πŸ¦‹

Encode, Encode::Guess β€” go read those too, they're the moment ✨


πŸ‘‘ AUTHOR πŸ‘‘

Makamaka Hannyaharamitu, <makamaka[at]cpan.org> 🫢


Copyright 2008-2013 by Makamaka Hannyaharamitu.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole page, bestie!! πŸ’– this absolute icon dropped with perl v5.36.0 on 2022-11-19, and yeah, the page name up top is the cursed truncated Text::...eGuess(3pm) version, iykyk πŸ’€βœ¨ periodt 🌸

πŸ“¦ where this page comes from