Skip to content

Instantly share code, notes, and snippets.

@hamzamuric
Last active October 4, 2020 23:47
Show Gist options
  • Save hamzamuric/22d2773634febf2a57df2ce56a989297 to your computer and use it in GitHub Desktop.
Save hamzamuric/22d2773634febf2a57df2ce56a989297 to your computer and use it in GitHub Desktop.
Osisaj latinicu u fajlu.
use std::env;
use std::fs;
fn main() {
let args: Vec<_> = env::args().collect();
let filename = &args[1];
let contents = fs::read_to_string(filename).expect("Problem reading the file");
let transformed: String = contents.chars().map(|c| ascii_char(c)).collect();
fs::write(filename, transformed).expect("Unable to write file");
}
#[inline(always)]
fn ascii_char(c: char) -> char {
match c {
'Č' => 'č',
'Ć' => 'C',
'ć' => 'c',
'Đ' => 'đ',
'Š' => 'S',
'š' => 's',
'Ž' => 'Z',
'ž' => 'z',
other => other,
}
}
@hamzamuric
Copy link
Author

Treba da se doda i dj.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment