diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
index 2e11bb0..a277ab9 100644
--- a/poppler/GlobalParams.cc
+++ b/poppler/GlobalParams.cc
@@ -748,7 +748,7 @@ GlobalParams::GlobalParams(const char *customPopplerDataDir)
 void GlobalParams::scanEncodingDirs() {
   GDir *dir;
   GDirEntry *entry;
-  const char *dataRoot = popplerDataDir ? popplerDataDir : POPPLER_DATADIR;
+  const char *dataRoot = popplerDataDir ? popplerDataDir : ( getenv("POPPLER_DATADIR") ? getenv("POPPLER_DATADIR") : POPPLER_DATADIR );
   
   // allocate buffer large enough to append "/nameToUnicode"
   size_t bufSize = strlen(dataRoot) + strlen("/nameToUnicode") + 1;
