Last active
October 4, 2020 23:47
-
-
Save hamzamuric/22d2773634febf2a57df2ce56a989297 to your computer and use it in GitHub Desktop.
Osisaj latinicu u fajlu.
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
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, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Treba da se doda i dj.