From e8542816277c0f78a17afcd4eed756337df9cd70 Mon Sep 17 00:00:00 2001 From: Stefanos Mandalas Date: Sun, 14 Nov 2021 16:09:07 +0200 Subject: [PATCH] fixed translation of negative bytes --- .../scala/io/kaitai/struct/translators/NimTranslator.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shared/src/main/scala/io/kaitai/struct/translators/NimTranslator.scala b/shared/src/main/scala/io/kaitai/struct/translators/NimTranslator.scala index 95f400b52..0234e4e90 100644 --- a/shared/src/main/scala/io/kaitai/struct/translators/NimTranslator.scala +++ b/shared/src/main/scala/io/kaitai/struct/translators/NimTranslator.scala @@ -100,7 +100,10 @@ class NimTranslator(provider: TypeProvider, importList: ImportList) extends Base if (arr.size == 0) s"@[]" else - "@[" + arr.mkString("'u8, ") + "'u8]" + "@[" + arr.map(b => { + val ub: Int = b & 0xff + ub + }).mkString("'u8, ") + "'u8]" } override def doByteArrayNonLiteral(elts: Seq[expr]): String = s"@[${elts.map(translate).mkString(", ")}]"