[Vala] about string type and IOChannel



Hi all~
I looked into glib-2.0.vala and noticed that IOChannel use string as byte buffer to read data from channel.
But I don't kown how to make a string with enough size(maybe 10K) to call read_chars().

                IOChannel ocr = new IOChannel.file("testfile", "r");
               
                string rbuf; ---------  wrong!, rbuf is null
                or  string rbuf="buffer malloced by hand"     -----  it's really not nice

                ocr.read_chars(rbuf, 100, ret);
                ocr.shutdown(false);

I think using char[] to wrap g_io_channel_read and other functions which use binary data as parameter is more reasonable.
Using string as a binary buffer is not a best choice.

Another question :
Dose strings in Vala always be UTF-8 string?

Thanks!


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]