Bash unicode utf-8 conversion

Converting Unicode to UTF-8 in Bash

This article introduces how to convert Unicode to UTF-8 in Bash, the Linux command line language. When PowerShell output is garbled (not strictly garbled but), piping this should help... using uni2ascii...

Shou Arisaka
1 min read
Nov 10, 2025

This article introduces how to convert Unicode to UTF-8 in Bash, the Linux command line language.

Use uni2ascii.

ruby ~/pg/ruby/dev.rb| restrictstdout | python -m json.tool
{
    "categories": "note",
    "content": "`sudo apt update && sudo apt install nodejs npm -y`",
    "date": "2019-01-17 07:30:57 +0900",
    "post": "---\nlayout: post\ntitle:  \"node.js npm \u3092ubuntu 18.04\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\"\ndate:   2019-01-17 07:30:57 +0900\ncategories: note\n---\n\n`sudo apt update && sudo apt install nodejs npm -y`\n",
    "title": "node.js npm \u3092ubuntu 18.04\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb"
}

sudo apt-get install uni2ascii

ruby ~/pg/ruby/dev.rb| restrictstdout | python -m json.tool | ascii2uni -a U -q
{
        "categories": "note",
        "content": "`sudo apt update && sudo apt install nodejs npm -y`",
        "date": "2019-01-17 07:27:43 +0900",
        "post": "---\nlayout: post\ntitle:  \"node.js npm をubuntu 18.04にインストール\"\ndate:
2019-01-17 07:27:43 +0900\ncategories: note\n---\n\n`sudo apt update && sudo apt install nodejs npm -y`\n",
        "title": "node.js npm をubuntu 18.04にインストール"
}

By the way, iconv didn’t work. I wonder why.

ruby ~/pg/ruby/dev.rb| restrictstdout | python -m json.tool | iconv -f UNICODE -t UTF-8
ⴹ㄰ㄭ‷㜰㌺㨲㜲⬠㤰〰Ⱒ †††∠潰瑳㨢∠ⴭ尭汮祡畯㩴瀠獯屴瑮瑩敬›尠渢摯⹥獪渠浰尠㍵㤰甲畢瑮⁵㠱〮尴㍵
㘰屢㍵愰尴㍵昰尳㍵戰尹㍵挰尸㍵昰屣㍵攰屢尢摮瑡㩥†㈠㄰ⴹ㄰ㄭ‷㜰㌺㨲㜲⬠㤰〰湜慣整潧楲獥›潮整湜ⴭ尭屮

When PowerShell output is garbled (not strictly garbled but), piping this might make you happy.

Share this article

Shou Arisaka Nov 10, 2025

🔗 Copy Links