|
Download polyglot/polyglot-0000.jsonl from winapiadmin/tinycodinglm: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/main/polyglot/polyglot-0000.jsonl
- Command line
-
hf download hf://datasets/winapiadmin/tinycodinglm/polyglot/polyglot-0000.jsonl
-
curl -L -o polyglot-0000.jsonl https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/main/polyglot/polyglot-0000.jsonl
1.26 kB
| {"type": "session", "harness": "opencode", "id": "polyglot-0000", "name": "UTF-8 file stats in Rust"} | |
| {"type": "message", "message": {"role": "system", "content": "You are an expert software engineer. You give correct, idiomatic, runnable code with brief explanations."}} | |
| {"type": "message", "message": {"role": "user", "content": "How do I count lines, words, characters and bytes of a UTF-8 text file? Show me the Rust version."}} | |
| {"type": "message", "message": {"role": "assistant", "content": "In Rust, `String::len()` is bytes and `chars().count()` is Unicode scalar values — exactly the distinction you need. `read_to_string` enforces valid UTF-8.\n\n```rust\nuse std::fs;\n\nfn main() -> std::io::Result<()> {\n let text = \"Olá mundo! Ação, coração.\\nSegunda linha: Straße, 你好.\\n\";\n fs::write(\"sample.txt\", text)?;\n let data = fs::read_to_string(\"sample.txt\")?;\n let bytes = data.len();\n let chars = data.chars().count();\n let words = data.split_whitespace().count();\n let lines = data.lines().count();\n println!(\"lines={lines} words={words} chars={chars} bytes={bytes}\");\n assert_eq!((lines, words), (2, 8));\n assert!(bytes > chars); // multibyte content present\n Ok(())\n}\n```"}} | |