34 lines
736 B
C#
34 lines
736 B
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace IrcTokens
|
|
{
|
|
public class StatefulDecoder
|
|
{
|
|
private string _buffer;
|
|
public EncodingInfo Encoding { get; set; }
|
|
public EncodingInfo Fallback { get; set; }
|
|
|
|
public string Pending => _buffer;
|
|
|
|
public void Clear()
|
|
{
|
|
_buffer = "";
|
|
}
|
|
|
|
public List<Line> Push(string data)
|
|
{
|
|
if (string.IsNullOrEmpty(data))
|
|
return null;
|
|
|
|
_buffer += data;
|
|
return _buffer
|
|
.Split('\n')
|
|
.Select(l => l.TrimEnd('\r'))
|
|
.Select(l => new Line(l))
|
|
.ToList();
|
|
}
|
|
}
|
|
}
|