summaryrefslogtreecommitdiffstats
path: root/src/Util.vala
diff options
context:
space:
mode:
Diffstat (limited to 'src/Util.vala')
-rw-r--r--src/Util.vala45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/Util.vala b/src/Util.vala
new file mode 100644
index 0000000..3666f96
--- /dev/null
+++ b/src/Util.vala
@@ -0,0 +1,45 @@
+namespace Eva {
+ private string array_to_string(uchar* array, ulong len) {
+ string ret = "";
+
+ for(ulong i = 0; i < len; ++i) {
+ if(array[i] == 0)
+ break;
+
+ string buf = string.nfill(6, 0);
+ ((unichar)array[i]).to_utf8(buf);
+
+ ret += buf;
+ }
+
+ return ret;
+ }
+
+ private char[]? string_to_array(string str) {
+ char[] ret = new char[str.len()];
+ int index = 0;
+
+ for(unowned string rest = str; rest.length > 0; rest = rest.next_char()) {
+ unichar c = rest.get_char();
+
+ if(c > 255)
+ return null;
+
+ ret[index++] = (char)c;
+ }
+
+ return ret;
+ }
+
+ private List string_to_list(string str) {
+ List ret = new List();
+
+ for(unowned string rest = str; rest.length > 0; rest = rest.next_char()) {
+ unichar c = rest.get_char();
+
+ ret.list.add(new UInt(c));
+ }
+
+ return ret;
+ }
+}