@@ -164,7 +164,7 @@ static void GetPasswordText(wchar *Str,uint MaxLength)
164164 SetConsoleMode (hConIn,ConInMode);
165165 SetConsoleMode (hConOut,ConOutMode);
166166#else
167- char StrA[MAXPASSWORD];
167+ char StrA[MAXPASSWORD* 4 ]; // "*4" for multibyte UTF-8 characters.
168168#if defined(_EMX) || defined (__VMS)
169169 fgets (StrA,ASIZE (StrA)-1 ,stdin);
170170#elif defined(__sun)
@@ -248,6 +248,12 @@ bool getwstr(wchar *str,size_t n)
248248 ErrHandler.Exit (RARX_USERBREAK);
249249 }
250250 StrA[ReadSize]=0 ;
251+
252+ // We expect ANSI encoding here, but "echo text|rar ..." to pipe to RAR,
253+ // such as send passwords, we get OEM encoding by default, unless we
254+ // use "chcp" in console. But we avoid OEM to ANSI conversion,
255+ // because we also want to handle ANSI files redirection correctly,
256+ // like "rar ... < ansifile.txt".
251257 CharToWide (&StrA[0 ],str,n);
252258 cleandata (&StrA[0 ],StrA.Size ()); // We can use this function to enter passwords.
253259 }
@@ -305,7 +311,7 @@ int Ask(const wchar *AskStr)
305311
306312 for (int I=0 ;I<NumItems;I++)
307313 {
308- eprintf (I==0 ? (NumItems>4 ? L" \n " :L" " ):L" , " );
314+ eprintf (I==0 ? (NumItems>3 ? L" \n " :L" " ):L" , " );
309315 int KeyPos=ItemKeyPos[I];
310316 for (int J=0 ;J<KeyPos;J++)
311317 eprintf (L" %c" ,Item[I][J]);
0 commit comments