mbtowc.c revision 114410893548b9522c46fdcbd8f63385eb8bfb68
/*
* MultiByteToWideChar implementation
*
* Copyright 2000 Alexandre Julliard
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
* Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Sun elects to use only
* the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
* a choice of LGPL license versions is made available with the language indicating
* that LGPLv2 or any later version may be used, or where a choice of which version
* of the LGPL is applied is otherwise unspecified.
*/
#include "config.h"
#include <string.h>
/* get the decomposition of a Unicode char */
{
extern const WCHAR unicode_decompose_table[];
int res;
if (!*ptr) return 1;
if (dstlen <= 1) return 0;
/* apply the decomposition recursively to the first char */
return res;
}
/* check src string for invalid chars; return non-zero if invalid char found */
{
+ (def_unicode_char & 0xff)];
while (srclen)
{
src++;
srclen--;
}
return srclen;
}
/* mbstowcs for single-byte code page */
/* all lengths are in characters, not bytes */
{
{
/* buffer too small: fill it up to dstlen and return error */
ret = -1;
}
for (;;)
{
switch(srclen)
{
default:
case 0: break;
}
dst += 16;
src += 16;
srclen -= 16;
}
}
/* mbstowcs for single-byte code page with char decomposition */
{
unsigned int len;
if (!dstlen) /* compute length */
{
return len;
}
{
if (!res) break;
}
}
/* query necessary dst length for src string */
{
int len;
{
{
if (!--srclen) break; /* partial char, ignore it */
src++;
}
}
return len;
}
/* check src string for invalid chars; return non-zero if invalid char found */
{
+ (def_unicode_char & 0xff)];
while (srclen)
{
if (off) /* multi-byte char */
{
src++;
srclen--;
}
src++;
srclen--;
}
return srclen;
}
/* mbstowcs for double-byte code page */
/* all lengths are in characters, not bytes */
{
unsigned int len;
{
if (off)
{
if (!--srclen) break; /* partial char, ignore it */
src++;
}
}
}
/* mbstowcs for double-byte code page with character decomposition */
{
unsigned int len;
int res;
if (!dstlen) /* compute length */
{
{
if (off)
{
if (!--srclen) break; /* partial char, ignore it */
src++;
}
}
return len;
}
{
if (off)
{
if (!--srclen) break; /* partial char, ignore it */
src++;
}
}
}
/* return -1 on dst buffer overflow, -2 on invalid input char */
const char *s, int srclen,
{
const unsigned char *src = (const unsigned char*) s;
{
if (flags & MB_ERR_INVALID_CHARS)
{
}
if (!(flags & MB_COMPOSITE))
{
}
}
else /* mbcs */
{
if (flags & MB_ERR_INVALID_CHARS)
{
}
if (!(flags & MB_COMPOSITE))
else
}
}
/* CP_SYMBOL implementation */
/* return -1 on dst buffer overflow */
{
int len, i;
for( i = 0; i < len; i++)
{
unsigned char c = src [ i ];
if( c < 0x20 )
dst[i] = c;
else
dst[i] = c + 0xf000;
}
return len;
}