aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/utils.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/utils.scala')
-rw-r--r--src/main/scala/utils.scala9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main/scala/utils.scala b/src/main/scala/utils.scala
new file mode 100644
index 0000000..f230be7
--- /dev/null
+++ b/src/main/scala/utils.scala
@@ -0,0 +1,9 @@
+package o1game.utils
+
+/** Converts this string to an array of bytes (probably for transmission).
+ *
+ * @param str the string to convert
+ * @return an array of bytes representing the string in UTF8.
+ */
+def stringToByteArray(str: String): Array[Byte] =
+ str.toVector.map(_.toByte).toArray