contentline

package
v1.1.12 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package contentline reads and writes the content lines of vCard and iCalendar, which have the same rules: a property's name, its parameters, and its value, folded so no line is more than 75 octets, with the characters of text values escaped. Reference: https://www.rfc-editor.org/rfc/rfc6350#section-3.2

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Escape

func Escape(value string) string

Escape escapes a text value, whose backslashes, commas, semicolons and line breaks must be escaped

func Split

func Split(value string, separator rune) []string

Split returns the parts of a value, which are separated with the separator where it isn't escaped, such as the semicolons between the components of a structured value, or the commas of a list, unescaped

func Unescape

func Unescape(value string) string

Unescape unescapes a text value, whose backslashes, commas, semicolons and line breaks are escaped

func Unfold

func Unfold(r io.Reader, size int, fn func(string) error) error

Unfold calls the function with each content line, unfolded (see Reader.Next). Lines are at most the size, and the function's error stops reading.

Types

type Property

type Property struct {
	Group  string
	Name   string
	Params map[string][]string
	Value  string
}

Property is a content line, which is a property's group, such as item1, its name, in upper case, such as EMAIL, its parameters, by their names in upper case, such as TYPE, and its value, which is still escaped

func Parse

func Parse(line string) (Property, bool)

Parse returns the property of a content line, or false when it isn't one. The value starts after the first colon which isn't in a quoted parameter. A parameter without a name, such as HOME in vCard 2.1's TEL;HOME, is a TYPE, and a parameter's values are split at commas which aren't quoted.

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader reads content lines, unfolded

func NewReader

func NewReader(r io.Reader, size int) *Reader

NewReader returns a reader of content lines from r, which are at most the size, once they're unfolded

func (*Reader) Next

func (r *Reader) Next() (string, error)

Next returns the next content line, unfolded, as a line which continues on the next starts with a space or tab, which is removed, or io.EOF when there are no more. Lines which are empty aren't returned, and a byte order mark which the first line starts with is removed.

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer writes content lines, each ending with CRLF, and folded so no line is more than 75 octets

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter returns a writer of content lines to w

func (*Writer) Err

func (w *Writer) Err() error

Err returns the first error of a write

func (*Writer) Write

func (w *Writer) Write(name string, params []string, value string) error

Write writes a property, with its parameters, such as TYPE=home, and its value, which must be escaped, folded, and returns the first error of a write, so the lines can be written and the error checked once

Jump to

Keyboard shortcuts

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