[Vala] string <-> bytes conversion in Vala



Hi,

I manipulate with strings in my application such as storing/reading
to/from binary files. And I need to convert a string to/from array of
bytes. What is the best way of doing it in Vala?

Looking into string class http://valadoc.org/glib-2.0/string.html I
see a method called string#to_utf8() that converts string to array of
chars. But I cannot find any other methods.

So I have 2 questions:
 - How to convert a string to array of chars in encoding different
from UTF8. Something like this one
http://download.oracle.com/javase/6/docs/api/java/lang/String.html#getBytes(java.nio.charset.Charset)
 - How to convert array of chars/uint8 back to string? Like this one
http://download.oracle.com/javase/6/docs/api/java/lang/String.html#String(byte[],
java.nio.charset.Charset)



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