[PATCH] [win32] set default locale to "English" in statistics.c
Lubomir I. Ivanov
neolit123 at gmail.com
Wed Nov 2 20:20:31 PDT 2011
From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
sets the default locale to "English" in statistics.c for win32.
it seems that mingw/GTK outputs xxxxxx, xxxxx characters
for Day, Month (%a, %b) on a non english locale Windows system
until 'setlocale(LC_ALL, "English")' is specified.
pending for a better fix perhaps, yet all units
might need to be translated as well, following this logic
- e.g. cyrilic "m" for meters and "kg" for kilograms.
uses _tsetlocale for eventual unicode support on win32.
[win32] additionally for gtk-gui.c:
use (LPCTSTR) casts for string literals - eventual unicode support.
Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
gtk-gui.c | 10 +++++-----
statistics.c | 14 ++++++++++++--
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/gtk-gui.c b/gtk-gui.c
index da6d9a2..79e3e7b 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -419,7 +419,7 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
gconf_client_set_string(gconf, GCONF_NAME(divelist_font), divelist_font, NULL);
#else
HKEY hkey;
- LONG success = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\subsurface"),
+ LONG success = RegCreateKeyEx(HKEY_CURRENT_USER, (LPCTSTR)"Software\\subsurface",
0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
NULL, &hkey, NULL);
if (success != ERROR_SUCCESS)
@@ -428,7 +428,7 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
#define StoreInReg(_key, _val) { \
value = (_val) ; \
- RegSetValueEx(hkey, TEXT(_key), 0, REG_DWORD, (BYTE *)&value, 4); \
+ RegSetValueEx(hkey, (LPCTSTR)_key, 0, REG_DWORD, (BYTE *)&value, 4); \
}
StoreInReg("feet", output_units.length == FEET);
@@ -731,7 +731,7 @@ static int get_from_registry(HKEY hkey, const char *key)
DWORD len = 4;
LONG success;
- success = RegQueryValueEx(hkey, TEXT(key), NULL, NULL,
+ success = RegQueryValueEx(hkey, (LPCTSTR)key, NULL, NULL,
(LPBYTE) &value, &len );
if (success != ERROR_SUCCESS)
return FALSE; /* that's what happens the first time we start */
@@ -786,7 +786,7 @@ void init_ui(int *argcp, char ***argvp)
LONG success;
HKEY hkey;
- success = RegOpenKeyEx( HKEY_CURRENT_USER, TEXT("Software\\subsurface"), 0,
+ success = RegOpenKeyEx( HKEY_CURRENT_USER, (LPCTSTR)"Software\\subsurface", 0,
KEY_QUERY_VALUE, &hkey);
output_units.length = get_from_registry(hkey, "feet");
@@ -801,7 +801,7 @@ void init_ui(int *argcp, char ***argvp)
divelist_font = malloc(80);
len = 80;
- success = RegQueryValueEx(hkey, TEXT("divelist_font"), NULL, NULL,
+ success = RegQueryValueEx(hkey, (LPCTSTR)"divelist_font", NULL, NULL,
(LPBYTE) divelist_font, &len );
if (success != ERROR_SUCCESS) {
/* that's what happens the first time we start - just use the default */
diff --git a/statistics.c b/statistics.c
index 351f2d1..c0acd78 100644
--- a/statistics.c
+++ b/statistics.c
@@ -19,6 +19,12 @@
#include "display-gtk.h"
#include "divelist.h"
+/* use "English" as the default locale until a POSIX ot WIN32 conversation */
+#ifdef WIN32
+#include <locale.h>
+#include <tchar.h>
+#endif
+
typedef struct {
GtkWidget *date,
*dive_time,
@@ -127,8 +133,12 @@ void show_dive_stats(struct dive *dive)
struct dive *prev_dive;
process_all_dives(dive, &prev_dive);
-
- strftime(buf, 80, "%a, %b %d, %Y, %k:%M", gmtime(&dive->when));
+
+ /* use "English" as the default locale until a POSIX ot WIN32 conversation */
+ #ifdef WIN32
+ _tsetlocale(LC_ALL, "English");
+ #endif
+ strftime(buf, 80, "%a, %b %d, %Y, %H:%M", gmtime(&dive->when));
set_label(info_stat_w.date, buf);
set_label(info_stat_w.dive_time, "%d min", (dive->duration.seconds + 30) / 60);
if (prev_dive)
--
1.7.6.msysgit.0
More information about the subsurface
mailing list