Beispiel #1
0
        public static Buf toBuf(string self, Charset charset)
        {
            MemBuf buf = new MemBuf(self.Length * 2);

            buf.charset(charset);
            buf.print(self);
            return(buf.flip());
        }
Beispiel #2
0
        public Buf dup()
        {
            int size = (int)this.size();

            byte[] copy = new byte[size];
            getBytes(0, copy, 0, size);

            Buf result = new MemBuf(copy, size);

            result.charset(charset());
            return(result);
        }
Beispiel #3
0
        public Buf getRange(Range range)
        {
            long size = getSize();
            long s    = range.start(size);
            long e    = range.end(size);
            int  n    = (int)(e - s + 1);

            if (n < 0)
            {
                throw IndexErr.make(range).val;
            }

            byte[] slice = new byte[n];
            getBytes(s, slice, 0, n);

            Buf result = new MemBuf(slice, n);

            result.charset(charset());
            return(result);
        }
Beispiel #4
0
        public Buf getRange(Range range)
        {
            long size = getSize();
              long s = range.start(size);
              long e = range.end(size);
              int n = (int)(e - s + 1);
              if (n < 0) throw IndexErr.make(range).val;

              byte[] slice = new byte[n];
              getBytes(s, slice, 0, n);

              Buf result = new MemBuf(slice, n);
              result.charset(charset());
              return result;
        }
Beispiel #5
0
        public Buf dup()
        {
            int size = (int)this.size();
              byte[] copy = new byte[size];
              getBytes(0, copy, 0, size);

              Buf result = new MemBuf(copy, size);
              result.charset(charset());
              return result;
        }
Beispiel #6
0
 public static Buf toBuf(string self, Charset charset)
 {
     MemBuf buf = new MemBuf(self.Length*2);
       buf.charset(charset);
       buf.print(self);
       return buf.flip();
 }