The NDEF URI Record is a well-known record type defined by the NFC Forum. It
carries a, potentially abbreviated, UTF-8 encoded Internationalized Resource
Identifier (IRI) as defined by RFC 3987. Abbreviation covers certain prefix
patterns that are compactly encoded as a single octet and automatically expanded
when decoding. The
UriRecord class provides both access attributes for decoded
IRI as well as a converted URI (if a netloc part is present in the IRI).
UriRecordclass decodes or encodes an NDEF URI Record. The
UriRecord.iriattribute holds the expanded (if a valid abbreviation code was decoded) internationalized resource identifier (IRI). The
UriRecord.uriattribute is a converted version of the IRI. Conversion is applied only for IRI’s that split with a netloc component. A converted URI contains only ASCII characters with an IDNA encoded netloc component and percent-encoded path, query and fragment components.
Parameters: iri (str) – initial value for the
iriattribute, default ‘’
The URI Record type is
The decoded or set internationalized resource identifier, expanded if an abbreviation code was used in the record payload.
>>> import ndef >>> record = ndef.UriRecord("http://www.hääyö.com/~user/") >>> record.iri 'http://www.hääyö.com/~user/' >>> record.uri 'http://www.xn--hy-viaa5g.com/~user/' >>> record = ndef.UriRecord("http://www.example.com") >>> b''.join(ndef.message_encoder([record])) b'\xd1\x01\x0cU\x01example.com'