charset

package
v1.69.2 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

* Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0

* Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0

* Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0

* Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved. * SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const InvalidUTF8CharacterReplacement = "?"

Variables

This section is empty.

Functions

func DetectTextEncoding

func DetectTextEncoding(content []byte) (encoding.Encoding, string, error)

DetectTextEncoding returns best guess of encoding of given content.

func DetectTextEncodingFromReader

func DetectTextEncodingFromReader(reader io.Reader) (encoding.Encoding, string, error)

DetectTextEncodingFromReader returns best guess of encoding of given reader content. Looks at the first 1024 bytes in the same way as https://pkg.go.dev/golang.org/x/net/html/charset#DetermineEncoding

func GetUnsupported

func GetUnsupported(name string) (encoding.Encoding, error)

GetUnsupported gets valid IANA charset encoding we know are not supported by golang but not reported as such.

func Iconv

func Iconv(reader io.Reader, fromEncoding encoding.Encoding, toEncoding encoding.Encoding) io.Reader

Iconv converts from any supported text encodings to any other, through Unicode conversion. Similar to https://www.gnu.org/software/libiconv/ but using pure go as opposed to many go libraries

func IconvBytes

func IconvBytes(input []byte, fromEncoding encoding.Encoding, toEncoding encoding.Encoding) ([]byte, error)

IconvBytes converts bytes from one text encoding charset to another.

func IconvBytesFromLabels

func IconvBytesFromLabels(input []byte, fromEncodingLabel string, toEncodingLabel string) (transformedBytes []byte, err error)

IconvBytesFromLabels is similar to IconvBytes but uses labels.

func IconvFromLabels

func IconvFromLabels(reader io.Reader, fromEncodingLabel string, toEncodingLabel string) (transformedReader io.Reader, err error)

IconvFromLabels is similar to Iconv but uses labels.

func IconvString

func IconvString(input string, fromEncoding encoding.Encoding, toEncoding encoding.Encoding) (string, error)

IconvString converts string from one text encoding charset to another.

func IconvStringFromLabels

func IconvStringFromLabels(input string, fromEncodingLabel string, toEncodingLabel string) (transformedText string, err error)

IconvStringFromLabels is similar to IconvString but uses labels.

func LookupCharset

func LookupCharset(charsetLabel string) (charsetEnc encoding.Encoding, charsetName string, err error)

LookupCharset returns the encoding with the specified charsetLabel, and its canonical name. Matching is case-insensitive and ignores leading and trailing whitespace.

Types

type ICharsetEncodingMapping

type ICharsetEncodingMapping interface {
	GetCanonicalName(alias string) (string, error)
}

Directories

Path Synopsis
* Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors.
* Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors.
Package iconv provides utilities to convert characters into different charsets
Package iconv provides utilities to convert characters into different charsets

Jump to

Keyboard shortcuts

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