UTF8Encoding.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // System.Text.UTF8Encoding.cs
  3. //
  4. // Author:
  5. // Sean MacIsaac ([email protected])
  6. //
  7. // (C) Ximian, Inc. http://www.ximian.com
  8. //
  9. namespace System.Text {
  10. public class UTF8Encoding : Encoding {
  11. public override int GetByteCount(char[] chars, int index, int count) {
  12. // FIXME
  13. return 0;
  14. }
  15. public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) {
  16. if (chars == null || bytes == null)
  17. throw new ArgumentNullException ();
  18. if (charIndex < 0 || charCount < 0 || byteIndex < 0 ||
  19. charIndex + charCount > chars.Length ||
  20. byteIndex + charCount > bytes.Length)
  21. throw new ArgumentOutOfRangeException ();
  22. // fixme: do realy unicode conversion
  23. for (int i = 0; i < charCount; i++) {
  24. bytes [byteIndex + i] = (byte)chars [charIndex + i];
  25. }
  26. return charCount;
  27. }
  28. public override char[] GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) {
  29. // FIXME
  30. return null;
  31. }
  32. public override int GetMaxByteCount(int charCount) {
  33. return charCount*3;
  34. }
  35. public override int GetMaxCharCount(int byteCount) {
  36. return byteCount;
  37. }
  38. }
  39. }