79516246

Date: 2025-03-18 03:56:00
Score: 0.5
Natty:
Report link

This was my solution.

In order to accommodate for the utf-8 format spec, each byte should be left padded up to 8 bits with 0.

The accepted answer's `format!("0{:b}")` does not take into consideration for characters above number 128 which did not work for me since I wasn't just working with ASCII letters.

fn main() {
    let chars = "日本語 ENG €";
    let mut chars_in_binary = String::from("");

    for char in chars.as_bytes() {
        chars_in_binary += &format!("{char:0>8b} ");
    }

    println!("The binary representation of the following utf8 string\n \"{chars}\"\nis\n {chars_in_binary}");
}       
Reasons:
  • Blacklisted phrase (1): did not work
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: tinnick