ejolson wrote: ↑Fri May 26, 2023 1:37 am
I was working on my car today and discovered my fear of rust might be greater than my fear of C++.
The cable broke and my main accomplishment was inserting some boards of wood inside the door under the window so it stays up before the rain came. After checking the rust on the car, I had some time to check Rust on the Pi.
Heater wrote: ↑Fri May 26, 2023 12:40 am
If you want to build and run that I suggest you use Cargo.
Thanks! Here are my results:
Code: Select all
$ cargo build --release
Compiling u8scan v0.1.0 (/x/turb/ejolson/code/u8scan)
Finished release [optimized] target(s) in 2.65s
$ wget https://downloads.raspberrypi.org/raspios_armhf/images/raspios_armhf-2023-05-03/2023-05-03-raspios-bullseye-armhf.img.xz
$ unxz 2023-05-03-raspios-bullseye-armhf.img.xz
$ su
# mkdir rootfs
# mount -o offset=272629760 2023-05-03-raspios-bullseye-armhf.img rootfs
# cd rootfs
# ../target/release/u8scan
Fido's UTF-8 popularity statistics:
Total files: 112362
UTF-8 files: 39217
UTF-8/total: 34.902369128353%
# cd ..
# umount rootfs
# exit
I don't know if 34.902369128353 percent of the files in Raspberry Pi OS are really UTF-8, but it seems plausible.
For reference my code was
Code: Select all
use std::fs::File;
use utf8_read::Reader;
use walkdir::WalkDir;
fn checku8(s:&str) -> bool {
let in_file = File::open(s).unwrap();
let mut file_reader = Reader::new(&in_file);
for c in file_reader.into_iter() {
if c.is_err() {
return false;
}
}
return true;
}
fn main() -> std::io::Result<()> {
let mut ucount=0; let mut tcount=0;
for entry in WalkDir::new(".").into_iter().filter_map(|e| e.ok()) {
if entry.path().is_file() {
let s=entry.path().to_str().unwrap();
tcount+=1;
if checku8(s) {
ucount+=1;
}
}
}
println!("Fido's UTF-8 popularity statistics:\n");
println!("\tTotal files: {}\n\tUTF-8 files: {}",tcount,ucount);
println!("\tUTF-8/total: {}%",100.0*ucount as f64/tcount as f64);
Ok(())
}
I dedicated the program to the dog developer, who immediately complained about how few people use PETSCII encoding these days. I replied that UTF-8 was better because of the

emoji.
That almost worked, but then Fido looked at my code and started barking.
Defensively, I explained that I used a bit of cut and paste but not ChatGPT; however, the problem was lack of

in the code itself. I tried to fix that but got the message
Code: Select all
error: identifiers cannot contain emoji: `🐶`
More barking ensued. I'm fearful the program will have to be translated to some other language.