/[gpgoe]/trunk/src/OEMisc.c
ViewVC logotype

Diff of /trunk/src/OEMisc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 22 by twoaday, Tue Apr 11 06:56:23 2006 UTC revision 23 by twoaday, Sat Aug 18 10:55:14 2007 UTC
# Line 46  native_to_utf8 (const char *string) Line 46  native_to_utf8 (const char *string)
46    
47      n = MultiByteToWideChar (GetACP (), 0, string, -1, result, n);      n = MultiByteToWideChar (GetACP (), 0, string, -1, result, n);
48      if (n < 0) {      if (n < 0) {
49          free (result);          xfree (result);
50          return NULL;          return NULL;
51      }      }
52    
# Line 58  native_to_utf8 (const char *string) Line 58  native_to_utf8 (const char *string)
58    
59      n = WideCharToMultiByte (CP_UTF8, 0, result, -1, native, n, NULL, NULL);      n = WideCharToMultiByte (CP_UTF8, 0, result, -1, native, n, NULL, NULL);
60      if (n < 0) {      if (n < 0) {
61          free (result);          xfree (result);
62          return NULL;          return NULL;
63      }      }
64    
65      free (result);      xfree (result);
66      return native;      return native;
67  }  }
68    
# Line 78  utf8_to_native (const char *string) Line 78  utf8_to_native (const char *string)
78      n = MultiByteToWideChar (CP_UTF8, 0, string, -1, NULL, 0);      n = MultiByteToWideChar (CP_UTF8, 0, string, -1, NULL, 0);
79      if (n < 0)      if (n < 0)
80          return NULL;          return NULL;
   
81      result = (wchar_t*)xcalloc (1, (n+1) * sizeof *result);      result = (wchar_t*)xcalloc (1, (n+1) * sizeof *result);
   
82      n = MultiByteToWideChar (CP_UTF8, 0, string, -1, result, n);      n = MultiByteToWideChar (CP_UTF8, 0, string, -1, result, n);
83      if (n < 0) {      if (n < 0) {
84          free (result);          xfree (result);
85          return NULL;          return NULL;
86      }      }
87    
88      n = WideCharToMultiByte (GetACP (), 0, result, -1, NULL, 0, NULL, NULL);      n = WideCharToMultiByte (GetACP (), 0, result, -1, NULL, 0, NULL, NULL);
89      if (n < 0)      if (n < 0)
90          return NULL;          return NULL;
91        native = (char*)xcalloc (1, n+1);
     native = (char*)malloc (n+1);  
     if (!native)  
         abort ();  
   
92      n = WideCharToMultiByte (GetACP (), 0, result, -1, native, n, NULL, NULL);      n = WideCharToMultiByte (GetACP (), 0, result, -1, native, n, NULL, NULL);
93      if (n < 0) {      if (n < 0) {
94          free (result);          xfree (result);
95          return NULL;          return NULL;
96      }      }
97    
98      free (result);      xfree (result);
99      return native;      return native;
100  }  }
101    
# Line 210  show_error (HWND hwnd, const char *capti Line 204  show_error (HWND hwnd, const char *capti
204      va_list ptr;      va_list ptr;
205    
206      va_start (ptr, fmt);      va_start (ptr, fmt);
207      _vsnprintf (buffer, sizeof (buffer)-1, fmt, ptr);      _vsnprintf (buffer, DIM (buffer)-1, fmt, ptr);
208      va_end (ptr);      va_end (ptr);
209      MessageBox (hwnd, buffer, caption, type);      MessageBox (hwnd, buffer, caption, type);
210  }  }
# Line 246  quote_msg_text (const char *inp, char ** Line 240  quote_msg_text (const char *inp, char **
240  /* Center the window @hwndChild over the parent window @parent. */  /* Center the window @hwndChild over the parent window @parent. */
241  void  void
242  center_window (HWND hwndChild, HWND parent)  center_window (HWND hwndChild, HWND parent)
243  {      {
244      HWND hwndParent;      HWND hwndParent;
245      RECT rChild, rParent;      RECT rChild, rParent;
246      HDC hdc;      HDC hdc;

Legend:
Removed from v.22  
changed lines
  Added in v.23

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26