Fix: Trim improperly parsed characters from memos.
This commit is contained in:
parent
f314bdc78b
commit
94f942136b
|
@ -23,21 +23,9 @@ val INCLUDE_MEMO_PREFIXES_RECOGNIZED = arrayOf(
|
|||
inline fun ByteArray?.toUtf8Memo(): String {
|
||||
// TODO: make this more official but for now, this will do
|
||||
return if (this == null || this[0] >= 0xF5) "" else try {
|
||||
String(this, StandardCharsets.UTF_8).trim('\u0000')
|
||||
// trim empty and "replacement characters" for codes that can't be represented in unicode
|
||||
String(this, StandardCharsets.UTF_8).trim('\u0000', '\uFFFD')
|
||||
} catch (t: Throwable) {
|
||||
"unable to parse memo"
|
||||
"Unable to parse memo."
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if self.0[0] < 0xF5 {
|
||||
// Check if it is valid UTF8
|
||||
Some(str::from_utf8(&self.0).map(|memo| {
|
||||
// Drop trailing zeroes
|
||||
memo.trim_end_matches(char::from(0)).to_owned()
|
||||
}))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
*/
|
||||
}
|
Loading…
Reference in New Issue