Something I have done is to make queries and export them in some way to a file, be it a csv, etc.
Since you have that csv you can pass it a $file <archivo que exportaste>
and see the coding there.
Afterwards, that encoding is used in the command:
$iconv -f <la codificación que obtuviste> -t <a la que la quieres pasar> <archivo que exportaste> > archivo_nueva_codificacion.txt
Here there are good examples to a related question.
Just as an additional comment, I know you asked for Linux, but if at some point you are doing a web service that queries a database and has strange characters, you could generate a function similar to this in python that I use. Of course, according to the language of your preference, I just want to make you understand the idea.
def func_encode_to_utf(x):
if 'utf-8' not in chardet.detect(x)['encoding'].lower():
x = x.decode(chardet.detect(x)['encoding']).encode('utf-8')
return x
And the mechanics are the same, know the coding of a character and then, if it is not "UTF-8" (in my case), I pass it to "UTF-8"