Skip to content

Commit

Permalink
- remove language code from nfc record parsing; (eu-digital-green-cer…
Browse files Browse the repository at this point in the history
  • Loading branch information
MykhailoNester authored Sep 27, 2021
1 parent b8fab97 commit 3fc0931
Showing 1 changed file with 1 addition and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,14 @@ fun NdefRecord.parse(): ParsedNdefRecord? {
* The text is encoded in UTF16
*
* Bit_6 is reserved for future use and must be set to zero.
*
* Bits 5 to 0 are the length of the IANA language code.
*/
val textEncoding = if (recordPayload[0] and 128.toByte() == 0.toByte()) {
Charsets.UTF_8
} else {
Charsets.UTF_16
}

val languageCodeLength: Int = (recordPayload[0] and 63.toByte()).toInt()
val text = String(
recordPayload, languageCodeLength + 1,
recordPayload.size - languageCodeLength - 1, textEncoding
)
val text = String(recordPayload, textEncoding)
return TextRecord(text)
} catch (e: UnsupportedEncodingException) {
Timber.w("We got a malformed tag.")
Expand Down

0 comments on commit 3fc0931

Please sign in to comment.