rclone: github.com/ncw/rclone/lib/encoder Index | Files

package encoder

import "github.com/ncw/rclone/lib/encoder"

Index

Package Files

encoder.go

Constants

const (

    // QuoteRune is the rune used for quoting reserved characters
    QuoteRune = '‛' // SINGLE HIGH-REVERSED-9 QUOTATION MARK
    // EncodeStandard contains the flags used for the Standard Encoder
    EncodeStandard = EncodeZero | EncodeSlash | EncodeCtl | EncodeDel
    // Standard defines the encoding that is used for paths in- and output by rclone.
    //
    // List of replaced characters:
    //     (0x00)  -> '␀' // SYMBOL FOR NULL
    //   / (slash) -> '/' // FULLWIDTH SOLIDUS
    Standard = MultiEncoder(EncodeStandard)
)
const (
    EncodeZero        uint = 0         // NUL(0x00)
    EncodeSlash       uint = 1 << iota // /
    EncodeWin                          // :?"*<>|
    EncodeBackSlash                    // \
    EncodeHashPercent                  // #%
    EncodeDel                          // DEL(0x7F)
    EncodeCtl                          // CTRL(0x01-0x1F)
    EncodeLeftSpace                    // Leading SPACE
    EncodeLeftTilde                    // Leading ~
    EncodeRightSpace                   // Trailing SPACE
    EncodeRightPeriod                  // Trailing .
    EncodeInvalidUtf8                  // Invalid UTF-8 bytes
)

Possible flags for the MultiEncoder

func FromStandardName Uses

func FromStandardName(e Encoder, s string) string

FromStandardName takes name in Standard encoding and converts it in the given encoding.

func FromStandardPath Uses

func FromStandardPath(e Encoder, s string) string

FromStandardPath takes a / separated path in Standard encoding and converts it to a / separated path in the given encoding.

func ToStandardName Uses

func ToStandardName(e Encoder, s string) string

ToStandardName takes name in the given encoding and converts it in Standard encoding.

func ToStandardPath Uses

func ToStandardPath(e Encoder, s string) string

ToStandardPath takes a / separated path in the given encoding and converts it to a / separated path in Standard encoding.

type Encoder Uses

type Encoder interface {
    // Encode takes a raw name and substitutes any reserved characters and
    // patterns in it
    Encode(string) string
    // Decode takes a name and undoes any substitutions made by Encode
    Decode(string) string

    // FromStandardPath takes a / separated path in Standard encoding
    // and converts it to a / separated path in this encoding.
    FromStandardPath(string) string
    // FromStandardName takes name in Standard encoding and converts
    // it in this encoding.
    FromStandardName(string) string
    // ToStandardPath takes a / separated path in this encoding
    // and converts it to a / separated path in Standard encoding.
    ToStandardPath(string) string
    // ToStandardName takes name in this encoding and converts
    // it in Standard encoding.
    ToStandardName(string) string
}

Encoder can transform names to and from the original and translated version.

func Identity Uses

func Identity() Encoder

Identity returns a Encoder that always returns the input value

type MultiEncoder Uses

type MultiEncoder uint

MultiEncoder is a configurable Encoder. The Encode* constants in this package can be combined using bitwise or (|) to enable handling of multiple character classes

func (MultiEncoder) Decode Uses

func (mask MultiEncoder) Decode(in string) string

Decode takes a name and undoes any substitutions made by Encode

func (MultiEncoder) Encode Uses

func (mask MultiEncoder) Encode(in string) string

Encode takes a raw name and substitutes any reserved characters and patterns in it

func (MultiEncoder) FromStandardName Uses

func (mask MultiEncoder) FromStandardName(s string) string

FromStandardName takes name in Standard encoding and converts it in this encoding.

func (MultiEncoder) FromStandardPath Uses

func (mask MultiEncoder) FromStandardPath(s string) string

FromStandardPath takes a / separated path in Standard encoding and converts it to a / separated path in this encoding.

func (MultiEncoder) ToStandardName Uses

func (mask MultiEncoder) ToStandardName(s string) string

ToStandardName takes name in this encoding and converts it in Standard encoding.

func (MultiEncoder) ToStandardPath Uses

func (mask MultiEncoder) ToStandardPath(s string) string

ToStandardPath takes a / separated path in this encoding and converts it to a / separated path in Standard encoding.

Package encoder imports 6 packages (graph). Updated 2019-02-22. Refresh now. Tools for package owners.