else // no destination buffer
{
// convert using temp buffer to calculate the size of the buffer needed
- wchar_t tbuf[8];
+ wchar_t tbuf[256];
res = 0;
do
if (ms_wcNeedsSwap)
{
// need to copy to temp buffer to switch endianness
- // (doing WC_BSWAP twice on the original buffer won't help, as it
+ // (doing WC_BSWAP twice on the original buffer won't work, as it
// could be in read-only memory, or be accessed in some other thread)
- tmpbuf = (wchar_t *)malloc(inbuflen + SIZEOF_WCHAR_T);
+ tmpbuf = (wchar_t *)malloc(inbuflen);
for ( size_t i = 0; i < srcLen; i++ )
tmpbuf[i] = WC_BSWAP(src[i]);
- tmpbuf[srcLen] = L'\0';
src = tmpbuf;
}
else // no destination buffer
{
// convert using temp buffer to calculate the size of the buffer needed
- char tbuf[16];
+ char tbuf[256];
res = 0;
do
{
dst = tbuf;
- outbuflen = 16;
+ outbuflen = WXSIZEOF(tbuf);
cres = iconv(w2m, ICONV_CHAR_CAST(&inbuf), &inbuflen, &dst, &outbuflen);
- res += 16 - outbuflen;
+ res += WXSIZEOF(tbuf) - outbuflen;
}
while ((cres == (size_t)-1) && (errno == E2BIG));
}
#if wxUSE_FONTMAP
m_encoding = wxFontMapperBase::GetEncodingFromName(charset);
+ if ( m_encoding == wxFONTENCODING_MAX )
+ {
+ // set to unknown/invalid value
+ m_encoding = wxFONTENCODING_SYSTEM;
+ }
+ else if ( m_encoding == wxFONTENCODING_DEFAULT )
+ {
+ // wxFONTENCODING_DEFAULT is same as US-ASCII in this context
+ m_encoding = wxFONTENCODING_ISO8859_1;
+ }
#else
m_encoding = wxFONTENCODING_SYSTEM;
#endif