diff --git a/share/completions/gcc.fish b/share/completions/gcc.fish
index ba37d2810..de98c426e 100644
--- a/share/completions/gcc.fish
+++ b/share/completions/gcc.fish
@@ -464,9 +464,9 @@ complete -c gcc -o fdollars-in-identifiers --description '@anchor{fdollars-in-id
 complete -c gcc -o fextended-identifiers --description 'Accept universal character names in identifiers'
 complete -c gcc -o fpreprocessed --description 'Indicate to the preprocessor that the input file has already been preprocessed'
 complete -c gcc -o ftabstop --description 'Set the distance between tab stops'
-complete -c gcc -o fexec-charset --description 'Set the execution character set, used for string and character constants' -a "(iconv --list|sed -e 's|//||')"
-complete -c gcc -o fwide-exec-charset --description 'Set the wide execution character set, used for wide string and character constants' -a "(iconv --list|sed -e 's|//||')"
-complete -c gcc -o finput-charset --description 'Set the input character set, used for translation from the character set of the input file to the source character set used by GCC' -a "(iconv --list|sed -e 's|//||')"
+complete -c gcc -o fexec-charset --description 'Set the execution character set, used for string and character constants' -a "(__fish_print_encodings)"
+complete -c gcc -o fwide-exec-charset --description 'Set the wide execution character set, used for wide string and character constants' -a "(__fish_print_encodings)"
+complete -c gcc -o finput-charset --description 'Set the input character set, used for translation from the character set of the input file to the source character set used by GCC' -a "(__fish_print_encodings)"
 complete -c gcc -o fworking-directory --description 'Enable generation of linemarkers in the preprocessor output that will let the compiler know the current working directory at the time of preprocessing'
 complete -c gcc -o fno-show-column --description 'Do not print column numbers in diagnostics'
 complete -c gcc -s A --description 'Make an assertion with the predicate predicate and answer answer'
diff --git a/share/completions/iconv.fish b/share/completions/iconv.fish
index 68eea1fa7..e52c88f74 100644
--- a/share/completions/iconv.fish
+++ b/share/completions/iconv.fish
@@ -1,7 +1,7 @@
 
 
-complete -c iconv -s f -l from-code --description "Convert from specified encoding" -x -a "(iconv --list|sed -e 's|//||')"
-complete -c iconv -s t -l to-code --description "Convert to specified encoding" -x -a "(iconv --list|sed -e 's|//||')"
+complete -c iconv -s f -l from-code --description "Convert from specified encoding" -x -a "(__fish_print_encodings)"
+complete -c iconv -s t -l to-code --description "Convert to specified encoding" -x -a "(__fish_print_encodings)"
 complete -c iconv -l list --description "List known coded character sets"
 complete -c iconv -s o -l output --description "Output file" -r
 complete -c iconv -l verbose --description "Print progress information"
diff --git a/share/completions/xterm.fish b/share/completions/xterm.fish
index 13671c08f..1bd3da5e2 100644
--- a/share/completions/xterm.fish
+++ b/share/completions/xterm.fish
@@ -1,8 +1,5 @@
 # completion for xterm
 
-function __fish_complete_xterm_encoding -d "Complete encoding information for xterm"
-    iconv --list|sed -e 's|//||'
-end
 
 complete -c xterm -n '__fish_test_arg "+*"' -a +ah --description 'Never highlight the text cursor'
 complete -c xterm -n '__fish_test_arg "+*"' -a +ai --description 'Enable active icon support'
@@ -107,7 +104,7 @@ complete -r -c xterm -o bcf --description 'Blinking cursor will be off for that
 complete -r -c xterm -o bcn --description 'Blinking cursor will be on for that many milliseconds'
 complete -r -c xterm -o class --description 'Override xterm resource class'
 complete -r -c xterm -o cr --description 'Color for the text cursor'
-complete -r -c xterm -o en -xa "(__fish_complete_xterm_encoding )" --description 'xterm encoding'
+complete -r -c xterm -o en -xa "(__fish_print_encodings)" --description 'xterm encoding'
 complete -r -c xterm -o fb --description 'Bold font'
 complete -r -c xterm -o fa --description 'FreeType font pattern'
 complete -r -c xterm -o fd --description 'FreeType double-width font pattern'
diff --git a/share/functions/__fish_print_encodings.fish b/share/functions/__fish_print_encodings.fish
new file mode 100644
index 000000000..5770330b4
--- /dev/null
+++ b/share/functions/__fish_print_encodings.fish
@@ -0,0 +1,3 @@
+function __fish_print_encodings -d "Complete using available character encodings"
+    iconv --list|sed -e 's|//||'
+end