mscorlib(4.0.0.0) API with additions
ASCIIEncoding.cs
2 using System.Security;
3 
4 namespace System.Text
5 {
7  [Serializable]
8  [ComVisible(true)]
9  [__DynamicallyInvokable]
10  public class ASCIIEncoding : Encoding
11  {
14  [ComVisible(false)]
15  [__DynamicallyInvokable]
16  public override bool IsSingleByte
17  {
18  [__DynamicallyInvokable]
19  get
20  {
21  return true;
22  }
23  }
24 
26  [__DynamicallyInvokable]
27  public ASCIIEncoding()
28  : base(20127)
29  {
30  }
31 
32  internal override void SetDefaultFallbacks()
33  {
34  encoderFallback = EncoderFallback.ReplacementFallback;
35  decoderFallback = DecoderFallback.ReplacementFallback;
36  }
37 
50  [SecuritySafeCritical]
51  [__DynamicallyInvokable]
52  public unsafe override int GetByteCount(char[] chars, int index, int count)
53  {
54  if (chars == null)
55  {
56  throw new ArgumentNullException("chars", Environment.GetResourceString("ArgumentNull_Array"));
57  }
58  if (index < 0 || count < 0)
59  {
60  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
61  }
62  if (chars.Length - index < count)
63  {
64  throw new ArgumentOutOfRangeException("chars", Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer"));
65  }
66  if (chars.Length == 0)
67  {
68  return 0;
69  }
70  fixed (char* ptr = chars)
71  {
72  return GetByteCount(ptr + index, count, null);
73  }
74  }
75 
84  [SecuritySafeCritical]
85  [__DynamicallyInvokable]
86  public unsafe override int GetByteCount(string chars)
87  {
88  if (chars == null)
89  {
90  throw new ArgumentNullException("chars");
91  }
92  fixed (char* chars2 = chars)
93  {
94  return GetByteCount(chars2, chars.Length, null);
95  }
96  }
97 
108  [SecurityCritical]
109  [CLSCompliant(false)]
110  [ComVisible(false)]
111  public unsafe override int GetByteCount(char* chars, int count)
112  {
113  if (chars == null)
114  {
115  throw new ArgumentNullException("chars", Environment.GetResourceString("ArgumentNull_Array"));
116  }
117  if (count < 0)
118  {
119  throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
120  }
121  return GetByteCount(chars, count, null);
122  }
123 
142  [SecuritySafeCritical]
143  [__DynamicallyInvokable]
144  public unsafe override int GetBytes(string chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
145  {
146  if (chars == null || bytes == null)
147  {
148  throw new ArgumentNullException((chars == null) ? "chars" : "bytes", Environment.GetResourceString("ArgumentNull_Array"));
149  }
150  if (charIndex < 0 || charCount < 0)
151  {
152  throw new ArgumentOutOfRangeException((charIndex < 0) ? "charIndex" : "charCount", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
153  }
154  if (chars.Length - charIndex < charCount)
155  {
156  throw new ArgumentOutOfRangeException("chars", Environment.GetResourceString("ArgumentOutOfRange_IndexCount"));
157  }
158  if (byteIndex < 0 || byteIndex > bytes.Length)
159  {
160  throw new ArgumentOutOfRangeException("byteIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
161  }
162  int byteCount = bytes.Length - byteIndex;
163  if (bytes.Length == 0)
164  {
165  bytes = new byte[1];
166  }
167  fixed (char* ptr = chars)
168  {
169  byte[] array = bytes;
170  fixed (byte* ptr2 = array)
171  {
172  return GetBytes(ptr + charIndex, charCount, ptr2 + byteIndex, byteCount, null);
173  }
174  }
175  }
176 
195  [SecuritySafeCritical]
196  [__DynamicallyInvokable]
197  public unsafe override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
198  {
199  if (chars == null || bytes == null)
200  {
201  throw new ArgumentNullException((chars == null) ? "chars" : "bytes", Environment.GetResourceString("ArgumentNull_Array"));
202  }
203  if (charIndex < 0 || charCount < 0)
204  {
205  throw new ArgumentOutOfRangeException((charIndex < 0) ? "charIndex" : "charCount", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
206  }
207  if (chars.Length - charIndex < charCount)
208  {
209  throw new ArgumentOutOfRangeException("chars", Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer"));
210  }
211  if (byteIndex < 0 || byteIndex > bytes.Length)
212  {
213  throw new ArgumentOutOfRangeException("byteIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
214  }
215  if (chars.Length == 0)
216  {
217  return 0;
218  }
219  int byteCount = bytes.Length - byteIndex;
220  if (bytes.Length == 0)
221  {
222  bytes = new byte[1];
223  }
224  fixed (char* ptr = chars)
225  {
226  byte[] array = bytes;
227  fixed (byte* ptr2 = array)
228  {
229  return GetBytes(ptr + charIndex, charCount, ptr2 + byteIndex, byteCount, null);
230  }
231  }
232  }
233 
249  [SecurityCritical]
250  [CLSCompliant(false)]
251  [ComVisible(false)]
252  public unsafe override int GetBytes(char* chars, int charCount, byte* bytes, int byteCount)
253  {
254  if (bytes == null || chars == null)
255  {
256  throw new ArgumentNullException((bytes == null) ? "bytes" : "chars", Environment.GetResourceString("ArgumentNull_Array"));
257  }
258  if (charCount < 0 || byteCount < 0)
259  {
260  throw new ArgumentOutOfRangeException((charCount < 0) ? "charCount" : "byteCount", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
261  }
262  return GetBytes(chars, charCount, bytes, byteCount, null);
263  }
264 
277  [SecuritySafeCritical]
278  [__DynamicallyInvokable]
279  public unsafe override int GetCharCount(byte[] bytes, int index, int count)
280  {
281  if (bytes == null)
282  {
283  throw new ArgumentNullException("bytes", Environment.GetResourceString("ArgumentNull_Array"));
284  }
285  if (index < 0 || count < 0)
286  {
287  throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
288  }
289  if (bytes.Length - index < count)
290  {
291  throw new ArgumentOutOfRangeException("bytes", Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer"));
292  }
293  if (bytes.Length == 0)
294  {
295  return 0;
296  }
297  fixed (byte* ptr = bytes)
298  {
299  return GetCharCount(ptr + index, count, null);
300  }
301  }
302 
313  [SecurityCritical]
314  [CLSCompliant(false)]
315  [ComVisible(false)]
316  public unsafe override int GetCharCount(byte* bytes, int count)
317  {
318  if (bytes == null)
319  {
320  throw new ArgumentNullException("bytes", Environment.GetResourceString("ArgumentNull_Array"));
321  }
322  if (count < 0)
323  {
324  throw new ArgumentOutOfRangeException("count", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
325  }
326  return GetCharCount(bytes, count, null);
327  }
328 
347  [SecuritySafeCritical]
348  [__DynamicallyInvokable]
349  public unsafe override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
350  {
351  if (bytes == null || chars == null)
352  {
353  throw new ArgumentNullException((bytes == null) ? "bytes" : "chars", Environment.GetResourceString("ArgumentNull_Array"));
354  }
355  if (byteIndex < 0 || byteCount < 0)
356  {
357  throw new ArgumentOutOfRangeException((byteIndex < 0) ? "byteIndex" : "byteCount", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
358  }
359  if (bytes.Length - byteIndex < byteCount)
360  {
361  throw new ArgumentOutOfRangeException("bytes", Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer"));
362  }
363  if (charIndex < 0 || charIndex > chars.Length)
364  {
365  throw new ArgumentOutOfRangeException("charIndex", Environment.GetResourceString("ArgumentOutOfRange_Index"));
366  }
367  if (bytes.Length == 0)
368  {
369  return 0;
370  }
371  int charCount = chars.Length - charIndex;
372  if (chars.Length == 0)
373  {
374  chars = new char[1];
375  }
376  fixed (byte* ptr = bytes)
377  {
378  char[] array = chars;
379  fixed (char* ptr2 = array)
380  {
381  return GetChars(ptr + byteIndex, byteCount, ptr2 + charIndex, charCount, null);
382  }
383  }
384  }
385 
401  [SecurityCritical]
402  [CLSCompliant(false)]
403  [ComVisible(false)]
404  public unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int charCount)
405  {
406  if (bytes == null || chars == null)
407  {
408  throw new ArgumentNullException((bytes == null) ? "bytes" : "chars", Environment.GetResourceString("ArgumentNull_Array"));
409  }
410  if (charCount < 0 || byteCount < 0)
411  {
412  throw new ArgumentOutOfRangeException((charCount < 0) ? "charCount" : "byteCount", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
413  }
414  return GetChars(bytes, byteCount, chars, charCount, null);
415  }
416 
429  [SecuritySafeCritical]
430  [__DynamicallyInvokable]
431  public unsafe override string GetString(byte[] bytes, int byteIndex, int byteCount)
432  {
433  if (bytes == null)
434  {
435  throw new ArgumentNullException("bytes", Environment.GetResourceString("ArgumentNull_Array"));
436  }
437  if (byteIndex < 0 || byteCount < 0)
438  {
439  throw new ArgumentOutOfRangeException((byteIndex < 0) ? "byteIndex" : "byteCount", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
440  }
441  if (bytes.Length - byteIndex < byteCount)
442  {
443  throw new ArgumentOutOfRangeException("bytes", Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer"));
444  }
445  if (bytes.Length == 0)
446  {
447  return string.Empty;
448  }
449  fixed (byte* ptr = bytes)
450  {
451  return string.CreateStringFromEncoding(ptr + byteIndex, byteCount, this);
452  }
453  }
454 
455  [SecurityCritical]
456  internal unsafe override int GetByteCount(char* chars, int charCount, EncoderNLS encoder)
457  {
458  char c = '\0';
459  EncoderReplacementFallback encoderReplacementFallback = null;
460  char* ptr = chars + charCount;
461  EncoderFallbackBuffer encoderFallbackBuffer = null;
462  if (encoder != null)
463  {
464  c = encoder.charLeftOver;
465  encoderReplacementFallback = (encoder.Fallback as EncoderReplacementFallback);
466  if (encoder.InternalHasFallbackBuffer)
467  {
468  encoderFallbackBuffer = encoder.FallbackBuffer;
469  if (encoderFallbackBuffer.Remaining > 0 && encoder.m_throwOnOverflow)
470  {
471  throw new ArgumentException(Environment.GetResourceString("Argument_EncoderFallbackNotEmpty", EncodingName, encoder.Fallback.GetType()));
472  }
473  encoderFallbackBuffer.InternalInitialize(chars, ptr, encoder, setEncoder: false);
474  }
475  }
476  else
477  {
478  encoderReplacementFallback = (base.EncoderFallback as EncoderReplacementFallback);
479  }
480  if (encoderReplacementFallback != null && encoderReplacementFallback.MaxCharCount == 1)
481  {
482  if (c > '\0')
483  {
484  charCount++;
485  }
486  return charCount;
487  }
488  int num = 0;
489  if (c > '\0')
490  {
491  encoderFallbackBuffer = encoder.FallbackBuffer;
492  encoderFallbackBuffer.InternalInitialize(chars, ptr, encoder, setEncoder: false);
493  encoderFallbackBuffer.InternalFallback(c, ref chars);
494  }
495  while (true)
496  {
497  char num2 = encoderFallbackBuffer?.InternalGetNextChar() ?? '\0';
498  char c2 = num2;
499  if (num2 == '\0' && chars >= ptr)
500  {
501  break;
502  }
503  if (c2 == '\0')
504  {
505  c2 = *chars;
506  chars++;
507  }
508  if (c2 > '\u007f')
509  {
510  if (encoderFallbackBuffer == null)
511  {
512  encoderFallbackBuffer = ((encoder != null) ? encoder.FallbackBuffer : encoderFallback.CreateFallbackBuffer());
513  encoderFallbackBuffer.InternalInitialize(ptr - charCount, ptr, encoder, setEncoder: false);
514  }
515  encoderFallbackBuffer.InternalFallback(c2, ref chars);
516  }
517  else
518  {
519  num++;
520  }
521  }
522  return num;
523  }
524 
525  [SecurityCritical]
526  internal unsafe override int GetBytes(char* chars, int charCount, byte* bytes, int byteCount, EncoderNLS encoder)
527  {
528  char c = '\0';
529  EncoderReplacementFallback encoderReplacementFallback = null;
530  EncoderFallbackBuffer encoderFallbackBuffer = null;
531  char* ptr = chars + charCount;
532  byte* ptr2 = bytes;
533  char* ptr3 = chars;
534  if (encoder != null)
535  {
536  c = encoder.charLeftOver;
537  encoderReplacementFallback = (encoder.Fallback as EncoderReplacementFallback);
538  if (encoder.InternalHasFallbackBuffer)
539  {
540  encoderFallbackBuffer = encoder.FallbackBuffer;
541  if (encoderFallbackBuffer.Remaining > 0 && encoder.m_throwOnOverflow)
542  {
543  throw new ArgumentException(Environment.GetResourceString("Argument_EncoderFallbackNotEmpty", EncodingName, encoder.Fallback.GetType()));
544  }
545  encoderFallbackBuffer.InternalInitialize(ptr3, ptr, encoder, setEncoder: true);
546  }
547  }
548  else
549  {
550  encoderReplacementFallback = (base.EncoderFallback as EncoderReplacementFallback);
551  }
552  if (encoderReplacementFallback != null && encoderReplacementFallback.MaxCharCount == 1)
553  {
554  char c2 = encoderReplacementFallback.DefaultString[0];
555  if (c2 <= '\u007f')
556  {
557  if (c > '\0')
558  {
559  if (byteCount == 0)
560  {
561  ThrowBytesOverflow(encoder, nothingEncoded: true);
562  }
563  byte* intPtr = bytes;
564  bytes = intPtr + 1;
565  *intPtr = (byte)c2;
566  byteCount--;
567  }
568  if (byteCount < charCount)
569  {
570  ThrowBytesOverflow(encoder, byteCount < 1);
571  ptr = chars + byteCount;
572  }
573  while (chars < ptr)
574  {
575  char* intPtr2 = chars;
576  chars = intPtr2 + 1;
577  char c3 = *intPtr2;
578  if (c3 >= '\u0080')
579  {
580  byte* intPtr3 = bytes;
581  bytes = intPtr3 + 1;
582  *intPtr3 = (byte)c2;
583  }
584  else
585  {
586  byte* intPtr4 = bytes;
587  bytes = intPtr4 + 1;
588  *intPtr4 = (byte)c3;
589  }
590  }
591  if (encoder != null)
592  {
593  encoder.charLeftOver = '\0';
594  encoder.m_charsUsed = (int)(chars - ptr3);
595  }
596  return (int)(bytes - ptr2);
597  }
598  }
599  byte* ptr4 = bytes + byteCount;
600  if (c > '\0')
601  {
602  encoderFallbackBuffer = encoder.FallbackBuffer;
603  encoderFallbackBuffer.InternalInitialize(chars, ptr, encoder, setEncoder: true);
604  encoderFallbackBuffer.InternalFallback(c, ref chars);
605  }
606  while (true)
607  {
608  char num = encoderFallbackBuffer?.InternalGetNextChar() ?? '\0';
609  char c4 = num;
610  if (num == '\0' && chars >= ptr)
611  {
612  break;
613  }
614  if (c4 == '\0')
615  {
616  c4 = *chars;
617  chars++;
618  }
619  if (c4 > '\u007f')
620  {
621  if (encoderFallbackBuffer == null)
622  {
623  encoderFallbackBuffer = ((encoder != null) ? encoder.FallbackBuffer : encoderFallback.CreateFallbackBuffer());
624  encoderFallbackBuffer.InternalInitialize(ptr - charCount, ptr, encoder, setEncoder: true);
625  }
626  encoderFallbackBuffer.InternalFallback(c4, ref chars);
627  continue;
628  }
629  if (bytes >= ptr4)
630  {
631  if (encoderFallbackBuffer == null || !encoderFallbackBuffer.bFallingBack)
632  {
633  chars--;
634  }
635  else
636  {
637  encoderFallbackBuffer.MovePrevious();
638  }
639  ThrowBytesOverflow(encoder, bytes == ptr2);
640  break;
641  }
642  *bytes = (byte)c4;
643  bytes++;
644  }
645  if (encoder != null)
646  {
647  if (encoderFallbackBuffer != null && !encoderFallbackBuffer.bUsedEncoder)
648  {
649  encoder.charLeftOver = '\0';
650  }
651  encoder.m_charsUsed = (int)(chars - ptr3);
652  }
653  return (int)(bytes - ptr2);
654  }
655 
656  [SecurityCritical]
657  internal unsafe override int GetCharCount(byte* bytes, int count, DecoderNLS decoder)
658  {
659  DecoderReplacementFallback decoderReplacementFallback = null;
660  decoderReplacementFallback = ((decoder != null) ? (decoder.Fallback as DecoderReplacementFallback) : (base.DecoderFallback as DecoderReplacementFallback));
661  if (decoderReplacementFallback != null && decoderReplacementFallback.MaxCharCount == 1)
662  {
663  return count;
664  }
665  DecoderFallbackBuffer decoderFallbackBuffer = null;
666  int num = count;
667  byte[] array = new byte[1];
668  byte* ptr = bytes + count;
669  while (bytes < ptr)
670  {
671  byte b = *bytes;
672  bytes++;
673  if (b >= 128)
674  {
675  if (decoderFallbackBuffer == null)
676  {
677  decoderFallbackBuffer = ((decoder != null) ? decoder.FallbackBuffer : base.DecoderFallback.CreateFallbackBuffer());
678  decoderFallbackBuffer.InternalInitialize(ptr - count, null);
679  }
680  array[0] = b;
681  num--;
682  num += decoderFallbackBuffer.InternalFallback(array, bytes);
683  }
684  }
685  return num;
686  }
687 
688  [SecurityCritical]
689  internal unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int charCount, DecoderNLS decoder)
690  {
691  byte* ptr = bytes + byteCount;
692  byte* ptr2 = bytes;
693  char* ptr3 = chars;
694  DecoderReplacementFallback decoderReplacementFallback = null;
695  decoderReplacementFallback = ((decoder != null) ? (decoder.Fallback as DecoderReplacementFallback) : (base.DecoderFallback as DecoderReplacementFallback));
696  if (decoderReplacementFallback != null && decoderReplacementFallback.MaxCharCount == 1)
697  {
698  char c = decoderReplacementFallback.DefaultString[0];
699  if (charCount < byteCount)
700  {
701  ThrowCharsOverflow(decoder, charCount < 1);
702  ptr = bytes + charCount;
703  }
704  while (bytes < ptr)
705  {
706  byte* intPtr = bytes;
707  bytes = intPtr + 1;
708  byte b = *intPtr;
709  if (b >= 128)
710  {
711  char* intPtr2 = chars;
712  chars = intPtr2 + 1;
713  *intPtr2 = c;
714  }
715  else
716  {
717  char* intPtr3 = chars;
718  chars = intPtr3 + 1;
719  *intPtr3 = (char)b;
720  }
721  }
722  if (decoder != null)
723  {
724  decoder.m_bytesUsed = (int)(bytes - ptr2);
725  }
726  return (int)(chars - ptr3);
727  }
728  DecoderFallbackBuffer decoderFallbackBuffer = null;
729  byte[] array = new byte[1];
730  char* ptr4 = chars + charCount;
731  while (bytes < ptr)
732  {
733  byte b2 = *bytes;
734  bytes++;
735  if (b2 >= 128)
736  {
737  if (decoderFallbackBuffer == null)
738  {
739  decoderFallbackBuffer = ((decoder != null) ? decoder.FallbackBuffer : base.DecoderFallback.CreateFallbackBuffer());
740  decoderFallbackBuffer.InternalInitialize(ptr - byteCount, ptr4);
741  }
742  array[0] = b2;
743  if (!decoderFallbackBuffer.InternalFallback(array, bytes, ref chars))
744  {
745  bytes--;
746  decoderFallbackBuffer.InternalReset();
747  ThrowCharsOverflow(decoder, chars == ptr3);
748  break;
749  }
750  }
751  else
752  {
753  if (chars >= ptr4)
754  {
755  bytes--;
756  ThrowCharsOverflow(decoder, chars == ptr3);
757  break;
758  }
759  *chars = (char)b2;
760  chars++;
761  }
762  }
763  if (decoder != null)
764  {
765  decoder.m_bytesUsed = (int)(bytes - ptr2);
766  }
767  return (int)(chars - ptr3);
768  }
769 
775  [__DynamicallyInvokable]
776  public override int GetMaxByteCount(int charCount)
777  {
778  if (charCount < 0)
779  {
780  throw new ArgumentOutOfRangeException("charCount", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
781  }
782  long num = (long)charCount + 1L;
783  if (base.EncoderFallback.MaxCharCount > 1)
784  {
785  num *= base.EncoderFallback.MaxCharCount;
786  }
787  if (num > int.MaxValue)
788  {
789  throw new ArgumentOutOfRangeException("charCount", Environment.GetResourceString("ArgumentOutOfRange_GetByteCountOverflow"));
790  }
791  return (int)num;
792  }
793 
799  [__DynamicallyInvokable]
800  public override int GetMaxCharCount(int byteCount)
801  {
802  if (byteCount < 0)
803  {
804  throw new ArgumentOutOfRangeException("byteCount", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"));
805  }
806  long num = byteCount;
807  if (base.DecoderFallback.MaxCharCount > 1)
808  {
809  num *= base.DecoderFallback.MaxCharCount;
810  }
811  if (num > int.MaxValue)
812  {
813  throw new ArgumentOutOfRangeException("byteCount", Environment.GetResourceString("ArgumentOutOfRange_GetCharCountOverflow"));
814  }
815  return (int)num;
816  }
817 
820  [ComVisible(false)]
821  [__DynamicallyInvokable]
822  public override Decoder GetDecoder()
823  {
824  return new DecoderNLS(this);
825  }
826 
829  [ComVisible(false)]
830  [__DynamicallyInvokable]
831  public override Encoder GetEncoder()
832  {
833  return new EncoderNLS(this);
834  }
835  }
836 }
static EncoderFallback ReplacementFallback
Gets an object that outputs a substitute string in place of an input character that cannot be encoded...
override int GetMaxByteCount(int charCount)
Calculates the maximum number of bytes produced by encoding the specified number of characters.
Represents a character encoding.To browse the .NET Framework source code for this type,...
Definition: Encoding.cs:15
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
unsafe override int GetByteCount(string chars)
Calculates the number of bytes produced by encoding the characters in the specified T:System....
override Encoder GetEncoder()
Obtains an encoder that converts a sequence of Unicode characters into an ASCII encoded sequence of b...
Converts a set of characters into a sequence of bytes.
Definition: Encoder.cs:11
unsafe override int GetByteCount(char *chars, int count)
Calculates the number of bytes produced by encoding a set of characters starting at the specified cha...
override int GetMaxCharCount(int byteCount)
Calculates the maximum number of characters produced by decoding the specified number of bytes.
Definition: __Canon.cs:3
The exception that is thrown when the value of an argument is outside the allowable range of values a...
abstract int Remaining
When overridden in a derived class, gets the number of characters in the current T:System....
unsafe override int GetBytes(string chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
Encodes a set of characters from the specified T:System.String into the specified byte array.
unsafe override int GetCharCount(byte *bytes, int count)
Calculates the number of characters produced by decoding a sequence of bytes starting at the specifie...
Provides a failure-handling mechanism, called a fallback, for an input character that cannot be conve...
unsafe override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
Decodes a sequence of bytes from the specified byte array into the specified character array.
static DecoderFallback ReplacementFallback
Gets an object that outputs a substitute string in place of an input byte sequence that cannot be dec...
unsafe override string GetString(byte[] bytes, int byteIndex, int byteCount)
Decodes a range of bytes from a byte array into a string.
Provides a failure handling mechanism, called a fallback, for an input character that cannot be conve...
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
Converts a sequence of encoded bytes into a set of characters.
Definition: Decoder.cs:11
virtual string EncodingName
When overridden in a derived class, gets the human-readable description of the current encoding.
Definition: Encoding.cs:724
Provides a failure-handling mechanism, called a fallback, for an encoded input byte sequence that can...
unsafe override int GetBytes(char *chars, int charCount, byte *bytes, int byteCount)
Encodes a set of characters starting at the specified character pointer into a sequence of bytes that...
Represents an ASCII character encoding of Unicode characters.
override bool IsSingleByte
Gets a value indicating whether the current encoding uses single-byte code points.
override Decoder GetDecoder()
Obtains a decoder that converts an ASCII encoded sequence of bytes into a sequence of Unicode charact...
The exception that is thrown when one of the arguments provided to a method is not valid.
unsafe override int GetChars(byte *bytes, int byteCount, char *chars, int charCount)
Decodes a sequence of bytes starting at the specified byte pointer into a set of characters that are ...
unsafe override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
Encodes a set of characters from the specified character array into the specified byte array.
override int MaxCharCount
Gets the number of characters in the replacement string for the T:System.Text.EncoderReplacementFallb...
Provides a buffer that allows a fallback handler to return an alternate string to an encoder when it ...
unsafe override int GetCharCount(byte[] bytes, int index, int count)
Calculates the number of characters produced by decoding a sequence of bytes from the specified byte ...
unsafe override int GetByteCount(char[] chars, int index, int count)
Calculates the number of bytes produced by encoding a set of characters from the specified character ...
ASCIIEncoding()
Initializes a new instance of the T:System.Text.ASCIIEncoding class.