Mercurial > dwindows
changeset 1784:86ace55df07b
Added UTF8/Wide conversion functions on OS/2 and Windows...
Updated the readme file and some comment cleanups.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 24 Jul 2012 23:33:50 +0000 |
parents | 9de6d1cc8fb8 |
children | c5ea64e8b436 |
files | mac/dw.m os2/dw.c os2/dw.def os2/dw.lnk readme.txt win/dw-mingw.def win/dw.c win/dw.def |
diffstat | 8 files changed, 94 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mac/dw.m Tue Jul 24 22:52:57 2012 +0000 +++ b/mac/dw.m Tue Jul 24 23:33:50 2012 +0000 @@ -11035,14 +11035,16 @@ * Parameters: * utf8string: UTF-8 encoded source string. * Returns: - * Wide string that needs to be freed with dw_free(). + * Wide string that needs to be freed with dw_free() + * or NULL on failure. */ 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; + wchar_t *temp = malloc(buflen * sizeof(wchar_t)); + if(temp) + mbstowcs(temp, utf8string, buflen); + return temp; } /* @@ -11050,12 +11052,14 @@ * Parameters: * wstring: Wide source string. * Returns: - * UTF-8 encoded string that needs to be freed with dw_free(). + * UTF-8 encoded string that needs to be freed with dw_free() + * or NULL on failure. */ char * API dw_wchar_to_utf8(wchar_t *wstring) { size_t bufflen = 8 * wcslen(wstring) + 1; char *temp = malloc(bufflen); - wcstombs(temp, wstring, bufflen); + if(temp) + wcstombs(temp, wstring, bufflen); return temp; }
--- a/os2/dw.c Tue Jul 24 22:52:57 2012 +0000 +++ b/os2/dw.c Tue Jul 24 23:33:50 2012 +0000 @@ -13279,3 +13279,37 @@ if(day) *day = DW_POINTER_TO_UINT(dw_window_get_data(window, "_dw_day")) + 1; } + +/* + * 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() + * or NULL on failure. + */ +wchar_t * API dw_utf8_to_wchar(char *utf8string) +{ +#ifdef UNICODE + return _UTF8toWide(utf8string); +#else + return NULL; +#endif +} + +/* + * 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() + * or NULL on failure. + */ +char * API dw_wchar_to_utf8(wchar_t *wstring) +{ +#ifdef UNICODE + return _WideToUTF8(wstring); +#else + return NULL; +#endif +}
--- a/os2/dw.def Tue Jul 24 22:52:57 2012 +0000 +++ b/os2/dw.def Tue Jul 24 23:33:50 2012 +0000 @@ -309,3 +309,5 @@ dw_print_run @511 dw_print_cancel @512 + dw_utf8_to_wchar @520 + dw_wchar_to_utf8 @521
--- a/os2/dw.lnk Tue Jul 24 22:52:57 2012 +0000 +++ b/os2/dw.lnk Tue Jul 24 23:33:50 2012 +0000 @@ -303,3 +303,5 @@ export dw_print_run.511 export dw_print_cancel.512 +export dw_utf8_to_wchar.520 +export dw_wchar_to_utf8.521
--- a/readme.txt Tue Jul 24 22:52:57 2012 +0000 +++ b/readme.txt Tue Jul 24 23:33:50 2012 +0000 @@ -27,6 +27,7 @@ from available libraries (Firefox, Webkit, Qt, etc). Changes from version 2.3: +Added support for MacOS 10.8 Mountain Lion. Added fullscreen support on Mac for resizable windows on Lion. Added UNICODE build mode on Windows allowing UTF-8 encoded text. ANSI builds are supported by removing -DUNICODE -D_UNICODE and -DAEROGLASS @@ -47,6 +48,7 @@ Added new optional UTF-8 parameter to the key press callback. This is a pointer to a UTF-8 string representing the key pressed. The buffer pointed to is only good for the duration of the callback. +Added UTF-8/Wide string conversion functions for Unicode buffer management. Fixed dwindows-config --version not returning the version at all. Fixed value changed events not working for spinbuttons on OS/2 and Windows. Fixed issues drawing arcs on GTK2, GTK3 and Mac. @@ -61,6 +63,10 @@ over the data passed in on most platforms. Fixed dw_container_delete_row() failing and/or crashing on Mac. Fixed memory and resource leaks on Windows and Mac. +Fixed incorrect display of status text fields on Mac 10.5 and 10.8. +Fixed compiler warnings on Mac 10.5 and 10.8 by checking selectors directly + and removing use of now deprecated APIs. +Fixed incorrect display of textured background non-resizable windows on Mac. Updated the test program removing deprecated flags and using new ones. Dynamic Windows Documentation is available at:
--- a/win/dw-mingw.def Tue Jul 24 22:52:57 2012 +0000 +++ b/win/dw-mingw.def Tue Jul 24 23:33:50 2012 +0000 @@ -306,3 +306,6 @@ dw_print_new @510 dw_print_run @511 dw_print_cancel @512 + + dw_utf8_to_wchar @520 + dw_wchar_to_utf8 @521
--- a/win/dw.c Tue Jul 24 22:52:57 2012 +0000 +++ b/win/dw.c Tue Jul 24 23:33:50 2012 +0000 @@ -12474,3 +12474,38 @@ } } } + +/* + * 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() + * or NULL on failure. + */ +wchar_t * API dw_utf8_to_wchar(char *utf8string) +{ + #ifdef UNICODE + return _myUTF8toWide(utf8string, malloc(MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0) * sizeof(WCHAR))); +#else + return NULL; +#endif +} + +/* + * 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() + * or NULL on failure. + */ +char * API dw_wchar_to_utf8(wchar_t *wstring) +{ +#ifdef UNICODE + return _myWideToUTF8(wstring, malloc(WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL))); +#else + return NULL; +#endif +} +