EncodingInfo.cs 1016 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. namespace System.Text
  5. {
  6. public sealed class EncodingInfo
  7. {
  8. internal EncodingInfo(int codePage, string name, string displayName)
  9. {
  10. CodePage = codePage;
  11. Name = name;
  12. DisplayName = displayName;
  13. }
  14. public int CodePage { get; }
  15. public string Name { get; }
  16. public string DisplayName { get; }
  17. public Encoding GetEncoding()
  18. {
  19. return Encoding.GetEncoding(CodePage);
  20. }
  21. public override bool Equals(object value)
  22. {
  23. if (value is EncodingInfo that)
  24. {
  25. return this.CodePage == that.CodePage;
  26. }
  27. return false;
  28. }
  29. public override int GetHashCode()
  30. {
  31. return CodePage;
  32. }
  33. }
  34. }