Re: [Vala] Is it possible to do a reading buffer offset in vala?
- From: JM <interflug1 gmx net>
- To: Jiří Zárevúcky <zarevucky jiri gmail com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] Is it possible to do a reading buffer offset in vala?
- Date: Tue, 09 Feb 2010 18:52:36 +0100
Hello Jiří
Thanks! It works fine with pointers. just like in C. I just there was a
possibility to avoid them in vala because I have to manage them
manually.
But it's also fine this way.
Another question:
Is there some trick to cast the read data back to utf-8? Otherwise the
content of the file is unreadable in some parts (For example if I write
your name to the file :) )?
Regards
Jörn
Am Dienstag, den 09.02.2010, 16:06 +0100 schrieb Jiří Zárevúcky:
JM píše v Út 09. 02. 2010 v 10:36 +0100:
Hi all
I have a little problem on working with buffer offsets in vala.
In C doing an offset for a "char buf[SOME_SIZE];" is easy, but I have
difficulties doing it in vala.
You can simply use the same way you would in C. Cast your buffer to a
pointer and do pointer arithmetic with it.
Simple example:
void main ()
{
char[] testbuffer = new char [8] { 0, 1, 2, 3, 4, 5, 6, 7 };
char* testbufferoffset = ((char*)testbuffer) + 5;
assert (testbufferoffset[0] == 5);
testbufferoffset[1] = 25;
assert (testbuffer[6] == 25);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]