encoding

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package encoding provides Memegen text encoding and decoding.

Memegen URLs encode special characters in meme text using a set of replacement rules. The encoding order is critical: underscores and dashes must be escaped BEFORE spaces are converted to underscores.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(text string) string

Decode converts Memegen URL format back to user text.

This reverses Encode by processing replacements in the opposite order:

  1. Restore tilde-encoded specials and double-quote sequences.
  2. Restore underscores (double underscore = literal, single = space).
  3. Restore dashes (double dash = literal dash).

func Encode

func Encode(text string) string

Encode converts user text to Memegen URL-safe format.

The replacement order matters:

  1. Escape literal underscores (_) and dashes (-) by doubling them.
  2. Convert spaces to underscores.
  3. Replace remaining special characters with tilde or quote sequences.

func NormalizeQuotes

func NormalizeQuotes(text string) string

NormalizeQuotes replaces common Unicode smart quotes and dashes with their ASCII equivalents so that user input from rich-text editors encodes correctly.

Types

This section is empty.

Jump to

Keyboard shortcuts

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