CJK 語系下 CUI 在 screen 上排版錯誤

結論

.screenrc 補上設定 cjkwidth off 就好

原因

screen.c 有兩段

int main(int argc, char **argv)
{
	# ...
		char *s; 
		if ((s = locale_name())) {
			if (!strncmp(s, "zh_", 3) || !strncmp(s, "ja_", 3) || !strncmp(s, "ko_", 3)) {
				cjkwidth = 1;
			}   
		}
	# ...
}

static char *locale_name(void)                                                                                                                                                                                                                                 
{           
	static char *s;   
	
	s = getenv("LC_ALL");
	if (s == NULL)
		s = getenv("LC_CTYPE");
	if (s == NULL)
		s = getenv("LANG");
	if (s == NULL)
		s = "C";
	return s;
}

依照順序嘗試取得環境變數 LC_ALLLC_CTYPELANG ,如果值開頭為 zh_ja_ko_ 則預設 cjkwidth on,使得不確定寬度的字元會視為全寬字元,與各 CUI 繪製函式庫不合。

, , , ,

Related posts

apt 套件優先、禁用設定 (Pin)

設定檔位於 /etc/apt/preferences.d/

以下示範

Package: *
Pin: release a=stable,n=bionic
Pin-Priority: -1

表示:

Package: * 表示所有套件,也可以指定套件名稱或 glob 表示法Pin: release a=stable,n=bionic 表示僅限釋出在 stable...

容器內升級 Debian 11 後 SSH 登入變慢

於記錄 /var/log/auth.log 裡找到類似以下記錄的場合:

Failed to activate service 'org.freedesktop.login1': timed out (service_start_timeout=25000ms)

是因為 systemd-logind 無法啟動所致,可以將該服務從驗證流程中移除來解決

systemctl mask systemd-logind
pam-auth-update...

systemd-resolved 導致 docker 無法取得 DNS

解法

cd /etc
sed 's/#DNSStubListener=yes/DNSStubListener=no/' ./systemd/resolved.conf
systemctl restart systemd-resolved
rm resolv.conf
ln -s ../run/systemd/resolve/resolv.conf resolv.conf

原因分析

systemd-resolved 將 /etc/resolv.conf 改為本機地址 127.0.0.53,通過本機...

Leave a Comment

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *