# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1343170377 0 # Node ID 9de6d1cc8fb818778f93d9fb07886834e99838cc # Parent d056a50196a9d5b7870ed286f20107997babf71e Put test program code into DEPRECATED #ifdef again to avoid build warnings. Added UTF-8/Wide string conversion functions which will be used in an editor. diff -r d056a50196a9 -r 9de6d1cc8fb8 dw.h --- a/dw.h Mon Jul 23 16:56:08 2012 +0000 +++ b/dw.h Tue Jul 24 22:52:57 2012 +0000 @@ -1415,6 +1415,8 @@ #define _DW_SCROLLED_MAX_WIDTH 500 #define _DW_SCROLLED_MAX_HEIGHT 400 +#include + /* Let other APIs know what types we've defined, * Regina REXX in particular, on Unix. */ @@ -1724,5 +1726,7 @@ HPRINT API dw_print_new(char *jobname, unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata); int API dw_print_run(HPRINT print, unsigned long flags); void API dw_print_cancel(HPRINT print); +wchar_t * API dw_utf8_to_wchar(char *utf8string); +char * API dw_wchar_to_utf8(wchar_t *wstring); #endif diff -r d056a50196a9 -r 9de6d1cc8fb8 dwtest.c --- a/dwtest.c Mon Jul 23 16:56:08 2012 +0000 +++ b/dwtest.c Tue Jul 24 22:52:57 2012 +0000 @@ -1380,6 +1380,7 @@ } } +#ifdef DEPRECATED void mdi_add(void) { HWND mdibox, mdi, mdi1w, mdi1box, ef, mdi2w, mdi2box, bb; @@ -1411,6 +1412,7 @@ dw_window_set_size(mdi2w, 200, 200); dw_window_show(mdi2w); } +#endif void menu_add(void) { @@ -1666,7 +1668,9 @@ ULONG notebookpage3; ULONG notebookpage4; ULONG notebookpage5; +#ifdef DEPRECATED ULONG notebookpage6; +#endif ULONG notebookpage7; ULONG notebookpage8; ULONG notebookpage9; @@ -1720,11 +1724,13 @@ dw_notebook_page_set_text( notebook, notebookpage5, "buttons"); buttons_add(); +#ifdef DEPRECATED notebookbox6 = dw_box_new( DW_VERT, 5 ); notebookpage6 = dw_notebook_page_new( notebook, 1, FALSE ); dw_notebook_pack( notebook, notebookpage6, notebookbox6 ); dw_notebook_page_set_text( notebook, notebookpage6, "mdi"); mdi_add(); +#endif notebookbox7 = dw_box_new( DW_VERT, 6 ); notebookpage7 = dw_notebook_page_new( notebook, 1, FALSE ); diff -r d056a50196a9 -r 9de6d1cc8fb8 mac/dw.m --- a/mac/dw.m Mon Jul 23 16:56:08 2012 +0000 +++ b/mac/dw.m Tue Jul 24 22:52:57 2012 +0000 @@ -11030,3 +11030,32 @@ p->drawfunc = NULL; } +/* + * Converts a UTF-8 encoded string into a wide string. + * Parameters: + * utf8string: UTF-8 encoded source string. + * Returns: + * Wide string that needs to be freed with dw_free(). + */ +wchar_t * API dw_utf8_to_wchar(char *utf8string) +{ + size_t buflen = strlen(utf8string) + 1; + wchar_t *buffer = malloc(buflen * sizeof(wchar_t)); + mbstowcs(buffer, utf8string, buflen); + return buffer; +} + +/* + * Converts a wide string into a UTF-8 encoded string. + * Parameters: + * wstring: Wide source string. + * Returns: + * UTF-8 encoded string that needs to be freed with dw_free(). + */ +char * API dw_wchar_to_utf8(wchar_t *wstring) +{ + size_t bufflen = 8 * wcslen(wstring) + 1; + char *temp = malloc(bufflen); + wcstombs(temp, wstring, bufflen); + return temp; +}