I'm using Go sqlx package to make queries on MariaDB database and I'd like to be able to save non-ascii form submitted values into the database.
Here is the function:
func QuoteCreate(content string, author string) error {
var err error
fmt.Println("content, author", content, author)
_, err = database.SQL.Exec("INSERT INTO quote (content, author) VALUES (?,?)", content, author)
if err != nil {
fmt.Println(err)
}
return standardizeError(err)
}
The quote
tables has utf8_general_cli
colation and InnoDB
engine. However the content
and author
values submitted by form are saved as ???
when the values are not ascii characters (I tried Persian and simplified chinese).
I have also tried utf8_unicode_cli
for the table colation, but got the same problem. Interestingly, non-ascii characters are shown correctly when printed on terminal befor being saved.
So I'm left clueless what's wrong here and how can I fix it?