Last active
March 10, 2021 07:42
-
-
Save ianfoo/93cd8d3be4409fcf2873fdc1a699d2d8 to your computer and use it in GitHub Desktop.
Decode ISO-8859 encoded text to UTF-8
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
#! /usr/bin/env python2 | |
# <bitbar.title>Escaped-Py2</bitbar.title> | |
# <bitbar.version>v0.0.1</bitbar.version> | |
# <bitbar.author.github>ianfoo</bitbar.author.github> | |
# <bitbar.desc>Echo escaped chars to stdout</bitbar.desc> | |
print("py2: :zzz: P\xe5 tide \xe5 logge av") |
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
package main | |
import ( | |
"fmt" | |
"os" | |
"os/exec" | |
"golang.org/x/text/encoding/charmap" | |
) | |
func main() { | |
c := exec.Cmd{Path: "001-escaped-py2.2s.py"} | |
stdout, err := c.Output() | |
if err != nil { | |
fmt.Fprintf(os.Stderr, "error running command: %w\n", err) | |
return | |
} | |
dec := charmap.ISO8859_1.NewDecoder() | |
output, err := dec.String(string(stdout)) | |
fmt.Println(output) | |
} |
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
❯ ./001-escaped-py2.2s.py | |
py2: :zzz: P� tide � logge av | |
❯ go run decode-it.go | |
py2: :zzz: På tide å logge av |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment