forked from jasder/antlr
Fix use of encoding argument in AntlrFileStream
This commit is contained in:
parent
7d7f5a1afc
commit
2ea504a493
|
@ -53,22 +53,26 @@ namespace Antlr4.Runtime
|
|||
}
|
||||
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public AntlrFileStream(string fileName, string encoding)
|
||||
public AntlrFileStream(string fileName, Encoding encoding)
|
||||
{
|
||||
this.fileName = fileName;
|
||||
Load(fileName, encoding);
|
||||
}
|
||||
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public virtual void Load(string fileName, string encoding)
|
||||
public virtual void Load(string fileName, Encoding encoding)
|
||||
{
|
||||
if (fileName == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Encoding fileEncoding = Encoding.GetEncoding(encoding);
|
||||
string text = File.ReadAllText(fileName, fileEncoding);
|
||||
string text;
|
||||
if (encoding != null)
|
||||
text = File.ReadAllText(fileName, encoding);
|
||||
else
|
||||
text = File.ReadAllText(fileName);
|
||||
|
||||
data = text.ToCharArray();
|
||||
n = data.Length;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue