From 4865341e271e149952e0980db024602ab3507f7c Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Wed, 11 Nov 2026 14:09:22 -0600 Subject: [PATCH] Fix "Wide character in print" warnings from `WeBWorK::Debug::debug`. Debug messages printed to STDERR were not encoded, and so messages containing wide characters caused warnings. Encode them as UTF-8 first. This issue occurs when the general debugging facility is enabled in the `conf/webwork2.mojolicious.yml` file and the `logfile` is not set (or if the `logfile` is set, but cannot be opened). So this is typically only when using morbo, since usually you would use the `logfile` setting in production with hypnotoad. One way to test this is to enable debugging and go to the set detail page and edit a set for a user and press "Save Changes" (you don't need to actually change any settings). Since the dates contain narrow non-breaking space you will see a warning about a wide character in print. --- lib/WeBWorK/Debug.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/WeBWorK/Debug.pm b/lib/WeBWorK/Debug.pm index d478dfae2a..206af6850a 100644 --- a/lib/WeBWorK/Debug.pm +++ b/lib/WeBWorK/Debug.pm @@ -5,6 +5,7 @@ use strict; use warnings; use Date::Format; +use Encode qw(encode_utf8); use Time::HiRes qw/gettimeofday/; use WeBWorK::Utils qw/undefstr/; @@ -98,10 +99,10 @@ sub debug { close $fh; } else { warn "Failed to open debug log '$Logfile' in append mode: $!"; - print STDERR $finalMessage; + print STDERR encode_utf8($finalMessage); } } else { - print STDERR $finalMessage; + print STDERR encode_utf8($finalMessage); } }