agentleFS
ShanHaiFishShanHaiFish/encoding-converter-skill/SKILL.md

encoding-converter

Skill0 starsChanged 6 months agoMITView on GitHub

Convert source files between text encodings. Use when an agent needs to migrate source comments, verify project encoding status, add or remove BOM, convert between encodings such as UTF-8, UTF-8-BOM, GB2312, GBK, Big5, Shift-JIS, UTF-16LE, or UTF-16BE, use git-tracked-file-aware encoding scans, prepare embedded firmware or Keil MDK source files for Chinese comment readability, or roll back tracked encoding-conversion changes.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. youjun011/skills★ 1same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

The file

Show its rules and text

We split this skill into the rules it gives an agent

18 rules. About 0 are common, 8 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill to convert source files between text encodings while avoiding accidental double-conversion.

    line 8
  2. Distinctive:

    Check repository status before changing files:

    line 12
  3. Distinctive:

    If the project is not already under git, initialize it and commit a baseline before conversion.

    line 18
  4. Distinctive:

    Commit the encoding migration separately from semantic code changes.

    line 40
  5. Very specific:

    Use -FirmwareSafe for an initial pass when third-party or vendor trees should remain byte-identical.

    line 53
  6. Very specific:

    Prefer -IncludeDirs for known application-owned folders such as src, User, FOC, App, or Core/Src.

    line 54
  7. Very specific:

    Do not include Keil project files such as .uvprojx or .uvoptx unless the user explicitly asks for project-file text conversion.

    line 55
  8. Very specific:

    After conversion, run the real firmware build.

    line 56
  9. Very specific:

    Run the scripts from this skill folder, or copy scripts/*.ps1 into the target project if that is more convenient.

    line 60
  10. Very specific:

    Add or remove BOM according to -TargetEncoding.

    line 90
  11. Distinctive:

    Use this after conversion and in CI-style checks.

    line 98
  12. Very specific:

    Prefer -ScanMode Auto for open-source use:

    line 116
  13. Very specific:

    Use -ScanMode Filesystem when untracked files must be included.

    line 120
  14. Very specific:

    Use -ScanMode Tracked when a git-only check should fail outside a repository.

    line 121
  15. Very specific:

    Prefer explicit -SourceEncoding for non-UTF encodings that cannot be reliably auto-detected.

    line 127
  16. Distinctive:

    Use this only when the conversion result should be discarded.

    line 131
  17. Distinctive:

    Do not hand-repair already-garbled Chinese text unless the original encoding can be proven.

    line 142
  18. Distinctive:

    Keep encoding-only commits separate from logic, formatting, and generated-file changes.

    line 144

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Encoding Converter

Use this skill to convert source files between text encodings while avoiding accidental double-conversion. The default workflow remains legacy Chinese source comments to UTF-8 with BOM, but explicit -SourceEncoding and -TargetEncoding parameters support broader conversions.

Workflow

  1. Check repository status before changing files:

    git status --short --branch
  2. If the project is not already under git, initialize it and commit a baseline before conversion.
  3. Preview the conversion:

    .\scripts\convert-encoding.ps1 -ProjectRoot "C:\Path\To\Project" -WhatIf
  4. Convert files:

    .\scripts\convert-encoding.ps1 -ProjectRoot "C:\Path\To\Project"
  5. Verify the result:

    .\scripts\verify-encoding.ps1 -ProjectRoot "C:\Path\To\Project"
  6. Spot-check converted files and run the project build.
  7. Commit the encoding migration separately from semantic code changes.

Embedded Firmware / Keil Workflow

For MCU firmware projects, keep the first pass narrow and build-verified:

.\scripts\convert-encoding.ps1 `
    -ProjectRoot "C:\Path\To\Firmware" `
    -FirmwareSafe `
    -WhatIf
  • Use -FirmwareSafe for an initial pass when third-party or vendor trees should remain byte-identical. It adds common embedded vendor directories such as Libraries, CMSIS, Middlewares, SEGGER, and FreeModbus to -ExcludeDirs.
  • Prefer -IncludeDirs for known application-owned folders such as src, User, FOC, App, or Core/Src.
  • Do not include Keil project files such as .uvprojx or .uvoptx unless the user explicitly asks for project-file text conversion.
  • After conversion, run the real firmware build. For Keil MDK, inspect the build log for 0 Error(s) instead of trusting only the process exit code.

Script Usage

Run the scripts from this skill folder, or copy scripts/*.ps1 into the target project if that is more convenient. If your agent exposes a skill root path, build the script path from that root:

$skillScripts = "C:\Path\To\agent-skills\encoding-converter\scripts"
& "$skillScripts\convert-encoding.ps1" -ProjectRoot "C:\Path\To\Project" -WhatIf

convert-encoding.ps1

Defaults:

ParameterDefaultNotes
-ProjectRootcurrent directoryTarget project root.
-SourceEncodingAutoAuto detects BOM, ASCII, strict UTF-8, and legacy Chinese byte patterns. Use explicit encodings for reliable mutual conversion.
-LegacyEncodingGB2312Fallback used when Auto detects legacy Chinese byte patterns. Use GBK, Big5, etc. when appropriate.
-TargetEncodingUTF-8-BOMSupports common .NET names plus aliases such as UTF-8, UTF-8-BOM, UTF-16LE, and UTF-16BE.
-ConvertAsciioffConvert ASCII-only files too. By default they are skipped.
-ScanModeAutoAuto uses git tracked files when available, otherwise filesystem scanning.
-IncludeDirsemptyOptional scan boundary. Empty means all candidate files.
-ExcludeFilesemptyAccepts either relative paths or leaf filenames.
-ExcludeDirsgeneric VCS/dependency/build dirsAvoid .git, node_modules, build output, and common binary output dirs.
-FileFiltercommon C/C++/assembly source extensionsAdd docs such as *.md or *.txt only when explicitly needed.
-FirmwareSafeoffAdd common embedded vendor directories to -ExcludeDirs.
-WhatIfoffPreview only; no writes.

Behavior:

  • Skip files already matching the requested target encoding.
  • Skip pure ASCII files unless -ConvertAscii is used.
  • Add or remove BOM according to -TargetEncoding.
  • Convert files using explicit source encoding when provided.
  • In Auto mode, detect BOM, ASCII, strict UTF-8, and legacy Chinese byte patterns using -LegacyEncoding.
  • Skip unknown non-UTF-8 files instead of guessing.
  • Return exit code 1 only when conversion errors occur.

verify-encoding.ps1

Use this after conversion and in CI-style checks.

.\scripts\verify-encoding.ps1 -ProjectRoot "C:\Path\To\Project"

It reports:

  • effective scan mode and candidate file count.
  • target-encoding files.
  • files needing conversion.
  • ASCII files skipped by default.
  • unknown/unsupported files.

It exits with code 1 when any candidate file still needs conversion or has unknown encoding.

Scan Strategy

Prefer -ScanMode Auto for open-source use:

  • In a git worktree, scan only tracked files. This avoids untracked build artifacts and dependency caches.
  • Outside git, scan the filesystem using -FileFilter, -IncludeDirs, and -ExcludeDirs.
  • Use -ScanMode Filesystem when untracked files must be included.
  • Use -ScanMode Tracked when a git-only check should fail outside a repository.

Directories are only scan boundaries. Encoding state decides whether a candidate file is converted.

Encoding Notes

Prefer explicit -SourceEncoding for non-UTF encodings that cannot be reliably auto-detected. Auto mode is intentionally conservative; it does not pretend to distinguish every possible legacy encoding.

rollback-encoding.ps1

Use this only when the conversion result should be discarded.

.\scripts\rollback-encoding.ps1 -ProjectRoot "C:\Path\To\Project" -WhatIf
.\scripts\rollback-encoding.ps1 -ProjectRoot "C:\Path\To\Project"

The rollback script reverts tracked changes matching -FileFilter from HEAD using git. It does not delete untracked files.

Safety Rules

  • Do not hand-repair already-garbled Chinese text unless the original encoding can be proven.
  • Decide the firmware vendor boundary before conversion; use -FirmwareSafe, -IncludeDirs, or explicit -ExcludeDirs when third-party code should stay byte-identical.
  • Keep encoding-only commits separate from logic, formatting, and generated-file changes.
  • For Keil MDK projects, UTF-8 with BOM is often the safest target for files containing Chinese comments.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.