The Problem – Rendering Unicode Characters using Glabels

I have a Perl script running on an Apache webserver that launches glabels-3-batch and given a data input file and a glabels template outputs a label as a PDF document.

This is in a Ubuntu 18.04.1 LTS container running on Docker Community Edition on my MacBook Pro

The problem is that I have been using a \beta  (beta) character in the file and when running from the command line with a UTF-8 language configured (en_AU.UTF-8) it works fine…

But from a web server, which is running as the www-data user the line with the \beta (beta) value in it is missing…

I’ve traced the problem to not having a LANG environment variable specified in the environment that the www-data user is running under.

What doesn’t work

I tried adding
PerlSetEnv LANG en_AU.UTF-8
to /etc/apache/apache2.conf
I also tried adding 
export LANG=en_AU.UTF-8
to /etc/apache/envars
But both of the above didn’t add the LANG setting to the environment

The Fix

To test the environment I used this script placed at cgi-bin/

What worked was adding
SetEnv LANG en_AU.UTF-8
to /etc/apache/apache2.conf

Viewing your mod_perl / CGI Environment

#!/usr/bin/perl -wT
use strict;
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);

print header;
print start_html("Environment");

foreach my $key (sort(keys(%ENV))) {
    print "$key = $ENV{$key}<br>\n";