btoa accepts characters outside Latin-1

Open Beginner friendly
#3,822 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp, typescript
Domain
backend

Research direction

Start by running the provided snippet with the SharpTS interpreter and with standalone compilation and verification, then trace the btoa implementation used by both paths. Compare its handling of characters outside Latin-1 with Node.js v22.23.2, which throws InvalidCharacterError with code 5. Done when both SharpTS outputs match that behavior for the reproduction.

Written by the indexing model from the issue text.

Description

While verifying #3816, I found a separate mismatch in the encoder.

try { console.log(btoa('\u0100')); }
catch (error) { console.log(error.name, error.code); }

Node.js v22.23.2 throws and the snippet prints InvalidCharacterError 5. The SharpTS interpreter and IL-verified standalone output both print QQ==.

Reproduced against a326c6f59. Run as sharpts --no-tsconfig --noLib repro.js. For standalone, run sharpts --no-tsconfig --noLib --compile repro.js --standalone --verify -o repro.dll and dotnet repro.dll.

Dominant language
C#
Stars
156
Forks
4
Avg merge
14h 45m
Merged PRs (30d)
40

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nickna/SharpTS

All issues in nickna/SharpTS

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.