diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
index 31e3b16..0cd3237 100644
*** a/src/backend/utils/adt/pg_locale.c
--- b/src/backend/utils/adt/pg_locale.c
*************** PGLC_localeconv(void)
*** 505,510 ****
--- 505,517 ----
  	}
  
  	/*
+ 	 * Ensure the global locale is being used by localeconv().
+ 	 * This is necessary, for example, if another loaded library
+ 	 * such as libperl has done uselocale() underneath us.
+ 	 */
+ 	uselocale(LC_GLOBAL_LOCALE);
+ 
+ 	/*
  	 * This is tricky because we really don't want to risk throwing error
  	 * while the locale is set to other than our usual settings.  Therefore,
  	 * the process is: collect the usual settings, set locale to special
diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c
index 7af1ccb..4ef4d9e 100644
*** a/src/fe_utils/print.c
--- b/src/fe_utils/print.c
*************** setDecimalLocale(void)
*** 3628,3633 ****
--- 3628,3639 ----
  {
  	struct lconv *extlconv;
  
+ 	/*
+ 	 * Ensure the global locale is being used by localeconv().
+ 	 * This is necessary, for example, if another loaded library
+ 	 * has done uselocale() underneath us.
+ 	 */
+ 	uselocale(LC_GLOBAL_LOCALE);
  	extlconv = localeconv();
  
  	/* Don't accept an empty decimal_point string */
