{"action":"reopened","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/26710","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/26710/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/26710/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/26710/events","html_url":"https://github.com/rust-lang/rust/issues/26710","id":92332502,"number":26710,"title":"Unexpected behaviour with stdin and .lines() on Windows","user":{"login":"DaniJVaz","id":1095533,"avatar_url":"https://avatars.githubusercontent.com/u/1095533?v=3","gravatar_id":"","url":"https://api.github.com/users/DaniJVaz","html_url":"https://github.com/DaniJVaz","followers_url":"https://api.github.com/users/DaniJVaz/followers","following_url":"https://api.github.com/users/DaniJVaz/following{/other_user}","gists_url":"https://api.github.com/users/DaniJVaz/gists{/gist_id}","starred_url":"https://api.github.com/users/DaniJVaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaniJVaz/subscriptions","organizations_url":"https://api.github.com/users/DaniJVaz/orgs","repos_url":"https://api.github.com/users/DaniJVaz/repos","events_url":"https://api.github.com/users/DaniJVaz/events{/privacy}","received_events_url":"https://api.github.com/users/DaniJVaz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-07-01T09:48:47Z","updated_at":"2015-07-01T13:57:11Z","closed_at":null,"body":"Using .lines() for input on Windows always reads an '\\r' at the end of the string.\r\n\r\nFor example:\r\n\r\n\tfn main() {\r\n\t\tuse std::io::prelude::*;\r\n\t\tuse std::io;\r\n\r\n\t\tlet stdin = io::stdin();\r\n\t\tfor line in stdin.lock().lines() {\r\n\t\t\tlet line = line.unwrap();\r\n\t\t\tprintln!(\"You entered (String): {:?}\", line);\r\n\r\n\t\t\tmatch line.parse::<i32>() {\r\n\t\t\t\tOk(num) => println!(\"You entered (i32): {}\", num),\r\n\t\t\t\tErr(_) => println!(\"That was not a number...\"),\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\nprints:\r\n\r\n\t2\r\n\tYou entered (String): \"2\\r\"\r\n\tThat was not a number...\r\n\r\nThis complicates even simple tasks, like reading a number in the example, which now needs an extra .trim() to make sure that the '\\r' is removed. \r\n\r\nI understand that in some cases having the '\\r' may be useful, but when using .lines() the input should be split into lines according to the line separator, which is \"\\r\\n\" on Windows."}}