Bug 41789

Summary: EDIFACT messages broken by unidecode
Product: Koha Reporter: Andreas Jonsson <andreas.jonsson>
Component: AcquisitionsAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low    
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:

Description Andreas Jonsson 2026-02-06 15:31:57 UTC
In EDI.pm EDIFACT messages are built and the result is passed to unidecode.  However, unidecode replace unicode characters with the transliterated ascii characters which may include characters that have special meaning including apostrophe '.

    my $order_file = $edifact->encode();

    # ingest result
    if ($order_file) {
        my $m = unidecode($order_file);    # remove diacritics and non-latin chars

But this must be done before escaping special characters. For instance:

diff --git a/Koha/Edifact/Order.pm b/Koha/Edifact/Order.pm
index a36bd7e1b5b..096e66d5f3e 100644
--- a/Koha/Edifact/Order.pm
+++ b/Koha/Edifact/Order.pm
@@ -27,6 +27,7 @@ use Readonly qw( Readonly );
 use Koha::Database;
 use Koha::DateUtils qw( dt_from_string );
 use C4::Budgets     qw( GetBudget );
+use Text::Unidecode qw( unidecode );
 
 use Koha::Acquisition::Orders;
 
@@ -685,6 +686,7 @@ sub _interchange_sr_identifier {
 sub encode_text {
     my $string = shift;
     if ($string) {
+        $string = unidecode( $string );
         $string =~ s/[?]/??/g;
         $string =~ s/'/?'/g;
         $string =~ s/:/?:/g;