Output encoding, Web vs CLI

Hi all,

when I run a script using RT::Interface::CLI, everything I get (such as
a CF value or correspondance) is ISO-8859-1. Same code in a mason
template in share/html give UTF-8.

Do I miss some initialization in myu script to get UTF-8?

-----script—
#!/usr/bin/perl -w

Extract customfields

use strict;
use lib “/home/rt/rt/lib”;
use RT;
use RT::Interface::CLI qw( CleanEnv GetCurrentUser );
use RT::User;

RT CLI initialization

CleanEnv();
RT::LoadConfig();
RT::Init();

Get the current user all loaded

our $CurrentUser = GetCurrentUser();

my $ticket = RT::Ticket->new( $CurrentUser);
$ticket->Load(13595);
if ((my $values = $ticket->CustomFieldValues (‘essai’)))
{
print $values->First->Content."\n";
}

-------Mason----
<%INIT>
my $ticket = RT::Ticket->new( $CurrentUser);
$ticket->Load(13595);
my $values = $ticket->CustomFieldValues (‘essai’);
</%INIT>
<% $values->First->Content %>

I did with putty changing the translation to utf8.

Best regards,

ALBERTO VILLANUEVA VAL
Consultor
Altran
ParqueEmpresarial Las Mercedes, Edificio 1
C/ Campezo, 1. 28022 Madrid
Tel : + 34 91 744 46 00
Fax: + 34 91 415 24 57
www.altran.es-----Mensaje original-----
De: rt-users-bounces@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] En nombre de Emmanuel Lacour
Enviado el: viernes, 03 de abril de 2009 12:19
Para: rt-users@lists.bestpractical.com
Asunto: [rt-users] Output encoding, Web vs CLI

Hi all,

when I run a script using RT::Interface::CLI, everything I get (such as
a CF value or correspondance) is ISO-8859-1. Same code in a mason
template in share/html give UTF-8.

Do I miss some initialization in myu script to get UTF-8?

-----script—
#!/usr/bin/perl -w

Extract customfields

use strict;
use lib “/home/rt/rt/lib”;
use RT;
use RT::Interface::CLI qw( CleanEnv GetCurrentUser );
use RT::User;

RT CLI initialization

CleanEnv();
RT::LoadConfig();
RT::Init();

Get the current user all loaded

our $CurrentUser = GetCurrentUser();

my $ticket = RT::Ticket->new( $CurrentUser);
$ticket->Load(13595);
if ((my $values = $ticket->CustomFieldValues (‘essai’)))
{
print $values->First->Content."\n";
}

-------Mason----
<%INIT>
my $ticket = RT::Ticket->new( $CurrentUser);
$ticket->Load(13595);
my $values = $ticket->CustomFieldValues (‘essai’);
</%INIT>
<% $values->First->Content %>

http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Hi all,

when I run a script using RT::Interface::CLI, everything I get (such as
a CF value or correspondance) is ISO-8859-1. Same code in a mason
template in share/html give UTF-8.

Do I miss some initialization in myu script to get UTF-8?

Seems I need to do this:

$data = Encode::encode_utf8($data);

to get utf8 octets.

Hi all,

when I run a script using RT::Interface::CLI, everything I get (such as
a CF value or correspondance) is ISO-8859-1. Same code in a mason
template in share/html give UTF-8.

Do I miss some initialization in myu script to get UTF-8?

I have a sneaking suspicion this is related to Locale::Maketext::Lexicon
being “smart”

What have you set your environment/locale to in that shell?
Can you reduce this to a test we can drop into the RT test suite?

I have a sneaking suspicion this is related to Locale::Maketext::Lexicon
being “smart”

What have you set your environment/locale to in that shell?
Can you reduce this to a test we can drop into the RT test suite?

$ locale
LANG=fr_FR.UTF-8
LC_CTYPE="fr_FR.UTF-8"
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_PAPER="fr_FR.UTF-8"
LC_NAME="fr_FR.UTF-8"
LC_ADDRESS="fr_FR.UTF-8"
LC_TELEPHONE="fr_FR.UTF-8"
LC_MEASUREMENT="fr_FR.UTF-8"
LC_IDENTIFICATION="fr_FR.UTF-8"
LC_ALL=fr_FR.UTF-8
$ ./test.pl > out
$ file out
out: ISO-8859 text
$

I get proper utf-8 if I do print Encode::encode(‘utf-8’, $data)

LC_ALL=fr_FR.UTF-8
$ ./test.pl > out
$ file out
out: ISO-8859 text
$

Oh. Hang on. Perl ALWAYS magically autopromotes things to Latin-1 if
you’re not both careful and explicit. perluniintro starts to explain the
problem.