Skip to content

feat(builtins): add iconv command (encoding conversion) #555

@chaliy

Description

@chaliy

Summary

iconv converts text between character encodings. When processing files from unknown sources, encoding mismatches are a constant problem — mojibake, invalid UTF-8, Latin-1 legacy files.

Requested Flags

Flag Description
-f encoding Source encoding (from)
-t encoding Target encoding (to)
-l List available encodings
-c Silently discard characters that cannot be converted
-o file Output to file instead of stdout
//IGNORE Suffix on -t to skip unconvertible chars
//TRANSLIT Suffix on -t to transliterate unconvertible chars

Common Encodings to Support

Encoding Description
UTF-8 Default, most common
ASCII 7-bit ASCII
ISO-8859-1 / LATIN1 Western European
UTF-16 / UTF-16LE / UTF-16BE Windows Unicode
CP1252 / WINDOWS-1252 Windows Western European
ISO-8859-15 Latin-9 (Euro sign)

Use Cases

# Convert Latin-1 file to UTF-8
iconv -f ISO-8859-1 -t UTF-8 legacy.txt > modern.txt

# Pipe conversion
curl -s https://example.com/data.csv | iconv -f CP1252 -t UTF-8 | csvtool ...

# Strip non-ASCII characters
iconv -f UTF-8 -t ASCII//TRANSLIT input.txt

# List available encodings
iconv -l

Implementation Notes

  • Rust's encoding_rs crate handles most common encodings
  • Operates on VFS file contents (byte-level)
  • Default target encoding should be UTF-8
  • //IGNORE and //TRANSLIT suffixes on target encoding are important usability features

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions