@@ -, +, @@ Text::Unaccent::unac_string unac_string: Invalid or incomplete multibyte or wide character Return the unaccented equivalent of the string $string. The character set of $string is specified by the $charset argument. The returned string is coded using the same character set. $userid = unac_string('utf-8',$userid); --- Koha/Patron.pm | 3 ++- t/db_dependent/Koha/Patrons.t | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) --- a/Koha/Patron.pm +++ a/Koha/Patron.pm @@ -21,6 +21,7 @@ package Koha::Patron; use Modern::Perl; use Carp; +use Encode qw/encode_utf8 decode_utf8/; use List::MoreUtils qw( uniq ); use JSON qw( to_json ); use Text::Unaccent qw( unac_string ); @@ -1313,7 +1314,7 @@ sub generate_userid { $firstname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g; $surname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g; my $userid = lc(($firstname)? "$firstname.$surname" : $surname); - $userid = unac_string('utf-8',$userid); + $userid = decode_utf8(unac_string('utf-8',encode_utf8($userid))); $userid .= $offset unless $offset == 0; $self->userid( $userid ); $offset++; --- a/t/db_dependent/Koha/Patrons.t +++ a/t/db_dependent/Koha/Patrons.t @@ -18,6 +18,7 @@ # along with Koha; if not, see . use Modern::Perl; +use utf8; use Test::More tests => 34; use Test::Warn; @@ -1389,8 +1390,8 @@ subtest 'generate_userid' => sub { ); my %data = ( cardnumber => "123456789", - firstname => "Tomasito", - surname => "None", + firstname => "Tomasíto", # accent + surname => "Ñòñé", # accents categorycode => $patron_category->categorycode, branchcode => $library->branchcode, ); --