diff --git a/shared/src/main/scala/io/kaitai/struct/languages/RubyCompiler.scala b/shared/src/main/scala/io/kaitai/struct/languages/RubyCompiler.scala index 89cc7e2f8..9e396d11b 100644 --- a/shared/src/main/scala/io/kaitai/struct/languages/RubyCompiler.scala +++ b/shared/src/main/scala/io/kaitai/struct/languages/RubyCompiler.scala @@ -365,8 +365,12 @@ class RubyCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig) case _: BytesEosType => s"$io.read_bytes_full" case BytesTerminatedType(terminator, include, consume, eosError, _) => - val term = terminator.head & 0xff - s"$io.read_bytes_term($term, $include, $consume, $eosError)" + if (terminator.length == 1) { + val term = terminator.head & 0xff + s"$io.read_bytes_term($term, $include, $consume, $eosError)" + } else { + s"$io.read_bytes_term_multi(${translator.doByteArrayLiteral(terminator)}, $include, $consume, $eosError)" + } case BitsType1(bitEndian) => s"$io.read_bits_int_${bitEndian.toSuffix}(1) != 0" case BitsType(width: Int, bitEndian) => @@ -404,8 +408,12 @@ class RubyCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig) } val expr2 = terminator match { case Some(term) => - val t = term.head & 0xff - s"$kstreamName::bytes_terminate($expr1, $t, $include)" + if (term.length == 1) { + val t = term.head & 0xff + s"$kstreamName::bytes_terminate($expr1, $t, $include)" + } else { + s"$kstreamName::bytes_terminate_multi($expr1, ${translator.doByteArrayLiteral(term)}, $include)" + } case None => expr1 } expr2