-
Notifications
You must be signed in to change notification settings - Fork 0
/
CodecBase85.cs
42 lines (36 loc) · 1.2 KB
/
CodecBase85.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
namespace TuckBytesInCode
{
public sealed class CodecBase85 : ICharLookup, IBaseInfo
{
public char Map(int index)
{
if (index < 0 || index >= AllChars.Length) {
throw new IndexOutOfRangeException();
}
return AllChars[index];
}
public char Padding { get { return '\0'; }}
public bool IncludePadding { get { return false; }}
public int BytesIn { get { return 4; }}
public int CharsOut { get { return 5; }}
public bool TreatAsBinary { get { return false; }}
private CodecBase85() {}
static CodecBase85 _self = null;
public static CodecBase85 Self {
get {
if (_self == null) {
_self = new CodecBase85();
}
return _self;
}
}
public Base Identifier { get { return Base.Base85; }}
public string DisplayName { get { return "Base 85"; }}
public string Description { get { return "text-encoded base 85"; }}
public ICharLookup BaseInstance { get { return Self; }}
// https://tools.ietf.org/html/rfc1924
//static string AllChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~";
static string AllChars = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstu";
}
}