mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-06 17:15:00 -06:00
9.04 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
8874e4fbc9
commit
829409452d
@@ -3,7 +3,10 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <tchar.h>
|
||||
|
||||
#include "StdInStream.h"
|
||||
#include "StringConvert.h"
|
||||
#include "UTFConvert.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// "was declared deprecated" disabling
|
||||
@@ -19,6 +22,8 @@ static const char *kIllegalCharMessage = "Illegal character in input stream";
|
||||
|
||||
static LPCTSTR kFileOpenMode = TEXT("r");
|
||||
|
||||
extern int g_CodePage;
|
||||
|
||||
CStdInStream g_StdIn(stdin);
|
||||
|
||||
bool CStdInStream::Open(LPCTSTR fileName)
|
||||
@@ -42,14 +47,18 @@ CStdInStream::~CStdInStream()
|
||||
Close();
|
||||
}
|
||||
|
||||
AString CStdInStream::ScanStringUntilNewLine()
|
||||
AString CStdInStream::ScanStringUntilNewLine(bool allowEOF)
|
||||
{
|
||||
AString s;
|
||||
for (;;)
|
||||
{
|
||||
int intChar = GetChar();
|
||||
if (intChar == EOF)
|
||||
{
|
||||
if (allowEOF)
|
||||
break;
|
||||
throw kEOFMessage;
|
||||
}
|
||||
char c = char(intChar);
|
||||
if (c == kIllegalChar)
|
||||
throw kIllegalCharMessage;
|
||||
@@ -60,6 +69,20 @@ AString CStdInStream::ScanStringUntilNewLine()
|
||||
return s;
|
||||
}
|
||||
|
||||
UString CStdInStream::ScanUStringUntilNewLine()
|
||||
{
|
||||
AString s = ScanStringUntilNewLine(true);
|
||||
int codePage = g_CodePage;
|
||||
if (codePage == -1)
|
||||
codePage = CP_OEMCP;
|
||||
UString dest;
|
||||
if (codePage == CP_UTF8)
|
||||
ConvertUTF8ToUnicode(s, dest);
|
||||
else
|
||||
dest = MultiByteToUnicodeString(s, (UINT)codePage);
|
||||
return dest;
|
||||
}
|
||||
|
||||
void CStdInStream::ReadToString(AString &resultString)
|
||||
{
|
||||
resultString.Empty();
|
||||
|
||||
Reference in New Issue
Block a user