mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
WideCharToMultiByte accept each code page like MultiByteToWideChar.
Wmc.exe will now produce correct header files (bugcode.h) on ros. svn path=/trunk/; revision=3586
This commit is contained in:
parent
d9c63079bb
commit
5bb8c3c68f
1 changed files with 65 additions and 54 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: stubs.c,v 1.34 2002/09/27 15:29:03 hbirr Exp $
|
/* $Id: stubs.c,v 1.35 2002/09/30 21:01:32 hbirr Exp $
|
||||||
*
|
*
|
||||||
* KERNEL32.DLL stubs (unimplemented functions)
|
* KERNEL32.DLL stubs (unimplemented functions)
|
||||||
* Remove from this file, if you implement them.
|
* Remove from this file, if you implement them.
|
||||||
|
@ -1385,19 +1385,39 @@ WideCharToMultiByte (
|
||||||
{
|
{
|
||||||
int wi, di; // wide counter, dbcs byte count
|
int wi, di; // wide counter, dbcs byte count
|
||||||
|
|
||||||
// for now, make no difference but only convert cut the characters to 7Bit
|
/*
|
||||||
switch( CodePage )
|
* Check the parameters.
|
||||||
|
*/
|
||||||
|
if ( /* --- CODE PAGE --- */
|
||||||
|
( (CP_ACP != CodePage)
|
||||||
|
&& (CP_MACCP != CodePage)
|
||||||
|
&& (CP_OEMCP != CodePage)
|
||||||
|
&& (CP_SYMBOL != CodePage)
|
||||||
|
&& (CP_THREAD_ACP != CodePage)
|
||||||
|
&& (CP_UTF7 != CodePage)
|
||||||
|
&& (CP_UTF8 != CodePage)
|
||||||
|
&& (FALSE == IsInstalledCP (CodePage))
|
||||||
|
)
|
||||||
|
/* --- FLAGS --- */
|
||||||
|
|| (dwFlags & ~(/*WC_NO_BEST_FIT_CHARS
|
||||||
|
|*/ WC_COMPOSITECHECK
|
||||||
|
| WC_DISCARDNS
|
||||||
|
| WC_SEPCHARS
|
||||||
|
| WC_DEFAULTCHAR
|
||||||
|
)
|
||||||
|
)
|
||||||
|
/* --- INPUT BUFFER --- */
|
||||||
|
|| (NULL == lpWideCharStr)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
case CP_ACP: //ANSI code page
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
case CP_MACCP: //Macintosh code page
|
return 0;
|
||||||
case CP_OEMCP: //OEM code page
|
}
|
||||||
case CP_SYMBOL: //Symbol code page (42)
|
|
||||||
case CP_THREAD_ACP: //ACP Current thread's ANSI code page
|
// for now, make no difference but only convert cut the characters to 7Bit
|
||||||
case CP_UTF7: //Translate using UTF-7
|
|
||||||
case CP_UTF8: //Translate using UTF-8
|
|
||||||
if( cchWideChar == -1 ) // assume its a 0-terminated str
|
if( cchWideChar == -1 ) // assume its a 0-terminated str
|
||||||
{ // and determine its length
|
{ // and determine its length
|
||||||
for( cchWideChar=0; lpWideCharStr[cchWideChar]!=0; )
|
for( cchWideChar=0; lpWideCharStr[cchWideChar]!=0; cchWideChar++)
|
||||||
cchWideChar++;
|
cchWideChar++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1408,7 +1428,7 @@ WideCharToMultiByte (
|
||||||
return cchWideChar; // FIXME: determine correct.
|
return cchWideChar; // FIXME: determine correct.
|
||||||
}
|
}
|
||||||
// the lpWideCharStr is cchWideChar characters long.
|
// the lpWideCharStr is cchWideChar characters long.
|
||||||
for( wi=0, di=0; wi<cchWideChar && di<cchMultiByte; ++wi)
|
for( wi=0, di=0; wi<cchWideChar && di<cchMultiByte; ++wi, ++di)
|
||||||
{
|
{
|
||||||
// Flag and a not displayable char FIXME
|
// Flag and a not displayable char FIXME
|
||||||
/*if( (dwFlags&WC_NO_BEST_FIT_CHARS) && (lpWideCharStr[wi] >127) )
|
/*if( (dwFlags&WC_NO_BEST_FIT_CHARS) && (lpWideCharStr[wi] >127) )
|
||||||
|
@ -1420,27 +1440,18 @@ WideCharToMultiByte (
|
||||||
// FIXME
|
// FIXME
|
||||||
// just cut off the upper 9 Bit, since vals>=128 mean LeadByte.
|
// just cut off the upper 9 Bit, since vals>=128 mean LeadByte.
|
||||||
lpMultiByteStr[di] = lpWideCharStr[wi] & 0x007F;
|
lpMultiByteStr[di] = lpWideCharStr[wi] & 0x007F;
|
||||||
++di;
|
|
||||||
}
|
}
|
||||||
// has MultiByte exceeded but Wide is still in the string?
|
// has MultiByte exceeded but Wide is still in the string?
|
||||||
if( wi < cchWideChar && di >= cchMultiByte)
|
if( wi < cchWideChar && di >= cchMultiByte)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
||||||
return di;
|
return 0;
|
||||||
}
|
}
|
||||||
// else return # of bytes wirtten to MBCSbuffer (di)
|
// else return # of bytes wirtten to MBCSbuffer (di)
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
// FIXME: move that elsewhere
|
// FIXME: move that elsewhere
|
||||||
if( lpUsedDefaultChar!=NULL ) *lpUsedDefaultChar=FALSE;
|
if( lpUsedDefaultChar!=NULL ) *lpUsedDefaultChar=FALSE;
|
||||||
return di;
|
return di;
|
||||||
break;
|
|
||||||
default:
|
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
|
||||||
return FALSE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue