简体   繁体   English

ncurses A_ALTCHARSET字符未在OSX上显示

[英]ncurses A_ALTCHARSET characters not displaying on OSX

I am using ncurses in a c++ program and want to be able to use A_ALTCHARSET characters. 我在c ++程序中使用ncurses,并且希望能够使用A_ALTCHARSET字符。 On my linux computer it was working fine but then when I tried it on my Mac several characters showed up as '?'. 在我的linux计算机上,它工作正常,但是当我在Mac上尝试使用时,几个字符显示为'?'。 As a test I ran the second program from this website on both of my computers. 作为测试,我在两台计算机上都从该网站运行了第二个程序。 On my linux computer it showed all the characters correctly and showed the same thing as the picture on the website but on my mac I got: 在我的linux计算机上,它正确显示了所有字符,并显示了与网站上的图片相同的内容,但是在我的mac上,我得到了:

                                NCURSES ALTCHARSET CHARACTERS
     43 = > │  44 = < │  45 = ^ │  46 = v │  48 = # │  96 = ◆ │  97 = ▒ │ 102 = °
    103 = ± │ 104 = # │ 105 = ␋ │ 106 = ┘ │ 107 = ┐ │ 108 = ┌ │ 109 = └ │ 110 = ┼
    111 = ⎺ │ 112 = ⎻ │ 113 = ─ │ 114 = ⎼ │ 115 = ⎽ │ 116 = ├ │ 117 = ┤ │ 118 = ┴
    119 = ┬ │ 120 = │ │ 121 = ≤ │ 122 = ≥ │ 123 = π │ 124 = ≠ │ 125 = £ │ 126 = ·
    128 = ? │ 161 = ? │ 162 = ? │ 163 = ? │ 164 = ? │ 165 = ? │ 166 = ? │ 167 = ?
    168 = ? │ 169 = ? │ 170 = ? │ 171 = ? │ 172 = ? │ 174 = ? │ 175 = ? │ 176 = ?
    177 = ? │ 178 = ? │ 179 = ? │ 180 = ? │ 181 = ? │ 182 = ? │ 183 = ? │ 184 = ?
    185 = ? │ 186 = ? │ 187 = ? │ 188 = ? │ 189 = ? │ 190 = ? │ 191 = ? │ 192 = ?
    193 = ? │ 194 = ? │ 195 = ? │ 196 = ? │ 197 = ? │ 198 = ? │ 199 = ? │ 200 = ?
    201 = ? │ 202 = ? │ 203 = ? │ 204 = ? │ 205 = ? │ 206 = ? │ 207 = ? │ 208 = ?
    209 = ? │ 210 = ? │ 211 = ? │ 212 = ? │ 213 = ? │ 214 = ? │ 215 = ? │ 216 = ?
    217 = ? │ 218 = ? │ 219 = ? │ 220 = ? │ 221 = ? │ 222 = ? │ 223 = ? │ 224 = ?
    225 = ? │ 226 = ? │ 227 = ? │ 228 = ? │ 229 = ? │ 230 = ? │ 231 = ? │ 232 = ?
    233 = ? │ 234 = ? │ 235 = ? │ 236 = ? │ 237 = ? │ 238 = ? │ 239 = ? │ 240 = ?
    241 = ? │ 242 = ? │ 243 = ? │ 244 = ? │ 245 = ? │ 246 = ? │ 247 = ? │ 248 = ?
    249 = ? │ 250 = ? │ 251 = ? │ 252 = ? │ 253 = ? │ 254 = ? │ 255 = ? │ 

Why isn't this working and is there a away to fix it? 为什么这不起作用,还有解决的办法吗?

That looks as if you did something like setting TERM to linux . 好像您做了类似将TERM设置为linux The Linux console provides a non-VT100 method for drawing line-graphics (essentially using codes from 160-255). Linux控制台提供了一种非VT100的方法来绘制线形图(基本上使用160-255之间的代码)。 OSX Terminal implements a VT100-style line-graphics, which requires switching character-sets. OSX Terminal实现了VT100样式的线形图,这需要切换字符集。 As shown in the screenshot, linux is not one of the settings that you might make with Terminal's preferences. 如屏幕截图所示, linux不是您可以通过Terminal的首选项进行的设置之一。 However it's not unusual for people to set the variable in their .bashrc , etc.: 但是人们在他们的.bashrc等中设置变量并不罕见:

显示Apple假定的可用terminfo条目

The terminal description (selected by the TERM environment variable) is different in this area. 在此区域中,终端说明(由TERM环境变量选择)不同。 The recommended TERM for OSX Terminal is one of the nsterm flavors in ncurses. OSX终端推荐的TERM是ncurses中的nsterm风味之一。 Comparing: 比较:

$ infocmp linux nsterm |grep acs
        acsc: '+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260i\316j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330}\234~\376', '``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~'.
        enacs: NULL, '\E(B\E)0'.
        rmacs: '\E[10m', '^O'.
        smacs: '\E[11m', '^N'.

The smacs and rmacs strings in the VT100-style capabilities are called shift-in and shift-out (for the normal and graphics). VT100风格的功能中的smacsrmacs字符串称为移入移出 (对于普通和图形)。 As you may see, they're not like the Linux capabilities. 如您所见,它们不像Linux功能。

Further reading: 进一步阅读:

The feature to look for is the value of TERM which your program is using in the shell. 要寻找的功能是您的程序在Shell中使用的TERM的值。 OSX Terminal only has one possible behavior (none match "linux"). OSX Terminal只有一种可能的行为(没有匹配的“ linux”)。 The program does have a Preferences dialog which sets TERM , although your shell may explictly set it to some other value. 该程序确实有一个设置TERMPreferences对话框,尽管您的shell可能会明确将其设置为其他值。 For instance, the terminal database notes that 例如,终端数据库指出

# * The terminal preferences dialog replaces xterm-color by xterm-16color and
#   xterm-256color.  However, it adds "nsterm", so it is possible to use the
#   nsterm entry from this file to override the MacPorts (20110404) or
#   system (20081102) copy of this file.
# + In OS X 10.8 (Mountain Lion) the TERM which can be set in the preferences
#   dialog defaults to xterm-256color.  Alternative selections are ansi,
#   dtterm, rxvt, vt52, vt100, vt102, xterm and xterm-16color.  However,
#   the menu says "Declare terminal as" without promising to actually emulate
#   the corresponding terminals.  Indeed, changing TERM does not affect the

The above was written in February 2016. Development of ncurses and Linux is ongoing. 以上内容写于2016年2月。ncurses和Linux的开发正在进行中。 In May 2016 this change was made to ncurses' terminal database: 20165月 ,对ncurses的终端数据库进行了更改:

# 2016-05-14
#       + modify linux2.6 entry to improve line-drawing -TD
#       + make linux3.0 entry the default linux entry (Debian #823658) -TD

That made the standard linux terminal description look more like nsterm in this area. 这使得标准linux终端描述在该领域看起来更像nsterm If you were running infocmp on an up-to-date system, you would not see the difference shown. 如果您在最新的系统上运行infocmp ,则看不到显示的差异。 Apple, however, does not update ncurses that rapidly. 但是,Apple不会迅速更新ncurses。 The linux2.2 terminal description is what one would be using in the context of the original question. 在原始问题的上下文中,将使用linux2.2终端描述。 Here's a screenshot showing the ncurses test-program with that terminal description: 这是一个屏幕快照,显示了带有该终端说明的ncurses测试程序:

使用Terminal.app的问题的示例

Now... Apple may have caught up with Mohave, but there have been no credible test-results from that yet. 现在……苹果可能已经赶上了Mohave,但是至今还没有可靠的测试结果。 With High Sierra, Apple's terminal description for linux still uses the older version of graphics characters as shown in this screenshot: 对于High Sierra,Apple的linux终端说明仍然使用旧版本的图形字符,如以下屏幕截图所示:

High Sierra中的linux终端说明

Now... if you were using MacPorts or brew, the result would be different: 现在...如果您使用的是MacPorts或brew,结果将有所不同:

  • the terminal database added by those is newer, and 这些人添加的终端数据库较新,并且
  • one of the features in the newer database is that the linux terminal description uses the U8 extension , which tells ncurses to assume it should use UTF-8 when the locale encoding is UTF-8. 较新数据库中的功能之一是linux终端描述使用U8扩展名 ,该扩展名告诉ncurses假定在区域设置编码为UTF-8时应使用UTF-8。 If you had that situation, you would not see the original problem. 如果遇到这种情况,您将看不到原始问题。

In terminal, go to "Preferences", then "Profiles", and click on the "Advanced" tab. 在终端中,转到“首选项”,然后转到“配置文件”,然后单击“高级”选项卡。 In advanced, select the dropdown menu of Text Encodings and select Western (Mac OS Roman). 在高级菜单中,选择文本编码的下拉菜单,然后选择西方(Mac OS Roman)。 I'm sure other encodings have the characters you're missing - but that one worked for me. 我确定其他编码都有您所缺少的字符-但这对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM