https://github.com/tsatke/cpconv
A codepage converter. Has a Go API as well as a command line tool. Use it to convert streams from one codepage into another.
https://github.com/tsatke/cpconv
Last synced: 3 months ago
JSON representation
A codepage converter. Has a Go API as well as a command line tool. Use it to convert streams from one codepage into another.
- Host: GitHub
- URL: https://github.com/tsatke/cpconv
- Owner: tsatke
- License: mit
- Created: 2020-11-26T15:58:54.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-11-27T10:15:08.000Z (over 4 years ago)
- Last Synced: 2024-06-20T07:57:34.966Z (12 months ago)
- Language: Go
- Size: 56.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
cpconv
A codepage converter. Has a Go API as well as a command line tool. Use it to convert streams from one codepage into another.
---
## Installation
Go get it with
```plain
go get github.com/tsatke/cpconv/...
```
or just import it with
```plain
import "github.com/tsatke/cpconv"
```
and see a usage example below## Usage (as command line tool)
```plain
Usage:
cpconv [flags]Examples:
cat myFile.txt | cpconv --from IBM037 --to CP1252Flags:
--from string --from IBM037
-h, --help help for cpconv
--to string --to CP1252
--version version for cpconv
```This tool does not read from files, it just reads from stdin and writes to stdout.
Pipes are your best friends with this tool, as you can see in the example.## Supported codepages
| Codepage | supported | aliases |
| --- | :---: | --- |
| `IBM037` | :white_check_mark: | `IBM-037` |
| `CP1252` | :white_check_mark: | `CP-1252` |## Usage (with the Go API)
**Please note** that there are no restrictions on what codepages are supported when using the Go API.
This is because we are not limited to strings here.
As long as you can provide an implementation, the conversion will work.Working example:
```go
package mainimport (
"os""github.com/tsatke/cpconv"
"golang.org/x/text/encoding/charmap"
)func main() {
// this will convert EBCDIC input on stdin to CP1252 output on stdout
if err := cpconv.Convert(os.Stdin, charmap.CodePage037, os.Stdout, charmap.Windows1252); err != nil {
panic(err)
}
}
```Please find other examples in the examples directory.