From f964be5c98cd37c27eea03a27dacca1ee65cdb5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Wed, 19 Dec 2012 18:04:31 +0100 Subject: [PATCH] Sql.mysql: Avoid automatic downgrading from utf8 to iso-8859-1. --- lib/modules/Sql.pmod/mysql.pike | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/modules/Sql.pmod/mysql.pike b/lib/modules/Sql.pmod/mysql.pike index 6e9c9b6f9f..9bb6f18453 100644 --- a/lib/modules/Sql.pmod/mysql.pike +++ b/lib/modules/Sql.pmod/mysql.pike @@ -678,9 +678,12 @@ int decode_datetime (string timestr) } \ \ else { /* utf8_mode & UTF8_UNICODE_ENCODE_MODE */ \ - if (_can_send_as_latin1 (query)) \ - new_send_charset = "latin1"; \ - else { \ + /* NB: The send_charset may only be upgraded from \ + * "latin1" to "utf8", not the other way around. \ + * This is to avoid extraneous charset changes \ + * where the charset is changed from query to query. \ + */ \ + if ((send_charset == "utf8") || !_can_send_as_latin1(query)) { \ CH_DEBUG ("Converting query to utf8.\n"); \ query = utf8_encode_query (query, string_to_utf8); \ new_send_charset = "utf8"; \ -- GitLab