std.fmt.ParseInt working on MacOS but not Windows

Hey all! Fairly new to zig so I could be making a noob mistake. Been doing AoC recently and have been doing it all on my mac and all files execute as expected. Went to my windows recently and pulled changes and made no edits but I have been getting ‘Invalid Character’ errors on instances of std.fmt.parseInt. So it’s either an issue with my std.mem.tokenizeSequence or parseInt. Just curious to know what it could be.

code:
https://zigbin.io/1a2aca

edit: for reference, input is in the form of
num1 num2
e.g:
12345 67890
09876 54321
and so on

Wild guess, CRLF line endings on Windows?

--- a.zig	2025-02-18 07:09:44.390542090 +0000
+++ b.zig	2025-02-18 07:10:38.437649216 +0000
@@ -50,7 +50,8 @@
     var lines = std.mem.tokenizeScalar(u8, data, '\n');
     var i: usize = 0;
     while (lines.next()) |token| {
-        var line = std.mem.tokenizeScalar(u8, token, ' ');
+        const trimmed_token = std.mem.trim(u8, token, "\r");
+        var line = std.mem.tokenizeScalar(u8, trimmed_token, ' ');
         while (line.next()) |number| {
             if (i % 2 == 0) {
                 const num = parseInt(i32, number, 10) catch {
3 Likes

exactly right. Thank you.