// Extracted from one of my projects # Define t_max_buf_len 8 # Define t_buf_size 256 # DEFINE _ A (text) (toansichar (text )) # DEFINE _ u (text) (towidechar (text )) Wchar_t * towidechar (const char * szformat ,...) { Wchar_t * P = NULL; Static int nindex = 0; Static wchar_t szbuffer [t_max_buf_len] [t_buf_size]; Char sztext [t_buf_size]; Va_list ARGs; Va_start (ARGs, szformat ); Vsprintf (sztext, szformat, argS ); Va_end (ARGs ); Memset (szbuffer [nindex], 0, sizeof (szbuffer [nindex]); If (multibytetowidechar (cp_acp, 0, sztext,-1, (lpwstr) szbuffer [nindex], sizeof (szbuffer [nindex]) { P = szbuffer [nindex]; } Nindex ++; If (nindex> = t_max_buf_len) nindex = 0; Return P; } Char * toansichar (const wchar_t * sztext) { Char * P = NULL; Static int nindex = 0; Static char szbuffer [t_max_buf_len] [t_buf_size]; Memset (szbuffer [nindex], 0, sizeof (szbuffer [nindex]); If (widechartomultibyte (cp_acp, 0, sztext,-1, szbuffer [nindex], sizeof (szbuffer [nindex]), null, null )) { P = szbuffer [nindex]; } Nindex ++; If (nindex> = t_max_buf_len) nindex = 0; Return P; } |