forked from sebastienros/fluid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NullEncoder.cs
37 lines (30 loc) · 1.06 KB
/
NullEncoder.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
using System.Runtime.CompilerServices;
using System.Text.Encodings.Web;
namespace Fluid
{
// An HTML encoder which passes through all input data. Does no encoding.
public sealed class NullEncoder : TextEncoder
{
private NullEncoder()
{
}
public static NullEncoder Default { get; } = new NullEncoder();
public override int MaxOutputCharactersPerInputCharacter => 1;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override unsafe int FindFirstCharacterToEncode(char* text, int textLength)
{
return -1;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override unsafe bool TryEncodeUnicodeScalar(int unicodeScalar, char* buffer, int bufferLength, out int numberOfCharactersWritten)
{
numberOfCharactersWritten = 0;
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool WillEncode(int unicodeScalar)
{
return false;
}
}
}