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
Functionality for Base64 encoding implemented #565
Conversation
Standard Encode\ URL Safe Encode\ Decode Decode as Hex
src/Edit.c
Outdated
char *out = (char *)NP2HeapAlloc(olen); | ||
Base64ToBin(out, in); | ||
if(DecodeAsHex){ | ||
char *cch = (char *)NP2HeapAlloc((len * 3) + 4 + (floor(len / 16) * 1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang fails on floor
, see https://github.com/zufuliu/notepad2/actions/runs/3601306960/jobs/6066952554#step:5:210
how about len*3 + 2*(len/16 + 1) + 1
=> len*3 + len/8 + 3
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say it should be fine. Shall I make the change or are you going to make it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
multiply by 2 is due to CRLF line endings, you can push a change (without handing different eol) to make CI happy.
The current code doesn't looks good (e.g. Blkx
can be inlined?), but it hard to write optimized base64 encoding/decoding code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I'll make the change. I had already thought of putting the blk.. functions on line. I hadn't done it thinking I was doing something nice 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed what you requested 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think inline not means make them one line, but remove them completely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried other algorithms but this seems to be the only one that really works... I have no alternative ideas at the moment...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I can rework the code in this weekend.
Functions:
Standard Encode
URL Safe Encode
Decode
Decode as Hex