text

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2020 License: LGPL-3.0 Imports: 3 Imported by: 1

Documentation

Overview

Package text provides support for NDEF Payloads of Text type. It follows the NFC Forum Text Record Type Definition specification (NFCForum-TS-RTD_Text_1.0).

The Payload type implements the RecordPayload interface from ndef, so it can be used as ndef.Record.Payload.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Payload

type Payload struct {
	Language string
	Text     string
}

Payload represents a NDEF Record Payload of type "T", which holds a text field and IANA-formatted language information.

func New

func New(text, language string) *Payload

New returns a pointer to a Payload.

The language parameter must be compliant to RFC 3066 (i.e. "en_US"), but no check is performed.

func (*Payload) Len

func (t *Payload) Len() int

Len is the length of the byte slice resulting of Marshaling..

func (*Payload) Marshal

func (t *Payload) Marshal() []byte

Marshal returns the bytes representing the payload of a text Record.

func (*Payload) String

func (t *Payload) String() string

String returns the actual text. Language information is ommited.

func (*Payload) Type

func (t *Payload) Type() string

Type returns the URN for Text types.

func (*Payload) Unmarshal

func (t *Payload) Unmarshal(buf []byte)

Unmarshal parses the Payload from a text Record.

Notes

Bugs

  • The implementation ignores the guidelines about displaying the text and removing the control characters.

  • UTF-16 with different byte order, with/without BOM is not tested.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL