Help us shape the future of Go! Take the 2026 Go Developer Survey

dataurl

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package dataurl encodes resources as data URLs, choosing the representation that compresses best for SVG and base64 for everything else.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(uri string) (contents []byte, kind string, err error)

Decode returns the payload and media type of a data URL. A fragment, which references a part of the resource, is ignored.

func Encode

func Encode(contents []byte, kind string) (uri, encoding string)

Encode returns a data URL for contents of media type kind and the encoding used: "percent" (lossless SVG text) or "base64".

func SVG

func SVG(contents []byte) string

SVG encodes bytes, not XML: decoding must recover the original file byte-for-byte, including Unicode/encoding declarations, whitespace, IDs and fragment refs. This alphabet survives HTML attributes, srcset, either JS/CSS string delimiter and unquoted CSS url(). In particular %, #, comma, &, quotes and backslashes must never become ambiguous payload, markup, escapes or URL fragments.

Types

This section is empty.

Jump to

Keyboard shortcuts

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