/[winpt]/trunk/Src/wptUTF8.cpp
ViewVC logotype

Diff of /trunk/Src/wptUTF8.cpp

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

revision 200 by twoaday, Sat Apr 1 12:36:35 2006 UTC revision 201 by twoaday, Sat Apr 22 18:30:24 2006 UTC
# Line 43  native_to_utf8 (const char *string) Line 43  native_to_utf8 (const char *string)
43      if (n < 0)      if (n < 0)
44          return NULL;          return NULL;
45    
46      result = (wchar_t*)malloc ((n+1) * sizeof *result);      result = new wchar_t[n+1];
47      if (!result)      if (!result)
48          BUG (0);          BUG (0);
49    
50      n = MultiByteToWideChar (GetACP (), 0, string, -1, result, n);      n = MultiByteToWideChar (GetACP (), 0, string, -1, result, n);
51      if (n < 0) {      if (n < 0) {
52          free (result);          free_if_alloc (result);
53          return NULL;          return NULL;
54      }      }
55    
# Line 57  native_to_utf8 (const char *string) Line 57  native_to_utf8 (const char *string)
57      if (n < 0)      if (n < 0)
58          return NULL;          return NULL;
59    
60      native = (char*)malloc (n+1);      native = new char[n+1];
61      if (!native)      if (!native)
62          BUG (0);          BUG (0);
63    
64      n = WideCharToMultiByte (CP_UTF8, 0, result, -1, native, n, NULL, NULL);      n = WideCharToMultiByte (CP_UTF8, 0, result, -1, native, n, NULL, NULL);
65      if (n < 0) {      if (n < 0) {
66          free (result);          free_if_alloc (result);
67          return NULL;          return NULL;
68      }      }
69    
70      free (result);      free_if_alloc (result);
71      return native;      return native;
72  }  }
73    

Legend:
Removed from v.200  
changed lines
  Added in v.201

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26