Q:

Convert stdout to utf8 in bash

I want to convert the output of any website got with curl into utf8 for a database Insert.
usage ex:

html="$(curl -iL -compressed "$link")"

##code needed to convert nonUTF8 $html to utf8, preferably without writing to file

## escape characters for insert
html_q="${html//'\'/\\\\}"
html_q="${html_q//"'"/\'}"

## the insert statement
sqlHtml='INSERT INTO `'"${tableHtml}"'` (`html`) VALUES ('"'${html_q}'"');'
mysql -u$dbUser -p$dbPass -h$dbHost -P$dbPort -D$dbName --default_character_set utf8 -A <<ENDofMESSAGE
${sqlHtml}
ENDofMESSAGE

A:

Short question, short answer : 
man iconv
Now, you have one more problem : determining what is the source encoding of your web page. (tip: type charsetdetector in google)

