AwesomeWM 非 ascii 字符不显示

AwesomeWM non-ascii character doesn't display

在我的 wibox 任务栏中,我有一个 wibox.widget.textbox 其文本是使用 textbox:set_text 方法设置的。

文本来自 bash 命令,其输出通过 io:popen():

接收
local fd = io.popen("sensors | grep -oP 'Physical\s+id\s+\d+:\s+\+\K[0-9.]+'")
local out = fd:read("*all")
fd:close()    
temp_widget:set_text(out)

但是,out包含一个非ascii符号:度数字符°。

而在我的任务栏中,这个字符显示为�,它本身就是一个unicode字符:U+FFFD。所以我假设 awesome 支持 unicode,那么为什么这个字符显示不正确?

编辑:另外,作为附带问题,我无法在输出中附加字符串。 IE,如果我做temp_widget:set_text(out .. "foobar"),结果和temp_widget:set_text(out)一样。那么如何追加一个字符串呢?

我认为“�”不一定是 U+FFFD,它也是一个通用替换字符,用于不在您使用的字体中的任何字符。所以问题可能只是字体支持之一。例如,如果我转到 random web page whose title contains a degree sign the browser title bar contains a degree sign. Another possibility is that since Lua strings do not have an explicit encoding,您可能必须以某种方式告诉小部件它应该为输入采用哪种编码。

至于连接字符串,你确定out没有以换行结尾,导致后面的字符串因为越界而被隐藏? grep 输出总是以换行符结尾,即使不匹配也是如此:

$ echo ab | grep -o a | xxd -pu
610a

我通过从 grep 字符串中删除度数符号并在 lua 中再次附加它来解决我的问题。所以字体不是问题,假设编码不是 unicode 的小部件也不是问题。

l0b0 虽然以新行结尾是正确的,但它解决了我的第二个问题。