square / okio

A modern I/O library for Android, Java, and Kotlin Multiplatform.
https://square.github.io/okio/
Apache License 2.0
8.72k stars 1.17k forks source link

Consider `ignoreWhitespace=true` parameter to `decodeHex` #1433

Open JakeWharton opened 4 months ago

JakeWharton commented 4 months ago

Hex often shows up with visual whitespace (spaces, newlines, tabs). I can preprocess it, and I do, but I've just copied that helper function to my third project.

I think this would be a pragmatic inclusion.

One caveat is that this would probably be a conditional that selected two mostly different implementations of the decoding due to how the current one works.

swankjesse commented 4 months ago

I’m also sad we did a bad job of being consistent with hex and base64. Hex is strict and throws; base64 is lenient and returns null. Whoops!