-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
921458d
commit e1bfbca
Showing
10 changed files
with
1,202 additions
and
1,202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
module retrotxt.com/retrotxt | ||
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/alecthomas/chroma v0.7.3 | ||
github.com/aofei/mimesniffer v1.1.4 | ||
github.com/gookit/color v1.2.6 | ||
github.com/mozillazg/go-slugify v0.2.0 | ||
github.com/mozillazg/go-unidecode v0.1.1 // indirect | ||
github.com/muesli/go-app-paths v0.2.1 | ||
github.com/spf13/cobra v1.0.0 | ||
github.com/spf13/viper v1.7.0 | ||
github.com/tdewolff/minify v2.3.6+incompatible | ||
github.com/tdewolff/parse v2.3.4+incompatible // indirect | ||
github.com/tdewolff/test v1.0.6 // indirect | ||
golang.org/x/text v0.3.3 | ||
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 | ||
) | ||
module retrotxt.com/retrotxt | ||
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/alecthomas/chroma v0.7.3 | ||
github.com/aofei/mimesniffer v1.1.4 | ||
github.com/gookit/color v1.2.6 | ||
github.com/mozillazg/go-slugify v0.2.0 | ||
github.com/mozillazg/go-unidecode v0.1.1 // indirect | ||
github.com/muesli/go-app-paths v0.2.1 | ||
github.com/spf13/cobra v1.0.0 | ||
github.com/spf13/viper v1.7.0 | ||
github.com/tdewolff/minify v2.3.6+incompatible | ||
github.com/tdewolff/parse v2.3.4+incompatible // indirect | ||
github.com/tdewolff/test v1.0.6 // indirect | ||
golang.org/x/text v0.3.3 | ||
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.0.22 | ||
0.0.23 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,57 @@ | ||
package convert | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"io/ioutil" | ||
"strings" | ||
"unicode/utf8" | ||
|
||
"golang.org/x/text/encoding/charmap" | ||
"golang.org/x/text/transform" | ||
) | ||
|
||
var ErrNoUTF8 = errors.New("string is not encoded as utf8") | ||
|
||
// DString decodes simple character encoding text. | ||
func DString(s string, c *charmap.Charmap) (result []byte, err error) { | ||
decoder := c.NewDecoder() | ||
reader := transform.NewReader(strings.NewReader(s), decoder) | ||
result, err = ioutil.ReadAll(reader) | ||
if err != nil { | ||
return nil, fmt.Errorf("dstring ioutil readall error: %w", err) | ||
} | ||
return result, nil | ||
} | ||
|
||
// EString encodes text into a simple character encoding. | ||
func EString(s string, c *charmap.Charmap) (result []byte, err error) { | ||
if !utf8.Valid([]byte(s)) { | ||
return result, fmt.Errorf("estring: %w", ErrNoUTF8) | ||
} | ||
encoder := c.NewEncoder() | ||
reader := transform.NewReader(strings.NewReader(s), encoder) | ||
result, err = ioutil.ReadAll(reader) | ||
if err != nil { | ||
return nil, fmt.Errorf("estring ioutil readall error: %w", err) | ||
} | ||
return result, nil | ||
} | ||
|
||
// D437 decodes IBM Code Page 437 encoded text. | ||
func D437(s string) (result []byte, err error) { | ||
result, err = DString(s, charmap.CodePage437) | ||
if err != nil { | ||
return nil, fmt.Errorf("decode code page 437: %w", err) | ||
} | ||
return result, nil | ||
} | ||
|
||
// E437 encodes text into IBM Code Page 437. | ||
func E437(s string) (result []byte, err error) { | ||
result, err = EString(s, charmap.CodePage437) | ||
if err != nil { | ||
return nil, fmt.Errorf("encode code page 437: %w", err) | ||
} | ||
return result, nil | ||
} | ||
package convert | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"io/ioutil" | ||
"strings" | ||
"unicode/utf8" | ||
|
||
"golang.org/x/text/encoding/charmap" | ||
"golang.org/x/text/transform" | ||
) | ||
|
||
var ErrNoUTF8 = errors.New("string is not encoded as utf8") | ||
|
||
// DString decodes simple character encoding text. | ||
func DString(s string, c *charmap.Charmap) (result []byte, err error) { | ||
decoder := c.NewDecoder() | ||
reader := transform.NewReader(strings.NewReader(s), decoder) | ||
result, err = ioutil.ReadAll(reader) | ||
if err != nil { | ||
return nil, fmt.Errorf("dstring ioutil readall error: %w", err) | ||
} | ||
return result, nil | ||
} | ||
|
||
// EString encodes text into a simple character encoding. | ||
func EString(s string, c *charmap.Charmap) (result []byte, err error) { | ||
if !utf8.Valid([]byte(s)) { | ||
return result, fmt.Errorf("estring: %w", ErrNoUTF8) | ||
} | ||
encoder := c.NewEncoder() | ||
reader := transform.NewReader(strings.NewReader(s), encoder) | ||
result, err = ioutil.ReadAll(reader) | ||
if err != nil { | ||
return nil, fmt.Errorf("estring ioutil readall error: %w", err) | ||
} | ||
return result, nil | ||
} | ||
|
||
// D437 decodes IBM Code Page 437 encoded text. | ||
func D437(s string) (result []byte, err error) { | ||
result, err = DString(s, charmap.CodePage437) | ||
if err != nil { | ||
return nil, fmt.Errorf("decode code page 437: %w", err) | ||
} | ||
return result, nil | ||
} | ||
|
||
// E437 encodes text into IBM Code Page 437. | ||
func E437(s string) (result []byte, err error) { | ||
result, err = EString(s, charmap.CodePage437) | ||
if err != nil { | ||
return nil, fmt.Errorf("encode code page 437: %w", err) | ||
} | ||
return result, nil | ||
} |
Oops, something went wrong.