comparison win/dw.c @ 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 d81bebc5c8cc
children 209c57a14b09
comparison
equal deleted inserted replaced
1783:9de6d1cc8fb8 1784:86ace55df07b
12472 prev = tmp; 12472 prev = tmp;
12473 tmp = tmp->next; 12473 tmp = tmp->next;
12474 } 12474 }
12475 } 12475 }
12476 } 12476 }
12477
12478 /*
12479 * Converts a UTF-8 encoded string into a wide string.
12480 * Parameters:
12481 * utf8string: UTF-8 encoded source string.
12482 * Returns:
12483 * Wide string that needs to be freed with dw_free()
12484 * or NULL on failure.
12485 */
12486 wchar_t * API dw_utf8_to_wchar(char *utf8string)
12487 {
12488 #ifdef UNICODE
12489 return _myUTF8toWide(utf8string, malloc(MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0) * sizeof(WCHAR)));
12490 #else
12491 return NULL;
12492 #endif
12493 }
12494
12495 /*
12496 * Converts a wide string into a UTF-8 encoded string.
12497 * Parameters:
12498 * wstring: Wide source string.
12499 * Returns:
12500 * UTF-8 encoded string that needs to be freed with dw_free()
12501 * or NULL on failure.
12502 */
12503 char * API dw_wchar_to_utf8(wchar_t *wstring)
12504 {
12505 #ifdef UNICODE
12506 return _myWideToUTF8(wstring, malloc(WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL)));
12507 #else
12508 return NULL;
12509 #endif
12510 }
12511