0
0
mirror of https://github.com/markusfisch/BinaryEye.git synced 2024-09-19 19:42:18 +02:00

Treat LF/CR/Tab as printable characters

When encoding "something\nlike\tthüs". This string should be encoded
as text rather than binary, of course.
This commit is contained in:
Markus Fisch 2024-05-08 19:49:19 +02:00
parent 4758c2d337
commit c2071d8d81

View File

@ -288,9 +288,11 @@ class EncodeFragment : Fragment() {
toast(e.message ?: "Invalid escape sequence") toast(e.message ?: "Invalid escape sequence")
return null return null
} }
// Convert to a ByteArray if there were escape sequences // Return a ByteArray if there were escape sequences for
// for non-printable characters. // non-printable characters (like `\0`). This means the content
if (text.any { it.code < 32 }) { // will be encoded in binary mode, what would be wrong for
// "something\nlike\tthüs".
if (text.any { it.code < 32 && it.code !in setOf(9, 10, 13) }) {
return text.toByteArray() return text.toByteArray()
} }
} }