Text Record¶
The NDEF Text Record is a well-known record type defined by the NFC Forum. It carries a UTF-8 or UTF-16 encoded text string with an associated IANA language code identifier.
-
class
ndef.
TextRecord
(text='', language='en', encoding='UTF-8')¶ A
TextRecord
is initialized with the actual text content, an ISO/IANA language identifier, and the desired transfer encoding UTF-8 or UTF-16. Default values are empty text, language code ‘en’, and ‘UTF-8’ encoding.Parameters: -
type
¶ The Text Record type is
urn:nfc:wkt:T
.
-
text
¶ The decoded or set text string value.
-
language
¶ The decoded or set IANA language code identifier.
-
encoding
¶ The transfer encoding of the text string. Either ‘UTF-8’ or ‘UTF-16’.
>>> import ndef >>> record = ndef.TextRecord("Hallo Welt", "de") >>> octets = b''.join(ndef.message_encoder([record])) >>> print(list(ndef.message_decoder(octets))[0]) NDEF Text Record ID '' Text 'Hallo Welt' Language 'de' Encoding 'UTF-8'
-