Bugzilla – Attachment 179301 Details for
Bug 39327
UTF-8 BOM missing from label creator CSV and some UTF-8 output broken
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39327: Add BOM to label CSV output and set output layer to UTF-8
Bug-39327-Add-BOM-to-label-CSV-output-and-set-outp.patch (text/plain), 1.84 KB, created by
David Cook
on 2025-03-14 06:14:50 UTC
(
hide
)
Description:
Bug 39327: Add BOM to label CSV output and set output layer to UTF-8
Filename:
MIME Type:
Creator:
David Cook
Created:
2025-03-14 06:14:50 UTC
Size:
1.84 KB
patch
obsolete
>From 48771bd5ecfe2595954fa1819c5a808c4a6f95b5 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Fri, 14 Mar 2025 06:00:26 +0000 >Subject: [PATCH] Bug 39327: Add BOM to label CSV output and set output layer > to UTF-8 >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This change adds a BOM to the label CSV output, so that >Excel properly recognizes the data as UTF-8. > >It also sets the output layer to UTF-8, so that Text::CSV_XS library >always outputs UTF-8 even when it thinks a string might not be (see >below) > >To reproduce: >1. Make a cataloguing record with the minimum requirements filled in >2. Set 100$a to Chödrön, Pema >3. Add an item with a barcode >4. Repeat this process but use æç±ä½ for the 100$a > >5. Create a new label batch >6. Add the item to the batch >7. Export using the defaults >8. click "Download as CSV" >9. Note that Chödrön appears correctly but the Chinese does not > >Test plan: >1. Apply the patch and koha-plack --restart kohadev >2. Do the "To reproduce" plan >3. Note that both Chödrön and æç±ä½ appear correctly >4. If you were to inspect the bytes, you'd see that the output is UTF-8 >encoded after the patch while Chödrön before the patch is Latin-1 encoded >(ie ö when UTF-8 encoded is C3B6 and in Latin-1 it's encoded as F6) >--- > labels/label-create-csv.pl | 4 ++++ > 1 file changed, 4 insertions(+) > >diff --git a/labels/label-create-csv.pl b/labels/label-create-csv.pl >index 1eeb42b685..1f0b4e770a 100755 >--- a/labels/label-create-csv.pl >+++ b/labels/label-create-csv.pl >@@ -71,6 +71,10 @@ if (@label_ids) { > > my $csv = Text::CSV_XS->new( { formula => "empty" } ); > >+# Add BOM for UTF-8 encoded CSV >+print "\xEF\xBB\xBF"; >+binmode STDOUT, ':encoding(UTF-8)'; >+ > foreach my $item (@$items) { > my $label = C4::Labels::Label->new( > batch_id => $batch_id, >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 39327
:
179301
|
179362