[MDEV-4249] MYSQL_AUTODETECT_CHARACTER_SET option doesn't work with Windows GUI applications Created: 2013-03-06  Updated: 2013-03-12  Resolved: 2013-03-12

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.2, 5.5.29
Fix Version/s: 5.5.31

Type: Bug Priority: Major
Reporter: Georg Richter Assignee: Vladislav Vaintroub
Resolution: Fixed Votes: 0
Labels: None
Environment:

Windows



 Description   

The option MYSQL_AUTODETECT_CHARACTER_SET doesn't work with Windows GUI applications, since the function mysql_autodetect_character_set()tries to retrieve the current codepage via GetConsoleCP() windows api function.
In a GUI environment GetConsoleCP() returns 0 as current codepage.

5.x Versions are affected too.

Suggested fix:

=== modified file 'sql-common/client.c'
--- sql-common/client.c 2013-01-31 08:48:19 +0000
+++ sql-common/client.c 2013-03-06 09:11:33 +0000
@@ -2239,7 +2239,8 @@
 #ifdef __WIN__
   char cpbuf[64];
   {
-    my_snprintf(cpbuf, sizeof(cpbuf), "cp%d", (int) GetConsoleCP());
+    my_snprintf(cpbuf, sizeof(cpbuf), "cp%d", 
+                (GetConsoleWindow()) ? (int) GetConsoleCP() : (int) GetACP());
     csname= my_os_charset_to_mysql_charset(cpbuf);
   }
 #elif defined(HAVE_SETLOCALE) && defined(HAVE_NL_LANGINFO)


Generated at Thu Feb 08 06:54:57 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.