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_ALL、LC_CTYPE、LANG ,如果值開頭為 zh_、ja_、ko_ 則預設 cjkwidth on,使得不確定寬度的字元會視為全寬字元,與各 CUI 繪製函式庫不合。
Leave a Comment