Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added text.base64Encode and text.base64Decode #1742

Merged
merged 4 commits into from
Jan 17, 2020

Conversation

mpilquist
Copy link
Member

Adapted the implementations from scodec-bits for streaming / continuation.

@mpilquist
Copy link
Member Author

Fixes #1587

case 0 =>
buffer = (cidx & 0x3f)
mod += 1
case 1 =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case 1 | 2 might make intent a little clearer

case 0 => Right(Chunk.empty)
case 1 => Left("Final base 64 quantum had only 1 digit - must have at least 2 digits")
case 2 =>
Right(Chunk(((state.buffer >> 4) & 0x0ff).toByte))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this is 0x0ff vs 0xff?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, old habit. Fixing.

)
)
Pull.output1(out)
case _ => sys.error("carry must be size 0, 1, or 2")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding the invalid carry size in the error

Copy link
Contributor

@matthughes matthughes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM. Had a few small comments and think it might benefit from a couple additional test cases.

@mpilquist
Copy link
Member Author

@matthughes Want to take a quick look at updates from review?

@mpilquist mpilquist merged commit 6d081cc into typelevel:master Jan 17, 2020
@mpilquist mpilquist added this to the 2.2.0 milestone Jan 18, 2020
@mpilquist mpilquist deleted the topic/b64 branch February 18, 2020 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants