--- a/src/Pure/General/bytes.scala Wed Jul 29 15:52:57 2015 +0200
+++ b/src/Pure/General/bytes.scala Thu Jul 30 11:32:58 2015 +0200
@@ -59,7 +59,7 @@
final class Bytes private(
protected val bytes: Array[Byte],
protected val offset: Int,
- val length: Int)
+ val length: Int) extends CharSequence
{
/* equality */
@@ -107,6 +107,19 @@
}
+ /* CharSequence operations */
+
+ def charAt(i: Int): Char =
+ if (0 <= i && i < length) (bytes(offset + i).asInstanceOf[Int] & 0xFF).asInstanceOf[Char]
+ else throw new IndexOutOfBoundsException
+
+ def subSequence(i: Int, j: Int): Bytes =
+ {
+ if (0 <= i && i <= j && j <= length) new Bytes(bytes, offset + i, j - i)
+ else throw new IndexOutOfBoundsException
+ }
+
+
/* write */
def write(stream: OutputStream): Unit = stream.write(bytes, offset, length)