| Crates.io | hoicolor |
| lib.rs | hoicolor |
| version | 0.1.0 |
| created_at | 2024-12-25 04:44:02.400279+00 |
| updated_at | 2024-12-25 04:44:02.400279+00 |
| description | convert hearts of iron colors -> ansi |
| homepage | |
| repository | https://github.com/tlm9201/hoicolor |
| max_upload_size | |
| id | 1494792 |
| size | 5,571 |
a simple rust lib to convert from hearts of iron 4 (hoi4) escaped color sequences to ansi for stdout.
the original purpose in creating this project was for my other hoi4 related project hoiscan. this along with hoiscan is my first experience using rust. originally i was going to use python or javascript, but bindings to the steamworks library for those languages were limited. my other options were c/cpp/rust. i chose rust because of my positive experience building/using rust from other open source projects.
hoi4 uses escape sequences similar to minecraft¹. a start of a color is indicated by the unicode character U+0011 () followed by and english character representing the color (e.g. White: W). to end a sequence the unicode character followed by ! is used². stdout however cannot understand this. so, hoicolor maps a hoi4 colored string and replaces the colors with ansi color sequences³.
use hoicolor::Converter;
fn from_hoi(s: String) -> String {
let converter: Converter = Converter(s);
return s.to_ansi(); // hoi4 -> ansi
}