Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
sorainnosia authored Aug 7, 2023
1 parent 7605da6 commit 10a7f81
Showing 1 changed file with 91 additions and 0 deletions.
91 changes: 91 additions & 0 deletions src/rexetoolo/bytesops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,71 @@ pub fn rtrim(str: String) -> String {
return output;
}

pub fn lascii(str: String) -> String {
let obj = str.clone();
let mut gr = obj.chars();

let count = (obj.chars().count()) as i32;
let mut i = 0;
let mut start = true;

let mut output = String::from("");
while i < count {
let cc = gr.next();
let mut c = '\0';
match cc {
Some(x) => c = x,
None => { break; }
}

if start && (c < ' ' || c > '~') {
i = i + 1;
continue;
} else {
output.push_str(c.to_string().as_str());
start = false;
}
i = i + 1;
}
return output;
}

pub fn rascii(str: String) -> String {
let obj = str.clone();
let mut gr = obj.chars().rev();

let count = (obj.chars().count()) as i32;
let mut i = 0;
let mut start = true;

let mut output = String::from("");
while i < count {
let cc = gr.next();
let mut c = '\0';
match cc {
Some(x) => c = x,
None => { break; }
}

if start && (c < ' ' || c > '~') {
i = i + 1;
continue;
} else {
output.insert_str(0, c.to_string().as_str());
start = false;
}
i = i + 1;
}
return output;
}

pub fn ascii(str: String) -> String {
let mut result = str.to_string();
result = lascii(result);
result = rascii(result);
return result;

}
pub fn trim(str: String) -> String {
let mut result = str.to_string();
result = ltrim(result);
Expand Down Expand Up @@ -153,6 +218,32 @@ pub fn index_of(str: &Vec<u8>, sub: &Vec<u8>, start_index: i32, ignore_case: boo
return -1;
}

pub fn index_of_non_fn(str: &Vec<u8>, start_index: i32) -> i32 {
let stc = str.len();
if start_index + (1 as i32) > (stc as i32) { return -1; }

let mut i:i32 = 0;
let mut cnt:i32 = 0;

let mut cc:i32 = start_index;

for c in str.iter() {
if cc > 0 {
cc -= 1;
continue;
}

if (*c >= 32 && *c <= 126) {
i += 1;
} else {
i += 1;
return i - 1 + start_index;
}
}

return -1;
}

pub fn substring(str: &String, i: i32, mut count: i32) -> String {
let mut result = String::new();

Expand Down

0 comments on commit 10a7f81

Please sign in to comment.