Author: cwittich Date: Wed Dec 19 13:56:29 2007 New Revision: 31322
URL: http://svn.reactos.org/svn/reactos?rev=31322&view=rev Log: support CP_SYMBOL in MultiByteToWideChar and WideCharToMultiByte ported from Wine. patch by Daniel Zimmermann <netzimme at aim dot com> See issue #2870 for more details.
Modified: trunk/reactos/dll/win32/kernel32/misc/nls.c
Modified: trunk/reactos/dll/win32/kernel32/misc/nls.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/nls... ============================================================================== --- trunk/reactos/dll/win32/kernel32/misc/nls.c (original) +++ trunk/reactos/dll/win32/kernel32/misc/nls.c Wed Dec 19 13:56:29 2007 @@ -495,6 +495,116 @@
return MultiByteCount; } +} + +/** + * @name IntMultiByteToWideCharSYMBOL + * + * Internal version of MultiByteToWideChar for SYMBOL. + * + * @see MultiByteToWideChar + */ + +static INT STDCALL +IntMultiByteToWideCharSYMBOL(DWORD Flags, + LPCSTR MultiByteString, INT MultiByteCount, + LPWSTR WideCharString, INT WideCharCount) +{ + LONG Count; + UCHAR Char; + INT WideCharMaxLen; + + + if (Flags != 0) + { + SetLastError(ERROR_INVALID_FLAGS); + return 0; + } + + if (WideCharCount == 0) + { + return MultiByteCount; + } + + WideCharMaxLen = WideCharCount > MultiByteCount ? MultiByteCount : WideCharCount; + + for (Count = 0; Count < WideCharMaxLen; Count++) + { + Char = MultiByteString[Count]; + if ( Char < 0x20 ) + { + WideCharString[Count] = Char; + } + else + { + WideCharString[Count] = Char + 0xf000; + } + } + if (MultiByteCount > WideCharMaxLen) + { + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return 0; + } + + return WideCharMaxLen; +} + +/** + * @name IntWideCharToMultiByteSYMBOL + * + * Internal version of WideCharToMultiByte for SYMBOL. + * + * @see WideCharToMultiByte + */ + +static INT STDCALL +IntWideCharToMultiByteSYMBOL(DWORD Flags, + LPCWSTR WideCharString, INT WideCharCount, + LPSTR MultiByteString, INT MultiByteCount) +{ + LONG Count; + INT MaxLen; + WCHAR Char; + + if (Flags!=0) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + + if( MultiByteCount == 0) + { + return WideCharCount; + } + + MaxLen = MultiByteCount>WideCharCount?WideCharCount:MultiByteCount; + for (Count = 0;Count<MaxLen;Count++) + { + Char = WideCharString[Count]; + if (Char<0x20) + { + MultiByteString[Count] = Char; + } + else + { + if ((Char>=0xf020)&&(Char<0xf100)) + { + MultiByteString[Count] = Char - 0xf000; + } + else + { + SetLastError(ERROR_NO_UNICODE_TRANSLATION); + return 0; + } + } + } + if ( WideCharCount > MaxLen) + { + SetLastError(ERROR_INSUFFICIENT_BUFFER); + return 0; + } + return MaxLen; }
/** @@ -951,9 +1061,9 @@ return 0;
case CP_SYMBOL: - DPRINT1("MultiByteToWideChar for CP_SYMBOL is not implemented!\n"); - return 0; - + return IntMultiByteToWideCharSYMBOL( + Flags, MultiByteString, MultiByteCount, + WideCharString, WideCharCount); default: return IntMultiByteToWideCharCP( CodePage, Flags, MultiByteString, MultiByteCount, @@ -1034,8 +1144,14 @@ return 0;
case CP_SYMBOL: - DPRINT1("WideCharToMultiByte for CP_SYMBOL is not implemented!\n"); - return 0; + if ((DefaultChar!=NULL) || (UsedDefaultChar!=NULL)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + return IntWideCharToMultiByteSYMBOL( + Flags,WideCharString,WideCharCount,MultiByteString, + MultiByteCount);
default: return IntWideCharToMultiByteCP(