417 lines
11 KiB
C#
417 lines
11 KiB
C#
using System;
|
||
using System.Runtime.CompilerServices;
|
||
|
||
namespace System.Text
|
||
{
|
||
// Token: 0x020005F5 RID: 1525
|
||
[Serializable]
|
||
internal class Latin1Encoding : Encoding
|
||
{
|
||
// Token: 0x0600379B RID: 14235 RVA: 0x000BE7C4 File Offset: 0x000BC9C4
|
||
public Latin1Encoding()
|
||
: base(28591)
|
||
{
|
||
}
|
||
|
||
// Token: 0x17000AEF RID: 2799
|
||
// (get) Token: 0x0600379C RID: 14236 RVA: 0x000BE7D4 File Offset: 0x000BC9D4
|
||
public override bool IsSingleByte
|
||
{
|
||
get
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
|
||
// Token: 0x0600379D RID: 14237 RVA: 0x000BE7D8 File Offset: 0x000BC9D8
|
||
public override bool IsAlwaysNormalized(NormalizationForm form)
|
||
{
|
||
return form == NormalizationForm.FormC;
|
||
}
|
||
|
||
// Token: 0x0600379E RID: 14238 RVA: 0x000BE7E0 File Offset: 0x000BC9E0
|
||
public override int GetByteCount(char[] chars, int index, int count)
|
||
{
|
||
if (chars == null)
|
||
{
|
||
throw new ArgumentNullException("chars");
|
||
}
|
||
if (index < 0 || index > chars.Length)
|
||
{
|
||
throw new ArgumentOutOfRangeException("index", Encoding._("ArgRange_Array"));
|
||
}
|
||
if (count < 0 || count > chars.Length - index)
|
||
{
|
||
throw new ArgumentOutOfRangeException("count", Encoding._("ArgRange_Array"));
|
||
}
|
||
return count;
|
||
}
|
||
|
||
// Token: 0x0600379F RID: 14239 RVA: 0x000BE84C File Offset: 0x000BCA4C
|
||
public override int GetByteCount(string s)
|
||
{
|
||
if (s == null)
|
||
{
|
||
throw new ArgumentNullException("s");
|
||
}
|
||
return s.Length;
|
||
}
|
||
|
||
// Token: 0x060037A0 RID: 14240 RVA: 0x000BE868 File Offset: 0x000BCA68
|
||
public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
|
||
{
|
||
EncoderFallbackBuffer encoderFallbackBuffer = null;
|
||
char[] array = null;
|
||
return this.GetBytes(chars, charIndex, charCount, bytes, byteIndex, ref encoderFallbackBuffer, ref array);
|
||
}
|
||
|
||
// Token: 0x060037A1 RID: 14241 RVA: 0x000BE88C File Offset: 0x000BCA8C
|
||
private int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, ref EncoderFallbackBuffer buffer, ref char[] fallback_chars)
|
||
{
|
||
if (chars == null)
|
||
{
|
||
throw new ArgumentNullException("chars");
|
||
}
|
||
if (bytes == null)
|
||
{
|
||
throw new ArgumentNullException("bytes");
|
||
}
|
||
if (charIndex < 0 || charIndex > chars.Length)
|
||
{
|
||
throw new ArgumentOutOfRangeException("charIndex", Encoding._("ArgRange_Array"));
|
||
}
|
||
if (charCount < 0 || charCount > chars.Length - charIndex)
|
||
{
|
||
throw new ArgumentOutOfRangeException("charCount", Encoding._("ArgRange_Array"));
|
||
}
|
||
if (byteIndex < 0 || byteIndex > bytes.Length)
|
||
{
|
||
throw new ArgumentOutOfRangeException("byteIndex", Encoding._("ArgRange_Array"));
|
||
}
|
||
if (bytes.Length - byteIndex < charCount)
|
||
{
|
||
throw new ArgumentException(Encoding._("Arg_InsufficientSpace"));
|
||
}
|
||
int num = charCount;
|
||
while (num-- > 0)
|
||
{
|
||
char c = chars[charIndex++];
|
||
if (c < 'Ā')
|
||
{
|
||
bytes[byteIndex++] = (byte)c;
|
||
}
|
||
else if (c >= '!' && c <= '~')
|
||
{
|
||
bytes[byteIndex++] = (byte)(c - 'ﻠ');
|
||
}
|
||
else
|
||
{
|
||
if (buffer == null)
|
||
{
|
||
buffer = base.EncoderFallback.CreateFallbackBuffer();
|
||
}
|
||
if (char.IsSurrogate(c) && num > 1 && char.IsSurrogate(chars[charIndex]))
|
||
{
|
||
buffer.Fallback(c, chars[charIndex], charIndex++ - 1);
|
||
}
|
||
else
|
||
{
|
||
buffer.Fallback(c, charIndex - 1);
|
||
}
|
||
if (fallback_chars == null || fallback_chars.Length < buffer.Remaining)
|
||
{
|
||
fallback_chars = new char[buffer.Remaining];
|
||
}
|
||
for (int i = 0; i < fallback_chars.Length; i++)
|
||
{
|
||
fallback_chars[i] = buffer.GetNextChar();
|
||
}
|
||
byteIndex += this.GetBytes(fallback_chars, 0, fallback_chars.Length, bytes, byteIndex, ref buffer, ref fallback_chars);
|
||
}
|
||
}
|
||
return charCount;
|
||
}
|
||
|
||
// Token: 0x060037A2 RID: 14242 RVA: 0x000BEA78 File Offset: 0x000BCC78
|
||
public override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex)
|
||
{
|
||
EncoderFallbackBuffer encoderFallbackBuffer = null;
|
||
char[] array = null;
|
||
return this.GetBytes(s, charIndex, charCount, bytes, byteIndex, ref encoderFallbackBuffer, ref array);
|
||
}
|
||
|
||
// Token: 0x060037A3 RID: 14243 RVA: 0x000BEA9C File Offset: 0x000BCC9C
|
||
private int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex, ref EncoderFallbackBuffer buffer, ref char[] fallback_chars)
|
||
{
|
||
if (s == null)
|
||
{
|
||
throw new ArgumentNullException("s");
|
||
}
|
||
if (bytes == null)
|
||
{
|
||
throw new ArgumentNullException("bytes");
|
||
}
|
||
if (charIndex < 0 || charIndex > s.Length)
|
||
{
|
||
throw new ArgumentOutOfRangeException("charIndex", Encoding._("ArgRange_StringIndex"));
|
||
}
|
||
if (charCount < 0 || charCount > s.Length - charIndex)
|
||
{
|
||
throw new ArgumentOutOfRangeException("charCount", Encoding._("ArgRange_StringRange"));
|
||
}
|
||
if (byteIndex < 0 || byteIndex > bytes.Length)
|
||
{
|
||
throw new ArgumentOutOfRangeException("byteIndex", Encoding._("ArgRange_Array"));
|
||
}
|
||
if (bytes.Length - byteIndex < charCount)
|
||
{
|
||
throw new ArgumentException(Encoding._("Arg_InsufficientSpace"));
|
||
}
|
||
int num = charCount;
|
||
while (num-- > 0)
|
||
{
|
||
char c = s[charIndex++];
|
||
if (c < 'Ā')
|
||
{
|
||
bytes[byteIndex++] = (byte)c;
|
||
}
|
||
else if (c >= '!' && c <= '~')
|
||
{
|
||
bytes[byteIndex++] = (byte)(c - 'ﻠ');
|
||
}
|
||
else
|
||
{
|
||
if (buffer == null)
|
||
{
|
||
buffer = base.EncoderFallback.CreateFallbackBuffer();
|
||
}
|
||
if (char.IsSurrogate(c) && num > 1 && char.IsSurrogate(s[charIndex]))
|
||
{
|
||
buffer.Fallback(c, s[charIndex], charIndex++ - 1);
|
||
}
|
||
else
|
||
{
|
||
buffer.Fallback(c, charIndex - 1);
|
||
}
|
||
if (fallback_chars == null || fallback_chars.Length < buffer.Remaining)
|
||
{
|
||
fallback_chars = new char[buffer.Remaining];
|
||
}
|
||
for (int i = 0; i < fallback_chars.Length; i++)
|
||
{
|
||
fallback_chars[i] = buffer.GetNextChar();
|
||
}
|
||
byteIndex += this.GetBytes(fallback_chars, 0, fallback_chars.Length, bytes, byteIndex, ref buffer, ref fallback_chars);
|
||
}
|
||
}
|
||
return charCount;
|
||
}
|
||
|
||
// Token: 0x060037A4 RID: 14244 RVA: 0x000BEC9C File Offset: 0x000BCE9C
|
||
public override int GetCharCount(byte[] bytes, int index, int count)
|
||
{
|
||
if (bytes == null)
|
||
{
|
||
throw new ArgumentNullException("bytes");
|
||
}
|
||
if (index < 0 || index > bytes.Length)
|
||
{
|
||
throw new ArgumentOutOfRangeException("index", Encoding._("ArgRange_Array"));
|
||
}
|
||
if (count < 0 || count > bytes.Length - index)
|
||
{
|
||
throw new ArgumentOutOfRangeException("count", Encoding._("ArgRange_Array"));
|
||
}
|
||
return count;
|
||
}
|
||
|
||
// Token: 0x060037A5 RID: 14245 RVA: 0x000BED08 File Offset: 0x000BCF08
|
||
public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
|
||
{
|
||
if (bytes == null)
|
||
{
|
||
throw new ArgumentNullException("bytes");
|
||
}
|
||
if (chars == null)
|
||
{
|
||
throw new ArgumentNullException("chars");
|
||
}
|
||
if (byteIndex < 0 || byteIndex > bytes.Length)
|
||
{
|
||
throw new ArgumentOutOfRangeException("byteIndex", Encoding._("ArgRange_Array"));
|
||
}
|
||
if (byteCount < 0 || byteCount > bytes.Length - byteIndex)
|
||
{
|
||
throw new ArgumentOutOfRangeException("byteCount", Encoding._("ArgRange_Array"));
|
||
}
|
||
if (charIndex < 0 || charIndex > chars.Length)
|
||
{
|
||
throw new ArgumentOutOfRangeException("charIndex", Encoding._("ArgRange_Array"));
|
||
}
|
||
if (chars.Length - charIndex < byteCount)
|
||
{
|
||
throw new ArgumentException(Encoding._("Arg_InsufficientSpace"));
|
||
}
|
||
int num = byteCount;
|
||
while (num-- > 0)
|
||
{
|
||
chars[charIndex++] = (char)bytes[byteIndex++];
|
||
}
|
||
return byteCount;
|
||
}
|
||
|
||
// Token: 0x060037A6 RID: 14246 RVA: 0x000BEDF0 File Offset: 0x000BCFF0
|
||
public override int GetMaxByteCount(int charCount)
|
||
{
|
||
if (charCount < 0)
|
||
{
|
||
throw new ArgumentOutOfRangeException("charCount", Encoding._("ArgRange_NonNegative"));
|
||
}
|
||
return charCount;
|
||
}
|
||
|
||
// Token: 0x060037A7 RID: 14247 RVA: 0x000BEE10 File Offset: 0x000BD010
|
||
public override int GetMaxCharCount(int byteCount)
|
||
{
|
||
if (byteCount < 0)
|
||
{
|
||
throw new ArgumentOutOfRangeException("byteCount", Encoding._("ArgRange_NonNegative"));
|
||
}
|
||
return byteCount;
|
||
}
|
||
|
||
// Token: 0x060037A8 RID: 14248 RVA: 0x000BEE30 File Offset: 0x000BD030
|
||
public unsafe override string GetString(byte[] bytes, int index, int count)
|
||
{
|
||
if (bytes == null)
|
||
{
|
||
throw new ArgumentNullException("bytes");
|
||
}
|
||
if (index < 0 || index > bytes.Length)
|
||
{
|
||
throw new ArgumentOutOfRangeException("index", Encoding._("ArgRange_Array"));
|
||
}
|
||
if (count < 0 || count > bytes.Length - index)
|
||
{
|
||
throw new ArgumentOutOfRangeException("count", Encoding._("ArgRange_Array"));
|
||
}
|
||
if (count == 0)
|
||
{
|
||
return string.Empty;
|
||
}
|
||
fixed (byte* ptr = (ref bytes != null && bytes.Length != 0 ? ref bytes[0] : ref *null))
|
||
{
|
||
string text = string.InternalAllocateStr(count);
|
||
fixed (string text2 = text)
|
||
{
|
||
fixed (char* ptr2 = text2 + RuntimeHelpers.OffsetToStringData / 2)
|
||
{
|
||
byte* ptr3 = ptr + index;
|
||
byte* ptr4 = ptr3 + count;
|
||
char* ptr5 = ptr2;
|
||
while (ptr3 < ptr4)
|
||
{
|
||
*(ptr5++) = (char)(*(ptr3++));
|
||
}
|
||
text2 = null;
|
||
return text;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// Token: 0x060037A9 RID: 14249 RVA: 0x000BEF08 File Offset: 0x000BD108
|
||
public override string GetString(byte[] bytes)
|
||
{
|
||
if (bytes == null)
|
||
{
|
||
throw new ArgumentNullException("bytes");
|
||
}
|
||
return this.GetString(bytes, 0, bytes.Length);
|
||
}
|
||
|
||
// Token: 0x17000AF0 RID: 2800
|
||
// (get) Token: 0x060037AA RID: 14250 RVA: 0x000BEF28 File Offset: 0x000BD128
|
||
public override string BodyName
|
||
{
|
||
get
|
||
{
|
||
return "iso-8859-1";
|
||
}
|
||
}
|
||
|
||
// Token: 0x17000AF1 RID: 2801
|
||
// (get) Token: 0x060037AB RID: 14251 RVA: 0x000BEF30 File Offset: 0x000BD130
|
||
public override string EncodingName
|
||
{
|
||
get
|
||
{
|
||
return "Western European (ISO)";
|
||
}
|
||
}
|
||
|
||
// Token: 0x17000AF2 RID: 2802
|
||
// (get) Token: 0x060037AC RID: 14252 RVA: 0x000BEF38 File Offset: 0x000BD138
|
||
public override string HeaderName
|
||
{
|
||
get
|
||
{
|
||
return "iso-8859-1";
|
||
}
|
||
}
|
||
|
||
// Token: 0x17000AF3 RID: 2803
|
||
// (get) Token: 0x060037AD RID: 14253 RVA: 0x000BEF40 File Offset: 0x000BD140
|
||
public override bool IsBrowserDisplay
|
||
{
|
||
get
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
|
||
// Token: 0x17000AF4 RID: 2804
|
||
// (get) Token: 0x060037AE RID: 14254 RVA: 0x000BEF44 File Offset: 0x000BD144
|
||
public override bool IsBrowserSave
|
||
{
|
||
get
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
|
||
// Token: 0x17000AF5 RID: 2805
|
||
// (get) Token: 0x060037AF RID: 14255 RVA: 0x000BEF48 File Offset: 0x000BD148
|
||
public override bool IsMailNewsDisplay
|
||
{
|
||
get
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
|
||
// Token: 0x17000AF6 RID: 2806
|
||
// (get) Token: 0x060037B0 RID: 14256 RVA: 0x000BEF4C File Offset: 0x000BD14C
|
||
public override bool IsMailNewsSave
|
||
{
|
||
get
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
|
||
// Token: 0x17000AF7 RID: 2807
|
||
// (get) Token: 0x060037B1 RID: 14257 RVA: 0x000BEF50 File Offset: 0x000BD150
|
||
public override string WebName
|
||
{
|
||
get
|
||
{
|
||
return "iso-8859-1";
|
||
}
|
||
}
|
||
|
||
// Token: 0x040016A5 RID: 5797
|
||
internal const int ISOLATIN_CODE_PAGE = 28591;
|
||
}
|
||
}
|