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

Functionality for Base64 encoding implemented #565

Merged
merged 3 commits into from Dec 2, 2022

Conversation

Matteo-Nigro
Copy link
Contributor

Functions:
Standard Encode
URL Safe Encode
Decode
Decode as Hex

Standard Encode\						URL Safe Encode\							Decode											Decode as Hex
src/Notepad2.rc Outdated Show resolved Hide resolved
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));
Copy link
Owner

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 ?

Copy link
Contributor Author

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?

Copy link
Owner

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.

Copy link
Contributor Author

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 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed what you requested 😉

Copy link
Owner

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?

Copy link
Contributor Author

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...

Copy link
Owner

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.

@zufuliu zufuliu linked an issue Dec 2, 2022 that may be closed by this pull request
@zufuliu zufuliu removed a link to an issue Dec 2, 2022
@zufuliu zufuliu merged commit e7d7f11 into zufuliu:main Dec 2, 2022
@zufuliu zufuliu added this to the v4.23.01 milestone Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants