Last active
September 17, 2025 20:36
-
-
Save kirkegaard/21c0fe38307fb95c4ebbef25df9717e5 to your computer and use it in GitHub Desktop.
converts this into something pablodraw will read: https://demozoo.org/graphics/370994/
This file contains hidden or 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 ( | |
| "log" | |
| "os" | |
| ) | |
| func main() { | |
| data, err := os.ReadFile("input.txt") | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| replacements := map[string]byte{ | |
| "▓": 219, | |
| "▒": 177, | |
| "░": 176, | |
| "█": 219, | |
| "▄": 220, | |
| "▀": 223, | |
| "▐": 222, | |
| "▌": 221, | |
| } | |
| var result []byte | |
| for _, r := range string(data) { | |
| if r == '\n' { | |
| // LF to CR | |
| result = append(result, '\r') | |
| } else if r < 128 { | |
| // ASCII | |
| result = append(result, byte(r)) | |
| } else if cp437Val, exists := replacements[string(r)]; exists { | |
| // Unicode blocks to CP437 | |
| result = append(result, cp437Val) | |
| } else { | |
| // Unknown Unicode | |
| result = append(result, '?') | |
| } | |
| } | |
| err = os.WriteFile("output.txt", result, 0644) | |
| if err != nil { | |
| log.Fatal(err) | |
| } | |
| log.Println("Done") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment