public ReadCharString ( byte tag = 255 ) : string | ||
tag | byte | The tag number of the char string tag, or 255 for an application tag |
return | string |
public string ReadCharString(byte tag = 255)
{
_ensureTag(tag, ApplicationTag.CharString);
_ensureLVT(LVT.Length);
// we need at least one byte for the encoding
if (_length < 1)
throw new InvalidTagException();
// we only support ANSI for now
CharStringEncoding encoding = (CharStringEncoding)_reader.ReadByte();
if (encoding != CharStringEncoding.ANSI)
throw new InvalidTagException();
var bytes = _reader.ReadBytes((int)_length - 1);
return Encoding.ASCII.GetString(bytes);
}