summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mysql.sml17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mysql.sml b/src/mysql.sml
index 472b72d1..e34efbd4 100644
--- a/src/mysql.sml
+++ b/src/mysql.sml
@@ -551,6 +551,23 @@ fun init {dbstring, prepared = ss, tables, views, sequences} =
newline,
string "}",
newline,
+ newline,
+ string "if (mysql_set_character_set(mysql, \"utf8\")) {",
+ newline,
+ box [string "char msg[1024];",
+ newline,
+ string "strncpy(msg, mysql_error(mysql), 1024);",
+ newline,
+ string "msg[1023] = 0;",
+ newline,
+ string "mysql_close(mysql);",
+ newline,
+ string "uw_error(ctx, FATAL, ",
+ string "\"Error setting UTF-8 character set for MySQL connection: %s\", msg);"],
+ newline,
+ string "}",
+ newline,
+ newline,
string "conn = calloc(1, sizeof(uw_conn));",
newline,
string "conn->conn = mysql;",