Skip to content

xsoameix/utfconv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

utfconv

utfconv is the fast way to convert []byte to string by chooing charset

Installation

Make sure you have the a working Go environment. See the install instructions.

To install utfcon.go, simply run:

go get github.com/xsoameix/utfconv

To compile it from source:

git clone git@github.com:xsoameix/utfconv.git
cd utfconv && go build

Example

package main

import (
    "github.com/xsoameix/utfconv"
)

func main() {
    utf8 := []byte("Hello, world")
    utf16be := []byte("\x00\x48\x00\x65\x00\x6C" +
        "\x00\x6C\x00\x6F\x00\x2C\x00\x20"+
        "\x00\x77\x00\x6F\x00\x72\x00\x6C"+
        "\x00\x64")
    fmt.Printf("%s\n%s\n",
        utfconv.Read("utf8", utf8),
        utfconv.Read("utf16be", utf16be))
}

To run the application, put the code in a file called hello.go and run:

go build hello.go

About

convert []byte to string

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages