diff --git a/util/texi2dvi b/util/texi2dvi
index ac4a7db6ef..036f149b26 100755
--- a/util/texi2dvi
+++ b/util/texi2dvi
@@ -55,6 +55,8 @@ textra=         # Extra TeX commands to insert in the input file.
 txiprereq=19990129 # minimum texinfo.tex version with macro expansion
 verb=false      # true for verbose mode
 translate_file= # name of charset translation file
+texindexlocale_set=false # Set LC_ALL according to @documentlanguage and @documentencoding.
+
 
 # We have to initialize IFS to space tab newline since we save and
 # restore IFS and apparently POSIX allows stupid/broken behavior with
@@ -354,8 +356,28 @@ report ()
 run ()
 {
   verbose "Running $@"
-  "$@" 2>&5 1>&2 \
-  || error 1 "$1 failed"
+  case "$1" in
+    *=*)
+    (
+      again=true;
+      while $again; do
+	export "$1"
+	shift
+	case "$1" in
+	  *=*) ;;
+	  *)
+	  again=false;
+	  "$@" 2>&5 1>&2 \
+	    || error 1 "$1 failed"
+	  ;;
+	esac
+      done
+    )
+    ;;
+    *)
+    "$@" 2>&5 1>&2 \
+      || error 1 "$1 failed"
+  esac
 }
 
 
@@ -969,7 +991,21 @@ run_index ()
       ;;
 
     texinfo)
-      run $TEXINDEX $index_files
+      if $texindexlocale_set; then :; else
+	_document_encoding=`$SED  -ne 's/^[[:blank:]]*@documentencoding[[:blank:]]\+\([-A-Z0-9a-z]\+\).*$/\1/p' -e '/^[[:blank:]]*@documentencoding[[:blank:]]/q' -e '64q' $command_line_filename`
+	_document_language=`$SED  -ne 's/^[[:blank:]]*@documentlanguage[[:blank:]]\+\([_A-Z0-9a-z]\+\).*$/\1/p' -e '/^[[:blank:]]*@documentlanguage[[:blank:]]/q' -e '64q' $command_line_filename`
+	if [ -z "$_document_encoding" ]; then
+	  TEXINDEXLOCALE=''
+	else
+	  if [ -z "$_document_language" ]; then
+	    TEXINDEXLOCALE="LC_ALL=C.$_document_encoding "
+	  else
+	    TEXINDEXLOCALE="LC_ALL=$_document_language.$_document_encoding "
+	  fi
+	fi
+	texindexlocale_set=true;
+      fi
+      run $TEXINDEXLOCALE$TEXINDEX $index_files
       ;;
   esac
 }
