Skip to content

feat(rg): add encoding support - #1662

Merged
chaliy merged 1 commit into
mainfrom
2026-05-22-rg-encoding
May 22, 2026
Merged

chaliy merged 1 commit into
mainfrom
2026-05-22-rg-encoding

Conversation

@chaliy

@chaliy chaliy commented May 22, 2026

Copy link
Copy Markdown
Contributor

What

Add rg -E/--encoding support for auto, none, UTF-8, UTF-16LE, and UTF-16BE file decoding.

Why

Real ripgrep searches UTF-16 input when explicitly requested or when a UTF-16 BOM is present. Bashkit rg previously treated those files as lossy UTF-8/binary data.

How

Decode searched file bytes through rg-specific encoding handling before line splitting and binary detection, add parser/help/docs coverage, and extend real-rg differential cases for forced UTF-16, BOM auto-detection, and --encoding=none.

Risk

  • Low
  • Only a narrow set of encodings is implemented; other WHATWG labels still return an unsupported-encoding error.

Checklist

  • Tests added or updated
  • Backward compatibility considered

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 4f60c3e Commit Preview URL May 22 2026, 07:19 AM

@chaliy
chaliy merged commit f95a41a into main May 22, 2026
34 checks passed
@chaliy
chaliy deleted the 2026-05-22-rg-encoding branch May 22, 2026 07:31
chaliy added a commit that referenced this pull request May 30, 2026
## What
Add rg -E/--encoding support for auto, none, UTF-8, UTF-16LE, and
UTF-16BE file decoding.

## Why
Real ripgrep searches UTF-16 input when explicitly requested or when a
UTF-16 BOM is present. Bashkit rg previously treated those files as
lossy UTF-8/binary data.

## How
Decode searched file bytes through rg-specific encoding handling before
line splitting and binary detection, add parser/help/docs coverage, and
extend real-rg differential cases for forced UTF-16, BOM auto-detection,
and --encoding=none.

## Risk
- Low
- Only a narrow set of encodings is implemented; other WHATWG labels
still return an unsupported-encoding error.

## Checklist
- [x] Tests added or updated
- [x] Backward compatibility considered
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.

1 participant