hoicolor

Crates.iohoicolor
lib.rshoicolor
version0.1.0
created_at2024-12-25 04:44:02.400279+00
updated_at2024-12-25 04:44:02.400279+00
descriptionconvert hearts of iron colors -> ansi
homepage
repositoryhttps://github.com/tlm9201/hoicolor
max_upload_size
id1494792
size5,571
timo (tlm9201)

documentation

README

hoicolor

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³.

usage

use hoicolor::Converter;

fn from_hoi(s: String) -> String {
  let converter: Converter = Converter(s);
  return s.to_ansi(); // hoi4 -> ansi
}

thanks

  • @ewof for the hoi4 colors paste

todo

  • api to convert from ansi/human readable color -> hoi4 color

references

  1. minecraft colors
  2. hoi4 colors paste
  3. ansi colors

license

Commit count: 3

cargo fmt