🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

github.com/kpym/utf8reader

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/kpym/utf8reader

v0.5.1
Source
Go
Version published
Created
Source

utf8reader

A simple go package that converts an io.Reader to a utf8 encoded io.Reader. It automatically detects the encoding of the input and converts it to utf8.

Usage


package main

import (
    "fmt"
    "bytes"

    "github.com/kpym/utf8reader"
)

func main() {
    // Create a reader with koi8-r encoded "Това е на български"
    r := bytes.NewReader([]byte{0xF4, 0xCF, 0xD7, 0xC1, 0x20, 0xC5, 0x20, 0xCE, 0xC1, 0x20, 0xC2, 0xDF, 0xCC, 0xC7, 0xC1, 0xD2, 0xD3, 0xCB, 0xC9})
    reader := utf8reader.New(r)

    // Read the content of the reader
    buf := make([]byte, 100)
    n, err := reader.Read(buf)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Println(string(buf[:n]))
    // Output: Това е на български
}

Documentation

Go Reference

You can find the documentation on pkg.go.dev.

License

MIT

FAQs

Package last updated on 30 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts