summaryrefslogtreecommitdiffstats
path: root/src/Util.vala
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2010-07-09 08:53:03 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2010-07-09 08:53:03 +0200
commit46c0f539112cd19628dc0305d3556111099a04da (patch)
treebe76abc7b3b402c635d09da39bbcdd6bdd750124 /src/Util.vala
parent1b2562ed6503f3bb7c19514b5e9571c1fcb79360 (diff)
downloadeva-46c0f539112cd19628dc0305d3556111099a04da.tar
eva-46c0f539112cd19628dc0305d3556111099a04da.zip
Fixed unicode handling
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;
+ }
+}