EncodingInfo.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. using System;
  5. using System.Text;
  6. namespace System.Text
  7. {
  8. public sealed class EncodingInfo
  9. {
  10. private int iCodePage; // Code Page #
  11. private string strEncodingName; // Short name (web name)
  12. private string strDisplayName; // Full localized name
  13. internal EncodingInfo(int codePage, string name, string displayName)
  14. {
  15. iCodePage = codePage;
  16. strEncodingName = name;
  17. strDisplayName = displayName;
  18. }
  19. public int CodePage
  20. {
  21. get
  22. {
  23. return iCodePage;
  24. }
  25. }
  26. public string Name
  27. {
  28. get
  29. {
  30. return strEncodingName;
  31. }
  32. }
  33. public string DisplayName
  34. {
  35. get
  36. {
  37. return strDisplayName;
  38. }
  39. }
  40. public Encoding GetEncoding()
  41. {
  42. return Encoding.GetEncoding(iCodePage);
  43. }
  44. public override bool Equals(object value)
  45. {
  46. EncodingInfo that = value as EncodingInfo;
  47. if (that != null)
  48. {
  49. return (this.CodePage == that.CodePage);
  50. }
  51. return (false);
  52. }
  53. public override int GetHashCode()
  54. {
  55. return this.CodePage;
  56. }
  57. }
  58. }