🔲 Text Padding Tool
填充選項
按位元組計算時,若填充字元本身超過剩餘位元組,會寧可少填也不溢位,結果可能短於目標寬度;按字元計算時按使用者可見字元簇計數,emoji 不會被拆開。
📋 填充結果
請輸入文本...
📚 深度解析:文本填充對齊
💡 常見使用場景
- 固定寬度輸出:把不等長字串左補零或右補空格,便於對齊與排序。
- 報表與編號:訂單號補零到固定位(000123),字典序即數值序。
- 終端表格:用空格填充使列對齊。
編號補零到 6 位
輸入「123」,左補零到 6 位得「000123」;配合排序時「000123」自然小於「000999」,避免「123」排在「99」後的亂序。
❓ 常見問題(FAQ)
- 中文怎麼算寬度?
- 中文按 2 字元寬、英文 1 寬;填充對齊時若要視覺對齊需用支援 CJK 寬度的計算,否則出現錯位。
- 超出目標長度呢?
- 超長預設截斷或原樣保留(可選);補零編號建議先確認最大位數,避免截斷高位。
Formula & Standard References
| Item | Formula / Note | Source / Standard |
|---|---|---|
| Padding definition | padding appends a fill character on one or both sides up to a target width | Unicode UAX #44, character database |
| Display width | fullwidth characters occupy two columns so width based padding differs from count based | Unicode UAX #11, East Asian width |
| Fixed width alignment | tabular output aligns columns to fixed widths and overflow is left intact | W3C CSS Text Level 3, text-align |
⚠️ 使用說明與注意事項
- 本工具純前端執行,資料不會上傳到伺服器
- 建議在主流瀏覽器(Chrome/Safari/Firefox/Edge)中使用
- 計算結果僅供參考,請以實際應用場景為準