| name | officecli-cjk |
| description | CJK (Korean/Japanese/Chinese) text handling overlay for OfficeCLI. Ensures correct fonts, language tags, line-break rules, and encoding for East Asian documents. |
| metadata | {"openclaw":{"emoji":"๐ถ","requires":"officecli (>= 1.0.28)"}} |
officecli-cjk
Overlay skill for OfficeCLI that ensures correct CJK text rendering in DOCX, XLSX, and PPTX.
Use this skill when creating or modifying documents containing Korean, Japanese, or Chinese text.
Fork contract: Inside cli-jaw, use the fork-installed OfficeCLI binary for CJK/rhwp workflows.
Upstream OfficeCLI may have some CJK handling, but cli-jaw's supported contract is the fork plus
local verification. Verify the actual binary with version, capability/help output, text roundtrip,
and raw XML checks before relying on CJK font/language behavior.
Install consent contract: check command -v officecli first. If missing, do not auto-install.
Ask the user to install the supported fork from https://github.com/lidge-jun/OfficeCLI, continue
with a lightweight parent-skill fallback after stating CJK fidelity limits, or stop. If the user
chooses lightweight mode, save that preference to memory for future Office work.
When to Use
- Document contains Korean (ํ๊ธ), Japanese (ๆฅๆฌ่ช), or Chinese (ไธญๆ) text
- User requests Korean business report, Japanese presentation, or Chinese document
- Text appears garbled or fonts don't display correctly
- Line breaks occur in wrong places for CJK punctuation
CJK Font Chains
Always set East Asian fonts when adding CJK text. Each language has a primary/fallback chain:
| Language | BCP 47 Tag | Windows Primary | Windows Fallback | macOS Fallback |
|---|
| Korean | ko-KR | Malgun Gothic | ๋ง์ ๊ณ ๋ | AppleSDGothicNeo |
| Japanese | ja-JP | Yu Gothic | Meiryo | Hiragino Sans |
| Chinese (Simplified) | zh-CN | Microsoft YaHei | SimSun | PingFang SC |
| Chinese (Traditional) | zh-TW | Microsoft JhengHei | MingLiU | PingFang TC |
Cross-platform safe choice: Pretendard (Korean), Noto Sans JP (Japanese), Noto Sans SC (Chinese).
These are freely available and render well on all platforms.
DOCX Workflows
Create a Korean Document
officecli create report.docx
officecli add report.docx /body --type paragraph \
--prop text="๋ถ๊ธฐ๋ณ ๋งค์ถ ๋ณด๊ณ ์" --prop style=Heading1
officecli add report.docx /body --type paragraph \
--prop text="2026๋
1๋ถ๊ธฐ ์ค์ ์ ์์ฝํฉ๋๋ค."
officecli view report.docx text
Set CJK Font on Existing Runs
officecli set report.docx '/body/p[1]/r[1]' --prop font.name="Malgun Gothic"
officecli batch report.docx --commands '[
{"command":"set","path":"/body/p[1]/r[1]","props":{"font.name":"Malgun Gothic"}},
{"command":"set","path":"/body/p[2]/r[1]","props":{"font.name":"Malgun Gothic"}}
]'
Raw XML: East Asian Font and Language Tags
When the fork auto-detection isn't available, apply fonts and language tags via raw XML:
officecli get report.docx '/body/p[1]/r[1]' --json
officecli raw-set report.docx /document \
--xpath '//w:r[w:t[contains(.,"๋ถ๊ธฐ")]]/w:rPr' \
--action append \
--xml '<w:rFonts w:eastAsia="Malgun Gothic" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"/>'
officecli raw-set report.docx /document \
--xpath '//w:r/w:rPr' \
--action append \
--xml '<w:lang w:eastAsia="ko-KR" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"/>'
Verify CJK Tags in Raw XML
officecli raw report.docx /document | grep -E 'rFonts|w:lang'
PPTX Workflows
Create a Korean Presentation
officecli create slides.pptx
officecli add slides.pptx / --type slide
officecli add slides.pptx /slide[1] --type shape \
--prop text="ํ๊ตญ์ด ํ๋ ์ ํ
์ด์
" --prop x=1cm --prop y=1cm --prop w=8cm --prop h=1.5cm
officecli set slides.pptx '/slide[1]/shape[1]' --prop font="Malgun Gothic" --prop size=28
officecli view slides.pptx text
Japanese Slide Content
officecli add slides.pptx / --type slide
officecli add slides.pptx /slide[2] --type shape \
--prop text="ๆฅๆฌ่ชใฎใใฌใผใณใใผใทใงใณ" --prop x=1cm --prop y=1cm --prop w=8cm --prop h=1.5cm
officecli set slides.pptx '/slide[2]/shape[1]' --prop font="Yu Gothic"
XLSX Workflows
Korean Column Headers
officecli create data.xlsx
officecli set data.xlsx /Sheet1/A1 --prop value="์ ํ๋ช
"
officecli set data.xlsx /Sheet1/B1 --prop value="๋งค์ถ์ก"
officecli set data.xlsx /Sheet1/C1 --prop value="์ ๋
๋น"
officecli set data.xlsx '/Sheet1/A1:C1' --prop font.name="Malgun Gothic" --prop font.bold=true
Chinese Data Entry
officecli set data.xlsx /Sheet1/A2 --prop value="ๅฐ็ฎฑ"
officecli set data.xlsx /Sheet1/A3 --prop value="็ฉบ่ฐ"
officecli set data.xlsx '/Sheet1/A2:A3' --prop font.name="Microsoft YaHei"
Batch CJK Content (Multi-Language)
Create a document with Korean, Japanese, and Chinese sections in a single batch:
officecli create multilang.docx
officecli batch multilang.docx --commands '[
{"command":"add","path":"/body","type":"paragraph","props":{"text":"ํ๊ตญ์ด ์น์
","style":"Heading1"}},
{"command":"add","path":"/body","type":"paragraph","props":{"text":"ํ๊ตญ ์์ฅ ๋ถ์ ๋ณด๊ณ ์์
๋๋ค."}},
{"command":"add","path":"/body","type":"paragraph","props":{"text":"ๆฅๆฌ่ชใปใฏใทใงใณ","style":"Heading1"}},
{"command":"add","path":"/body","type":"paragraph","props":{"text":"ๆฅๆฌๅธๅ ดใฎๅๆใฌใใผใใงใใ"}},
{"command":"add","path":"/body","type":"paragraph","props":{"text":"ไธญๆ้จๅ","style":"Heading1"}},
{"command":"add","path":"/body","type":"paragraph","props":{"text":"่ฟๆฏไธญๅฝๅธๅบๅๆๆฅๅใ"}}
]'
officecli view multilang.docx text
officecli validate multilang.docx
Kinsoku (Line-Break Rules)
CJK text has special line-break rules called kinsoku shori (็ฆๅๅฆ็).
OfficeCLI with CjkHelper.cs handles kinsoku automatically when CJK text is detected.
Forbidden at Line Start (kinsoku: closing)
These characters must NOT appear at the beginning of a line:
! % ) , . : ; ? ] } ใ ใ ใ ใ ใ ใ ๏ผ ๏ผ ๏ผ
๏ผ
๏ผ ๏ผฝ ๏ผ ๏ผ ใผ ๏ฝ ใฃ ใ ใ
ใ ใ ใ ใ
ใ ใ
Forbidden at Line End (kinsoku: opening)
These characters must NOT appear at the end of a line:
( [ { ใ ใ ใ ใ ๏ผ ๏ผ ๏ผป
How It Works
When CjkHelper.DetectScript() identifies CJK content, the handler:
- Sets
w:kinsoku attribute on paragraph properties (DOCX)
- Applies
a:defRPr with lang attribute (PPTX)
- Ensures the rendering engine respects line-break rules
Manual Kinsoku Check
officecli raw report.docx /document | grep kinsoku
Language Tags (BCP 47)
Language tags are critical for:
- Spell-checking (right dictionary)
- Hyphenation rules
- Text-to-speech pronunciation
- CJK line-break behavior
| Language | BCP 47 | XML Element |
|---|
| Korean | ko-KR | <w:lang w:eastAsia="ko-KR"/> |
| Japanese | ja-JP | <w:lang w:eastAsia="ja-JP"/> |
| Chinese (Simplified) | zh-CN | <w:lang w:eastAsia="zh-CN"/> |
| Chinese (Traditional) | zh-TW | <w:lang w:eastAsia="zh-TW"/> |
Document-Level Language Setting
officecli raw-set report.docx /styles \
--xpath '//w:docDefaults/w:rPrDefault/w:rPr' \
--action append \
--xml '<w:lang w:eastAsia="ko-KR" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"/>'
Encoding Recovery
Symptoms of Encoding Issues
- Korean text displays as
ยพรยนรถ รรถ (EUC-KR interpreted as Latin)
- Japanese text shows
รฆโยฅรฆลยฌ (UTF-8 bytes shown as Latin)
- Square boxes
โกโกโก (missing font)
- Question marks
??? (encoding conversion failure)
Diagnosis
officecli raw document.docx /document
file document.docx
officecli raw document.docx /document | head -5
Recovery: EUC-KR โ UTF-8
If a legacy Korean document has EUC-KR encoded text embedded:
officecli view document.docx text > content_raw.txt
iconv -f EUC-KR -t UTF-8 content_raw.txt > content_utf8.txt
officecli create recovered.docx
Recovery: Shift_JIS โ UTF-8 (Japanese)
iconv -f SHIFT_JIS -t UTF-8 content_raw.txt > content_utf8.txt
Prevention
- Always create documents with officecli (guarantees UTF-8)
- When importing external text, verify encoding first with
file or chardet
- Our fork's
CjkHelper.cs always writes UTF-8 XML
CjkHelper.cs API Reference
The fork's CjkHelper.cs provides these auto-detection capabilities:
| Method | Purpose |
|---|
ContainsCjk(text) | Returns true if text has any CJK characters |
DetectScript(text) | Returns Korean, Japanese, Chinese, or None |
IsKorean(char) | Hangul syllable/jamo range detection |
IsJapanese(char) | Hiragana/Katakana range detection |
IsChinese(char) | CJK Unified Ideographs detection |
When text is added via officecli add, the fork binary calls DetectScript() and automatically:
- Sets
w:rFonts w:eastAsia to the correct font chain
- Adds
w:lang w:eastAsia with the BCP 47 tag
- Enables kinsoku processing for the paragraph
Roundtrip Verification Checklist
After creating or modifying any CJK document, verify with this sequence:
officecli view document.docx text
officecli raw document.docx /document | grep -E 'rFonts|w:lang|eastAsia'
officecli validate document.docx
officecli view slides.pptx issues --json
Pass criteria:
Quick Reference Card
| Task | Command |
|---|
| Create Korean doc | officecli create report.docx && officecli add report.docx /body --type paragraph --prop text="ํ๊ธ ํ
์คํธ" |
| Set CJK font | officecli set file.docx '/body/p[1]/r[1]' --prop font.name="Malgun Gothic" |
| Check font tags | officecli raw file.docx /document | grep rFonts |
| Check lang tags | officecli raw file.docx /document | grep w:lang |
| Validate | officecli validate file.docx |
| Multi-lang batch | officecli batch file.docx --commands '[...]' |
| PPTX CJK shape | officecli set slides.pptx '/slide[1]/shape[1]' --prop font="Malgun Gothic" |
| XLSX CJK header | officecli set data.xlsx '/Sheet1/A1:C1' --prop font.name="Malgun Gothic" |