/[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 187 by twoaday, Wed Mar 22 11:04:20 2006 UTC revision 278 by twoaday, Mon Jan 15 22:02:04 2007 UTC
# Line 1  Line 1 
1  /* wptUTF8.cpp - UTF8 conversation  /* wptUTF8.cpp - UTF8 conversation
2   *      Copyright (C) 2002, 2004, 2005, 2006 Timo Schulz   *      Copyright (C) 2002, 2004, 2005, 2006 Timo Schulz
3   *   *
4   * This file is part of WinPT.   * This file is part of WinPT.
# Line 12  Line 12 
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14   * GNU General Public License for more details.   * GNU General Public License for more details.
  *  
  * You should have received a copy of the GNU General Public License  
  * along with WinPT; if not, write to the Free Software Foundation,  
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA  
15   */   */
   
16  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
17  #include <config.h>  #include <config.h>
18  #endif  #endif
# Line 43  native_to_utf8 (const char *string) Line 38  native_to_utf8 (const char *string)
38      if (n < 0)      if (n < 0)
39          return NULL;          return NULL;
40    
41      result = (wchar_t*)malloc ((n+1) * sizeof *result);      result = new wchar_t[n+1];
42      if (!result)      if (!result)
43          BUG (0);          BUG (0);
44    
45      n = MultiByteToWideChar (GetACP (), 0, string, -1, result, n);      n = MultiByteToWideChar (GetACP (), 0, string, -1, result, n);
46      if (n < 0) {      if (n < 0) {
47          free (result);          free_if_alloc (result);
48          return NULL;          return NULL;
49      }      }
50    
# Line 57  native_to_utf8 (const char *string) Line 52  native_to_utf8 (const char *string)
52      if (n < 0)      if (n < 0)
53          return NULL;          return NULL;
54    
55      native = (char*)malloc (n+1);      native = new char[n+1];
56      if (!native)      if (!native)
57          BUG (0);          BUG (0);
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);          free_if_alloc (result);
62          return NULL;          return NULL;
63      }      }
64    
65      free (result);      free_if_alloc (result);
66      return native;      return native;
67  }  }
68    
# Line 113  utf8_to_native (const char *string) Line 108  utf8_to_native (const char *string)
108  }  }
109    
110    
111    /* Return -1 if the string contains any 8-bit characters. */
112  int  int
113  is_8bit_string (const char * str)  is_8bit_string (const char *str)
114  {  {
115      size_t i;      size_t i;
116    

Legend:
Removed from v.187  
changed lines
  Added in v.278

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26