%% options copyright owner = Dirk Krause copyright year = 2011-xxxx license = bsd %% header #ifdef DK3_USE_WX #undef DK3_USE_WX #endif /** Use wxWidgets libraries to build GUI programs. */ #define DK3_USE_WX 1 #if 0 #include #else #include #include #include #endif #ifndef WX_WXPREC_H_INCLUDED #include #define WX_WXPREC_H_INCLUDED 1 #endif #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #if DK4_HAVE_WX_CHARTYPE_H #ifndef WX_CHARTYPE_H_INCLUDED #include #define WX_CHARTYPE_H_INCLUDED 1 #endif #else #if DK4_HAVE_WX_WXCHAR_H #ifndef WX_WXCHAR_H_INCLUDED #include #define WX_WXCHAR_H_INCLUDED 1 #endif #else #ifndef WX_WX_H_INCLUDED #include #define WX_WX_H_INCLUDED #endif #endif #endif #endif /** Pointer to wxChar string. */ typedef wxChar *DK3_PWXCHAR; /** Pointer to constant wxChar string. */ typedef wxChar const *DK3_PCWXCHAR; #if DK3_ON_WINDOWS || DK3_HAVE_BACKSLASH /** File name separator. */ #define DK3_WX_CHAR_SEP wxT('\\') #else /** File name separator. */ #define DK3_WX_CHAR_SEP wxT('/') #endif #ifdef __cplusplus extern "C" { #endif /** Copy string. * @param d Destination pointer. * @param s Source pointer. */ void dk3wxs_cpy(wxChar *d, wxChar const *s); /** Copy string, cut to buffer size if necessary. * @param d Destination pointer. * @param s Source pointer. * @param n Size of \a d (number of characters). */ void dk3wxs_ncpy(wxChar *d, wxChar const *s, size_t n); /** Concatenate two strings. * @param d Destination pointer. * @param s Source pointer. */ void dk3wxs_cat(wxChar *d, wxChar const *s); /** Convert to lower-case character. * @param c Character to convert. * @return Conversion result. */ wxChar dk3wxs_tolower(wxChar c); /** Convert to upper-case character. * @param c Character to convert. * @return Conversion result. */ wxChar dk3wxs_toupper(wxChar c); /** Find left-most orrucance of character in string. * @param s String probably containing the character. * @param c Character to search for. * @return Pointer to character position on success, NULL on error. */ wxChar * dk3wxs_chr(wxChar const *s, wxChar c); /** Find right-most orrucance of character in string. * @param s String probably containing the character. * @param c Character to search for. * @return Pointer to character position on success, NULL on error. */ wxChar * dk3wxs_rchr(wxChar const *s, wxChar c); /** Calculate string length. * @param s String to process. * @return String length (number of characters). */ size_t dk3wxs_len(wxChar const *s); /** Duplicate string into dynamically allocated memory. * Use dk3_delete() to release the memory when done. * @param s String to duplicate. * @return Pointer to new string on success, NULL on error. */ wxChar * dk3wxs_dup(wxChar const *s); /** Duplicate string into dynamically allocated memory. * Use dk3_delete() to release the memory when done. * @param s String to duplicate. * @param app Application structure for diagnostics, may be NULL. * @return Pointer to new string on success, NULL on error. */ wxChar * dk3wxs_dup_app(wxChar const *s, dk3_app_t *app); /** Compare two strings, use only the first \a n characters. * @param l Left side string. * @param r Right side string. * @param n Number of characters to use in comparison. * @return 1 for l>r, 0 for l=r, -1 for lr, 0 for l=r, -1 for lr, 0 for l=r, -1 for l #include "dk3wxs.h" #include "dk3wxcs.h" $!trace-include void dk3wxs_cpy(wxChar *d, wxChar const *s) { #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 dk3str_c32_cpy((dk3_c32_t *)d, (const dk3_c32_t *)s); #else dk3str_c16_cpy((dk3_c16_t *)d, (const dk3_c16_t *)s); #endif #else dk3str_c8_cpy((char *)d, (const char *)s); #endif } wxChar * dk3wxs_get_suffix(wxChar const *s) { wxChar *back = NULL; #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = (wxChar *)dk3str_c32_get_suffix((const dk3_c32_t *)s); #else back = (wxChar *)dk3str_c16_get_suffix((const dk3_c16_t *)s); #endif #else back = (wxChar *)dk3str_c8_get_suffix((const char *)s); #endif return back; } void dk3wxs_ncpy(wxChar *d, wxChar const *s, size_t n) { #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 dk3str_c32_ncpy((dk3_c32_t *)d, (const dk3_c32_t *)s, n); #else dk3str_c16_ncpy((dk3_c16_t *)d, (const dk3_c16_t *)s, n); #endif #else dk3str_c8_ncpy((char *)d, (const char *)s, n); #endif } void dk3wxs_cat(wxChar *d, wxChar const *s) { #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 dk3str_c32_cat((dk3_c32_t *)d, (const dk3_c32_t *)s); #else dk3str_c16_cat((dk3_c16_t *)d, (const dk3_c16_t *)s); #endif #else dk3str_c8_cat((char *)d, (const char *)s); #endif } wxChar dk3wxs_tolower(wxChar c) { wxChar back; #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = dk3str_c32_tolower((dk3_c32_t)c); #else back = dk3str_c16_tolower((dk3_c16_t)c); #endif #else back = dk3str_c8_tolower((char)c); #endif return back; } wxChar dk3wxs_toupper(wxChar c) { wxChar back; #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = dk3str_c32_toupper((dk3_c32_t)c); #else back = dk3str_c16_toupper((dk3_c16_t)c); #endif #else back = dk3str_c8_toupper((char)c); #endif return back; } wxChar * dk3wxs_chr(wxChar const *s, wxChar c) { wxChar *back = NULL; if(s) { #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = (wxChar *)dk3str_c32_chr((const dk3_c32_t *)s, (dk3_c32_t)c); #else back = (wxChar *)dk3str_c16_chr((const dk3_c16_t *)s, (dk3_c16_t)c); #endif #else back = (wxChar *)dk3str_c8_chr((const char *)s, (char)c); #endif } return back; } wxChar * dk3wxs_rchr(wxChar const *s, wxChar c) { wxChar *back = NULL; if(s) { #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = (wxChar *)dk3str_c32_rchr((const dk3_c32_t *)s, (dk3_c32_t)c); #else back = (wxChar *)dk3str_c16_rchr((const dk3_c16_t *)s, (dk3_c16_t)c); #endif #else back = (wxChar *)dk3str_c8_rchr((const char *)s, (char)c); #endif } return back; } size_t dk3wxs_len(wxChar const *s) { size_t back = 0; if(s) { #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = dk3str_c32_len((const dk3_c32_t *)s); #else back = dk3str_c16_len((const dk3_c16_t *)s); #endif #else back = dk3str_c8_len((const char *)s); #endif } return back; } wxChar * dk3wxs_dup_app(wxChar const *s, dk3_app_t *app) { wxChar *back = NULL; if(s) { #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = (wxChar *)dk3str_c32_dup_app((const dk3_c32_t *)s, app); #else back = (wxChar *)dk3str_c16_dup_app((const dk3_c16_t *)s, app); #endif #else back = (wxChar *)dk3str_c8_dup_app((const char *)s, app); #endif } return back; } wxChar * dk3wxs_dup(wxChar const *s) { wxChar *back = NULL; if(s) { #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = (wxChar *)dk3str_c32_dup_app((const dk3_c32_t *)s, NULL); #else back = (wxChar *)dk3str_c16_dup_app((const dk3_c16_t *)s, NULL); #endif #else back = (wxChar *)dk3str_c8_dup_app((const char *)s, NULL); #endif } return back; } int dk3wxs_ncmp(wxChar const *l, wxChar const *r, size_t n) { int back = 0; #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = dk3str_c32_ncmp((const dk3_c32_t *)l, (const dk3_c32_t *)r, n); #else back = dk3str_c16_ncmp((const dk3_c16_t *)l, (const dk3_c16_t *)r, n); #endif #else back = dk3str_c8_ncmp((const char *)l, (const char *)r, n); #endif return back; } int dk3wxs_cmp(wxChar const *l, wxChar const *r) { int back = 0; #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = dk3str_c32_cmp((const dk3_c32_t *)l, (const dk3_c32_t *)r); #else back = dk3str_c16_cmp((const dk3_c16_t *)l, (const dk3_c16_t *)r); #endif #else back = dk3str_c8_cmp((const char *)l, (const char *)r); #endif return back; } int dk3wxs_casecmp(wxChar const *l, wxChar const *r) { int back = 0; #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = dk3str_c32_casecmp((const dk3_c32_t *)l, (const dk3_c32_t *)r); #else back = dk3str_c16_casecmp((const dk3_c16_t *)l, (const dk3_c16_t *)r); #endif #else back = dk3str_c8_casecmp((const char *)l, (const char *)r); #endif return back; } int dk3wxs_array_index(wxChar const * const *a, wxChar const *s, int c) { int back = -1; #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = dk3str_c32_array_index( (const dk3_c32_t * const *)a, (const dk3_c32_t *)s, c ); #else back = dk3str_c16_array_index( (const dk3_c16_t * const *)a, (const dk3_c16_t *)s, c ); #endif #else back = dk3str_c8_array_index((const char * const *)a, (const char *)s, c); #endif return back; } wxChar * dk3wxs_start(wxChar *s, wxChar const *whsp) { wxChar *back = NULL; #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = (wxChar *)dk3str_c32_start((dk3_c32_t *)s, (const dk3_c32_t *)whsp); #else back = (wxChar *)dk3str_c16_start((dk3_c16_t *)s, (const dk3_c16_t *)whsp); #endif #else back = (wxChar *)dk3str_c8_start((char *)s, (const char *)whsp); #endif return back; } wxChar * dk3wxs_next(wxChar *s, wxChar const *whsp) { wxChar *back = NULL; #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = (wxChar *)dk3str_c32_next((dk3_c32_t *)s, (const dk3_c32_t *)whsp); #else back = (wxChar *)dk3str_c16_next((dk3_c16_t *)s, (const dk3_c16_t *)whsp); #endif #else back = (wxChar *)dk3str_c8_next((char *)s, (const char *)whsp); #endif return back; } int dk3wxs_is_bool(wxChar const *s) { int back = 0; #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = dk3str_c32_is_bool((const dk3_c32_t *)s); #else back = dk3str_c16_is_bool((const dk3_c16_t *)s); #endif #else back = dk3str_c8_is_bool((const char *)s); #endif return back; } int dk3wxs_is_on(wxChar const *s) { int back = 0; #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = dk3str_c32_is_on((const dk3_c32_t *)s); #else back = dk3str_c16_is_on((const dk3_c16_t *)s); #endif #else back = dk3str_c8_is_on((const char *)s); #endif return back; } size_t dk3wxs_explode(wxChar **array, size_t sz, wxChar *s, wxChar const *whsp) { size_t back; #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = dk3str_c32_explode( (dk3_c32_t **)array, sz, (dk3_c32_t *)s, (const dk3_c32_t *)whsp ); #else back = dk3str_c16_explode( (dk3_c16_t **)array, sz, (dk3_c16_t *)s, (const dk3_c16_t *)whsp ); #endif #else back = dk3str_c8_explode( (char **)array, sz, (char *)s, (const char *)whsp ); #endif return back; } void dk3wxs_normalize(wxChar *l, wxChar const *w, wxChar c) { #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 dk3str_c32_normalize((dk3_c32_t *)l, (const dk3_c32_t *)w, (dk3_c32_t)c); #else dk3str_c16_normalize((dk3_c16_t *)l, (const dk3_c16_t *)w, (dk3_c16_t)c); #endif #else dk3str_c8_normalize((char *)l, (const char *)w, (char)c); #endif } int dk3wxs_is_abs_path(wxChar const *n) { int back = 0; #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = dk3str_c32_is_abs_path((const dk3_c32_t *)n); #else back = dk3str_c16_is_abs_path((const dk3_c16_t *)n); #endif #else back = dk3str_c8_is_abs_path((const char *)n); #endif return back; } int dk3wxs_append_path(wxChar *d, size_t sz, wxChar const *n) { int back = 0; #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 back = dk3str_c32_append_path_app( (dk3_c32_t *)d, sz, (const dk3_c32_t *)n, NULL ); #else back = dk3str_c16_append_path_app( (dk3_c16_t *)d, sz, (const dk3_c16_t *)n, NULL ); #endif #else back = dk3str_c8_append_path_app((char *)d, sz, (const char *)n, NULL); #endif return back; } void dk3wxs_correct_filename(wxChar *n) { #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 dk3str_c32_correct_filename((dk3_c32_t *)n); #else dk3str_c16_correct_filename((dk3_c16_t *)n); #endif #else dk3str_c8_correct_filename((char *)n); #endif } int dk3wxs_from_utf8(wxChar *d, size_t sz, char const *s) { int back = 0; $? "+ dk3wxs_from_utf8 %u \"%!8s\"", (unsigned)sz, s if((d) && (sz) && (s)) { #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 $? ". 32 bit" if(sz >= dk3str_cnvsz_c8u_to_c32_app(s, NULL)) { $? ". size ok" back = dk3str_cnv_c8u_to_c32_app( (dk3_c32_t *)d, sz, s, NULL); } #else $? ". 16 bit" if(sz >= dk3str_cnvsz_c8u_to_c16_app(s, NULL)) { $? ". size ok" back = dk3str_cnv_c8u_to_c16_app( (dk3_c16_t *)d, sz, s, NULL); } #endif #else $? ". 8 bit" if(sz >= dk3str_cnvsz_c8u_to_c8p_app(s, NULL)) { $? ". size ok" back = dk3str_cnv_c8u_to_c8p_app((char *)d, sz, s, NULL); } #endif } $? "- dk3wxs_from_utf8 %d", back return back; } int dk3wxs_from_plain(wxChar *d, size_t sz, char const *s) { int back = 0; if((d) && (sz) && (s)) { #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 if(sz >= dk3str_cnvsz_c8p_to_c32_app(s, NULL)) { back = dk3str_cnv_c8p_to_c32_app((dk3_c32_t *)d, sz, s, NULL); } #else if(sz >= dk3str_cnvsz_c8p_to_c16_app(s, NULL)) { back = dk3str_cnv_c8p_to_c16_app((dk3_c16_t *)d, sz, s, NULL); } #endif #else if(sz >= dk3str_c8_len(s)) { dk3str_c8_cpy((char *)d, s); back = 1; } #endif } return back; } int dk3wxs_from_utf16(wxChar *d, size_t sz, dk3_c16_t const *s) { int back = 0; if((d) && (sz) && (s)) { #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 if(sz >= dk3str_cnvsz_c16_to_c32_app(s, NULL)) { back = dk3str_cnv_c16_to_c32_app((dk3_c32_t *)d, sz, s, NULL); } #else if(sz >= dk3str_c16_len(s)) { dk3str_c16_cpy((dk3_c16_t *)d, s); back = 1; } #endif #else if(sz >= dk3str_cnvsz_c16_to_c8p_app(s, NULL)) { back = dk3str_cnv_c16_to_c8p_app((char *)d, sz, s, NULL); } #endif } return back; } int dk3wxs_from_dkstr(wxChar *dp, size_t sz, int wxe, dkChar const *src, int dke) { int back = 0; if((dp) && (sz) && (src)) { #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 /* + wxChar 4 */ #if DK3_CHAR_SIZE > 1 #if DK3_CHAR_SIZE > 2 /* + dkChar 4 */ if(dk3str_c32_len((const dk3_c32_t *)src) < sz) { dk3str_c32_cpy((dk3_c32_t *)dp, (const dk3_c32_t *)src); back = 1; } /* - dkChar 4 */ #else /* + dkChar 2 */ if(sz >= dk3str_cnvsz_c16_to_c32_app((const dk3_c16_t *)src, NULL)) { back = dk3str_cnv_c16_to_c32_app( (dk3_c32_t *)dp, sz, (const dk3_c16_t *)src, NULL ); } /* - dkChar 2 */ #endif #else /* + dkChar 1 */ if(dke == DK3_ENCODING_PLAIN) { if(sz >= dk3str_cnvsz_c8p_to_c32_app((const char *)src, NULL)) { back = dk3str_cnv_c8p_to_c32_app( (dk3_c32_t *)dp, sz, (const char *)src, NULL ); } } else { if(sz >= dk3str_cnvsz_c8u_to_c32_app(src, NULL)) { back = dk3str_cnv_c8u_to_c32_app(dp, sz, src, NULL); } } /* - dkChar 1 */ #endif /* - wxChar 4 */ #else /* + wxChar 2 */ #if DK3_CHAR_SIZE > 1 #if DK3_CHAR_SIZE > 2 /* + dkChar 4 */ if(sz >= dk3str_cnvsz_c32_to_c16_app((const dk3_c32_t *)src, NULL)) { back = dk3str_cnv_c32_to_c16_app( (dk3_c16_t *)dp, sz, (const dk3_c32_t *)src, NULL ); } /* - dkChar 4 */ #else /* + dkChar 2 */ if(dk3str_c16_len((const dk3_c16_t *)src) < sz) { dk3str_c16_cpy((dk3_c16_t *)dp, (const dk3_c16_t *)src); back = 1; } /* - dkChar 2 */ #endif #else /* + dkChar 1 */ if(dke == DK3_ENCODING_PLAIN) { if(sz >= dk3str_cnvsz_c8p_to_c16_app((const char *)src, NULL)) { back = dk3str_cnv_c8p_to_c16_app( (dk3_c16_t *)dp, sz, (const char *)src, NULL ); } } else { if(sz >= dk3str_cnvsz_c8u_to_c16_app((const char *)src, NULL)) { back = dk3str_cnv_c8u_to_c16_app( (dk3_c16_t *)dp, sz, (const char *)src, NULL ); } } /* - dkChar 1 */ #endif /* - wxChar 2 */ #endif #else /* + wxChar 1 */ #if DK3_CHAR_SIZE > 1 #if DK3_CHAR_SIZE > 2 /* + dkChar 4 */ if(wxe == DK3_ENCODING_PLAIN) { if(sz >= dk3str_cnvsz_c8p_to_c32_app((const dk3_c32_t *)src, NULL)) { back = dk3str_cnv_c8p_to_c32_app( (char *)dp, sz, (const dk3_c32_t *)src, NULL ); } } else { if(sz >= dk3str_cnvsz_c8u_to_c32_app((const dk3_c32_t *)src, NULL)) { back = dk3str_cnv_c8u_to_c32_app( (char *)dp, sz, (const dk3_c32_t *)src, NULL ); } } /* - dkChar 4 */ #else /* + dkChar 2 */ if(wxe == DK3_ENCODING_PLAIN) { if(sz >= dk3str_cnvsz_c8p_to_c16_app((const dk3_c16_t *)src, NULL)) { back =dk3str_cnv_c8p_to_c16_app( (char *)dp, sz, (const dk3_c16_t *)src, NULL ); } } else { if(sz >= dk3str_cnvsz_c8u_to_c16_app((const dk3_c16_t *)src, NULL)) { back =dk3str_cnv_c8u_to_c16_app( (char *)dp, sz, (const dk3_c16_t *)src, NULL ); } } /* - dkChar 2 */ #endif #else /* + dkChar 1 */ if(wxe == dke) { if(dk3str_c8_len((const char *)src) < sz) { dk3str_c8_cpy((char *)dp, (const char *)src); back = 1; } } else { if(wxe == DK3_ENCODING_PLAIN) { if(sz >= dk3str_cnvsz_c8u_to_c8p_app((const char *)src, NULL)) { back = dk3str_cnv_c8u_to_c8p_app( (char *)dp, sz, (const char *)src, NULL ); } } else { if(sz >= dk3str_cnvsz_c8p_to_c8u_app((const char *)src, NULL)) { back = dk3str_cnv_c8p_to_c8u_app( (char *)dp, sz, (const char *)src, NULL ); } } } /* - dkChar 1 */ #endif /* - wxChar 1 */ #endif } return back; } int dk3wxs_to_dkstr(dkChar *dp, size_t sz, int dke, wxChar const *src, int wxe) { int back = 0; if((dp) && (sz) && (src)) { #if DK3_CHAR_SIZE > 1 #if DK3_CHAR_SIZE > 2 /* + dkChar 4 */ #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 /* + wxChar 4 */ if(dk3str_c32_len((const dk3_c32_t *)src) < sz) { dk3str_c32_cpy((dk3_c32_t *)dp, (const dk3_c32_t *)src); back = 1; } /* - wxChar 4 */ #else /* + wxChar 2 */ if(sz >= dk3str_cnvsz_c16_to_c32_app((const dk3_c16_t *)src, NULL)) { back = dk3str_cnv_c16_to_c32_app( (dk3_c32_t *)dp, sz, (const dk3_c16_t *)src, NULL ); } /* - wxChar 2 */ #endif #else /* + wxChar 1 */ if(wxe == DK3_ENCODING_PLAIN) { if(sz >= dk3str_cnvsz_c8p_to_c32_app((const char *)src, NULL)) { back = dk3str_cnv_c8p_to_c32_app( (dk3_c32_t *)dp, sz, (const char *)src, NULL ); } } else { if(sz >= dk3str_cnvsz_c8u_to_c32_app((const char *)src, NULL)) { back = dk3str_cnv_c8u_to_c32_app( (dk3_c32_t *)dp, sz, (const char *)src, NULL ); } } /* - wxChar 1 */ #endif /* - dkChar 4 */ #else /* + dkChar 2 */ #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 /* + wxChar 4 */ if(sz >= dk3str_cnvsz_c32_to_c16_app((const dk3_c32_t *)src, NULL)) { back = dk3str_cnv_c32_to_c16_app( (dk3_c16_t *)dp, sz, (const dk3_c32_t *)src, NULL ); } /* - wxChar 4 */ #else /* + wxChar 2 */ if(sz > dk3str_c16_len((const dk3_c16_t *)src)) { dk3str_c16_cpy((dk3_c16_t *)dp, (const dk3_c16_t *)src); back = 1; } /* - wxChar 2 */ #endif #else /* + wxChar 1 */ if(wxe == DK3_ENCODING_PLAIN) { if(sz >= dk3str_cnvsz_c8p_to_c16_app((const char *)src, NULL)) { back = dk3str_cnv_c8p_to_c16_app( (dk3_c16_t *)dp, sz, (const char *)src, NULL ); } } else { if(sz >= dk3str_cnvsz_c8u_to_c16_app((const char *)src, NULL)) { back = dk3str_cnv_c8u_to_c16_app( (dk3_c16_t *)dp, sz, (const char *)src, NULL ); } } /* - wxChar 1 */ #endif /* - dkChar 2 */ #endif #else /* + dkChar 1 */ #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 /* + wxChar 4 */ if(dke == DK3_ENCODING_PLAIN) { if(sz >= dk3str_cnvsz_c32_to_c8p_app((const dk3_c32_t *)src, NULL)) { back = dk3str_cnv_c32_to_c8p_app( (char *)dp, sz, (const dk3_c32_t *)src, NULL ); } } else { if(sz >= dk3str_cnvsz_c32_to_c8u_app((const dk3_c32_t *)src, NULL)) { back = dk3str_cnv_c32_to_c8u_app( (char *)dp, sz, (const dk3_c32_t *)src, NULL ); } } /* - wxChar 4 */ #else /* + wxChar 2 */ if(dke == DK3_ENCODING_PLAIN) { if(sz >= dk3str_cnvsz_c16_to_c8p_app((const dk3_c16_t *)src, NULL)) { back = dk3str_cnv_c16_to_c8p_app( (char *)dp, sz, (const dk3_c16_t *)src, NULL ); } } else { if(sz >= dk3str_cnvsz_c16_to_c8u_app((const dk3_c16_t *)src, NULL)) { back = dk3str_cnv_c16_to_c8u_app( (char *)dp, sz, (const dk3_c16_t *)src, NULL ); } } /* - wxChar 2 */ #endif #else /* + wxChar 1 */ if(dke == wxe) { if(sz > dk3str_c8_len((const char *)src)) { dk3str_c8_cpy((char *)dp, (const char *)src); back = 1; } } else { if(dke == DK3_ENCODING_PLAIN) { if(sz >= dk3str_cnvsz_c8u_to_c8p_app((const char *)src, NULL)) { back = dk3str_cnv_c8u_to_c8p_app( (char *)dp, sz, (const char *)src, NULL ); } } else { if(sz >= dk3str_cnvsz_c8p_to_c8u_app((const char *)src, NULL)) { back = dk3str_cnv_c8p_to_c8u_app( (char *)dp, sz, (const char *)src, NULL ); } } } /* - wxChar 1 */ #endif /* - dkChar 1 */ #endif } return back; } int dk3wxs_to_c8(char *dp, size_t sz, int c8e, wxChar const *src, int wxe) { int back = 0; $? "+ dk3wxs_to_c8str" if((dp) && (sz) && (src)) { #if DK3_SIZEOF_WXCHAR > 1 #if DK3_SIZEOF_WXCHAR > 2 if(DK3_ENCODING_UTF8 == c8e) { $? ". 32 bit to UTF-8" if(sz >= dk3str_cnvsz_c32_to_c8u_app((const dk3_c32_t *)src, NULL)) { back = dk3str_cnv_c32_to_c8u_app( dp, sz, (const dk3_c32_t *)src, NULL ); } } else { $? ". 32 bit to plain" if(sz >= dk3str_cnvsz_c32_to_c8p_app((const dk3_c32_t *)src, NULL)) { back = dk3str_cnv_c32_to_c8p_app( dp, sz, (const dk3_c32_t *)src, NULL ); } } #else if(DK3_ENCODING_UTF8 == c8e) { $? ". 16 bit to UTF-8" if(sz >= dk3str_cnvsz_c16_to_c8u_app((const dk3_c16_t *)src, NULL)) { back = dk3str_cnv_c16_to_c8u_app( dp, sz, (const dk3_c16_t *)src, NULL ); } } else { $? ". 16 bit to plain" if(sz >= dk3str_cnvsz_c16_to_c8p_app((const dk3_c16_t *)src, NULL)) { back = dk3str_cnv_c16_to_c8p_app( dp, sz, (const dk3_c16_t *)src, NULL ); } } #endif #else if(c8e == wxe) { $? ". 8 bit copy" if(sz > strlen((const char *)src)) { strcpy(dp, (const char *)src); } } else { if(DK3_ENCODING_UTF8 == c8e) { $? ". 8 bit to UTF-8" if(sz >= dk3str_cnvsz_c8p_to_c8u_app((const char *)src, NULL)) { back = dk3str_cnv_c8p_to_c8u_app(dp, sz, (const char *)src, NULL); } } else { $? ". 8 bit to plain" if(sz >= dk3str_cnvsz_c8u_to_c8p_app((const char *)src, NULL)) { back = dk3str_cnv_c8u_to_c8p_app(dp, sz, (const char *)src, NULL); } } } #endif } $? "- dk3wxs_to_c8str %d", back return back; }