# Document Gen Unicode Safe

Unicode-safe fallback workflow for multi-format document generation with character...

- Repository: https://github.com/HKUDS/AgentPilot (7784 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add HKUDS/AgentPilot --skill document-gen-unicode-safe -g -a claude-code -y`
Codex: `npx skills add HKUDS/AgentPilot --skill document-gen-unicode-safe -g -a codex -y`
Cursor: `npx skills add HKUDS/AgentPilot --skill document-gen-unicode-safe -g -a cursor -y`
Gemini CLI: `npx skills add HKUDS/AgentPilot --skill document-gen-unicode-safe -g -a gemini-cli -y`

## Description

Unicode-safe fallback workflow for multi-format document generation with character sanitization and explicit error capture

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Document Generation Fallback Workflow (Unicode-Safe)

## When to Use

Use this skill when `shell_agent` returns unknown or unclear errors on complex document generation tasks, especially when:
- Generating documents in multiple formats (e.g., `.docx`, `.pdf`, `.html`)
- The error message doesn't provide clear debugging information
- You need to handle special characters, symbols, or non-ASCII text safely
- PDF generation fails due to LaTeX encoding issues

## Core Technique

Instead of delegating the entire document generation to `shell_agent`, manually split the workflow into discrete, observable steps:
1. **Content creation** → Use `write_file` to create source document (Markdown)
2. **Unicode sanitization** → Preprocess markdown to replace problematic characters before PDF conversion
3. **Format conversion with stderr capture** → Use `run_shell` with `pandoc` for each target format, capturing full stderr output
4. **Verification** → Check output files exist and are valid

## ⚠️ Unicode & LaTeX Compatibility Warning

**Critical**: PDF generation via pandoc typically uses LaTeX (`pdflatex` or `xelatex`), which has limited Unicode support. Common problematic characters include:

| Character | Issue | Safe Replacement |
|-----------|-------|------------------|
| `, ` (em dash) | May not render | `--` or `-` |
| `, ` (en dash) | May not render | `-` |
| `" "` (curly quotes) | Encoding errors | `" "` (straight quotes) |
| `' '` (curly apostrophe) | Encoding errors | `'` (straight apostrophe) |
| `…` (ellipsis) | May not render | `...` |
| `→` `←` `↑` `↓` (arrows) | LaTeX incompatibility | `->` `<-` `^` `v` |
| `✓` `✗` (checkmarks) | May not render | `[x]` `[ ]` |
| `★` `●` (symbols) | May not render | `*` `-` |
| `©` `®` `™` | May require packages | `(c)` `(r)` `(tm)` |
| Non-ASCII letters (é, ñ, ü) | Font-dependent | Use xeLaTeX or replace |

## Step-by-Step Workflow

### Step 1: Create Source Content with write_file

The rest: https://github.com/HKUDS/AgentPilot/blob/HEAD/openspace/benchmarks/gdpval/skills/document-gen-fallback-enhanced/SKILL.md
