mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
base64: simplify ignore_garbage
This commit is contained in:
parent
93f7220a40
commit
ce05187dac
1 changed files with 2 additions and 7 deletions
|
@ -17,7 +17,6 @@ extern crate getopts;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
#[phase(syntax, link)] extern crate log;
|
#[phase(syntax, link)] extern crate log;
|
||||||
|
|
||||||
use std::char;
|
|
||||||
use std::io::{println, File, stdin, stdout};
|
use std::io::{println, File, stdin, stdout};
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::str;
|
use std::str;
|
||||||
|
@ -101,13 +100,9 @@ fn decode(input: &mut Reader, ignore_garbage: bool) {
|
||||||
to_decode = str::replace(to_decode, "\n", "");
|
to_decode = str::replace(to_decode, "\n", "");
|
||||||
|
|
||||||
if ignore_garbage {
|
if ignore_garbage {
|
||||||
let standard_chars: ~[char] =
|
let standard_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
bytes!("ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
|
||||||
"abcdefghijklmnopqrstuvwxyz",
|
|
||||||
"0123456789+/").iter().map(|b| char::from_u32(*b as u32).unwrap()).collect();
|
|
||||||
|
|
||||||
to_decode = to_decode
|
to_decode = to_decode
|
||||||
.trim_chars(|c| !standard_chars.contains(&c))
|
.trim_chars(|c| !standard_chars.contains_char(c))
|
||||||
.to_owned();
|
.to_owned();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue