Implemented multibyte string reverse.

This commit is contained in:
Mike McCormack 2001-08-09 21:37:19 +00:00 committed by Alexandre Julliard
parent c4e40d8f9e
commit 7b3495ac93
2 changed files with 49 additions and 1 deletions

View File

@ -602,3 +602,51 @@ int _ismbcspace( unsigned int c)
FIXME("%c\n",c);
return 0;
}
/*********************************************************************
* _mbsrev (MSVCRT.@)
*/
char *_mbsrev(char *str)
{
int i, len = _mbslen(str);
char *p, *temp=MSVCRT_malloc(len*2);
if(!temp)
return str;
/* unpack multibyte string to temp buffer */
p=str;
for(i=0; i<len; i++)
{
if (MSVCRT_isleadbyte(*p))
{
temp[i*2]=*p++;
temp[i*2+1]=*p++;
}
else
{
temp[i*2]=*p++;
temp[i*2+1]=0;
}
}
/* repack it in the reverse order */
p=str;
for(i=len-1; i>=0; i--)
{
if(MSVCRT_isleadbyte(temp[i*2]))
{
*p++=temp[i*2];
*p++=temp[i*2+1];
}
else
{
*p++=temp[i*2];
}
}
MSVCRT_free(temp);
return str;
}

View File

@ -385,7 +385,7 @@ debug_channels (msvcrt)
@ cdecl _mbsnset(str long long) _mbsnset
@ stub _mbspbrk #(str str)
@ cdecl _mbsrchr(str long) _mbsrchr
@ stub _mbsrev #(str)
@ cdecl _mbsrev(str) _mbsrev
@ cdecl _mbsset(str long) _mbsset
@ cdecl _mbsspn(str str) _mbsspn
@ stub _mbsspnp #(str str)