xterm은 유니코드를 표시하지 않습니다

xterm은 유니코드를 표시하지 않습니다

내 터미널에 유니코드 기호를 표시할 수 없습니다. 예를 들어, 현재 OS를 사용하기 전에는 vim에서 Ctrl+A를 그리스어 mu에 매핑했는데 다른 컴퓨터에서는 작동했지만 현재 xterm에서는 작동하지 않았습니다. 나에게 관련 부분은 다음과 같습니다 .vimrc.

set encoding=utf-8
"map control-a to mu
imap <C-a> <C-k>m*

또한 다른 컴퓨터에서는 작동하지만 현재 xterm에서는 작동하지 않는 Python으로 Sympy 방정식을 출력해야 합니다. 대신에:

$ python
Python 2.7.3 (default, Mar 14 2014, 11:57:14) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sympy
>>> x = sympy.symbols('x')
>>> sympy.init_printing()
>>> (sympy.sqrt(x**3/(x+1)), 1)
⎛     _______   ⎞
⎜    ╱    3     ⎟
⎜   ╱    x      ⎟
⎜  ╱   ───── , 1⎟
⎝╲╱    x + 1    ⎠

알겠어요:

>>> (sympy.sqrt(x**3/(x+1)), 1)
n      -------   n
n     n    3     n
n    n    x      n
n   n   ───── , 1n
nnnn    x + 1    n

n실제로는 표시할 수 없을 때마다 유니코드 문자를 사용하는 것 같습니다.

나는 ~/.xinitrc파일에서 xterm을 실행하고 있습니다 ~/.Xresources. 이것은 내가 생각할 수 있는 모든 관련 정보입니다.

$ uname -a
Linux mypcname 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u3 x86_64 GNU/Linux
$ xterm -version
XTerm(278)
$ cat ~/.xinitrc 
#!/bin/bash

#update the xterm colors, font size, etc
[[ -f ~/.Xresources ]] && xrdb -merge ~/.Xresources

# run the window manager in the background first
metacity &

# get the window manager process id
wm_pid=$!

# wait a little while for the window manager to load (extend this if the xterm is not being properly maximised)
sleep 2

# run the xterm in fullscreen
#xterm +u8 -js -fullscreen &
xterm -en en_AU.UTF-8 -js -fullscreen &

# do not let the window manager become a zombie
wait $wm_pid

# this would run xterm first, then the window manager. doesn't maximise properly the first time startx is run
#xterm -fullscreen &
#exec mutter

$ cat ~/.Xresources 
! see man xterm under the resources heading for explanations
! run `xrdb -merge ~/.Xresources` after altering this file
! run `xrdb -query -all` to see the current settings

xterm.vt100.faceName: Terminus
xterm.vt100.faceSize: 14
! do not display bold fonts in bold
xterm.vt100.AllowBoldFonts: false
! display bold fonts in a different color to make them stand out
xterm.vt100.colorBDMode: true
! use green as the bold color (same as in ~/.bashrc)
xterm.vt100.colorBD: #98E34D

! cols x lines ... update with values from $(echo $COLUMNS) and $(echo $LINES)
xterm.vt100.geometry: 126x52

! dark green foreground (same as in ~/.bashrc)
*foreground: #4E9A06
! black background
*background: #000000

! scroll quickly
xterm*fastScroll: true

! enable utf-8 encoding
xterm*locale: true
xterm*utf8: 1

! flash the current line instead of making the bell sound
*visualBell: true
*visualBellLine: true

! black
*color0: #2E3436
! darkred
*color1: #CC0000
! dark green
*color2: #4E9A06
! brown
*color3: #C4A000
! darkblue
*color4: #3465A4
! darkmagenta
*color5: #75507B
! darkcyan
*color6: #06989A
! lightgrey
*color7: #D3D7CF
! darkgrey
*color8: #555753
! red
*color9: #EF2929
! green
*colorA: #8AE234
! yellow
*colorB: #FCE94F
! blue
*colorC: #729FCF
! magenta
*colorD: #AD7FA8
! cyan
*colorE: #34E2E2
! white
*colorF: #EEEEEC

$ tail -10 .bashrc
PATH=/usr/local/bin:/usr/bin:/bin:/sbin

export LC_ALL=en_AU.UTF-8
export LANG=en_AU.UTF-8
export LANGUAGE=en_AU.UTF-8

# final logon actions:

# go straight to x on login. only do this for tty1 so that we can still use the other tty consoles without starting x. also only do this when there is not already a display, otherwise the xterm will try and do this after x starts aswell
[[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]] && startx

$ locale
LANG=en_AU.UTF-8
LANGUAGE=en_AU.UTF-8
LC_CTYPE="en_AU.UTF-8"
LC_NUMERIC="en_AU.UTF-8"
LC_TIME="en_AU.UTF-8"
LC_COLLATE="en_AU.UTF-8"
LC_MONETARY="en_AU.UTF-8"
LC_MESSAGES="en_AU.UTF-8"
LC_PAPER="en_AU.UTF-8"
LC_NAME="en_AU.UTF-8"
LC_ADDRESS="en_AU.UTF-8"
LC_TELEPHONE="en_AU.UTF-8"
LC_MEASUREMENT="en_AU.UTF-8"
LC_IDENTIFICATION="en_AU.UTF-8"
LC_ALL=en_AU.UTF-8

$ printenv XTERM_LOCALE
en_AU.UTF-8

$ xrdb -query -all
*background:    #000000
*color0:    #2E3436
*color1:    #CC0000
*color2:    #4E9A06
*color3:    #C4A000
*color4:    #3465A4
*color5:    #75507B
*color6:    #06989A
*color7:    #D3D7CF
*color8:    #555753
*color9:    #EF2929
*colorA:    #8AE234
*colorB:    #FCE94F
*colorC:    #729FCF
*colorD:    #AD7FA8
*colorE:    #34E2E2
*colorF:    #EEEEEC
*foreground:    #4E9A06
*visualBell:    true
*visualBellLine:    true
xterm*fastScroll:   true
xterm*locale:   true
xterm*utf8: 1
xterm.vt100.AllowBoldFonts: false
xterm.vt100.colorBD:    #98E34D
xterm.vt100.colorBDMode:    true
xterm.vt100.faceName:   Terminus
xterm.vt100.faceSize:   14
xterm.vt100.geometry:   126x52

vim과 방정식에 그리스 기호를 표시하도록 utf-8을 얻으려면 어떻게 해야 합니까 sympy?


추가 정보 요청

$ echo $TERM
xterm
$ appres XTerm
*form.Thickness:    0
*tekMenu*tekreset*Label:    RESET
*tekMenu*tektext2*Label:    #2 Size Characters
*tekMenu*tekhide*Label: Hide Tek Window
*tekMenu*tekcopy*Label: COPY
*tekMenu*tektext3*Label:    #3 Size Characters
*tekMenu*vtshow*Label:  Show VT Window
*tekMenu*tektextsmall*Label:    Small Characters
*tekMenu*vtmode*Label:  Switch to VT Mode
*tekMenu*tektextlarge*Label:    Large Characters
*tekMenu*tekpage*Label: PAGE
*tekMenu.Label: Tek Options
*mainMenu*redraw*Label: Redraw Window
*mainMenu*sunKeyboard*Label:    VT220 Keyboard
*mainMenu*terminate*Label:  Send TERM Signal
*mainMenu*backarrow key*Label:  Backarrow Key (BS/DEL)
*mainMenu*logging*Label:    Log to File
*mainMenu*hpFunctionKeys*Label: HP Function-Keys
*mainMenu*kill*Label:   Send KILL Signal
*mainMenu*num-lock*Label:   Alt/NumLock Modifiers
*mainMenu*print-immediate*Label:    Print-All Immediately
*mainMenu*scoFunctionKeys*Label:    SCO Function-Keys
*mainMenu*quit*Label:   Quit
*mainMenu*alt-esc*Label:    Alt Sends Escape
*mainMenu*print-on-error*Label: Print-All on Error
*mainMenu*tcapFunctionKeys*Label:   Termcap Function-Keys
*mainMenu*meta-esc*Label:   Meta Sends Escape
*mainMenu*toolbar*Label:    Toolbar
*mainMenu*print*Label:  Print Window
*mainMenu*suspend*Label:    Send STOP Signal
*mainMenu*delete-is-del*Label:  Delete is DEL
*mainMenu*print-redir*Label:    Redirect to Printer
*mainMenu*fullscreen*Label: Full Screen
*mainMenu*continue*Label:   Send CONT Signal
*mainMenu*oldFunctionKeys*Label:    Old Function-Keys
*mainMenu*securekbd*Label:  Secure Keyboard
*mainMenu*interrupt*Label:  Send INT Signal
*mainMenu*8-bit control*Label:  8-Bit Controls
*mainMenu*allowsends*Label: Allow SendEvents
*mainMenu*sunFunctionKeys*Label:    Sun Function-Keys
*mainMenu*hangup*Label: Send HUP Signal
*mainMenu.Label:    Main Options
*VT100.utf8Fonts.font4: -misc-fixed-medium-r-normal--13-120-75-75-c-80-iso10646-1
*VT100.utf8Fonts.font2: -misc-fixed-medium-r-normal--8-80-75-75-c-50-iso10646-1
*VT100.utf8Fonts.font6: -misc-fixed-medium-r-normal--20-200-75-75-c-100-iso10646-1
*VT100.utf8Fonts.font5: -misc-fixed-medium-r-normal--18-120-100-100-c-90-iso10646-1
*VT100.utf8Fonts.font3: -misc-fixed-medium-r-normal--14-130-75-75-c-70-iso10646-1
*VT100.utf8Fonts.font:  -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1
*VT100.font4:   7x13
*VT100.font2:   5x7
*VT100.font6:   10x20
*VT100.font5:   9x15
*VT100.font3:   6x10
*VT100.font1:   nil2
*vtMenu*selectToClipboard*Label:    Select to Clipboard
*vtMenu*reversewrap*Label:  Enable Reverse Wraparound
*vtMenu*softreset*Label:    Do Soft Reset
*vtMenu*cursesemul*Label:   Enable Curses Emulation
*vtMenu*autolinefeed*Label: Enable Auto Linefeed
*vtMenu*hardreset*Label:    Do Full Reset
*vtMenu*visualbell*Label:   Enable Visual Bell
*vtMenu*appcursor*Label:    Enable Application Cursor Keys
*vtMenu*clearsavedlines*Label:  Reset and Clear Saved Lines
*vtMenu*bellIsUrgent*Label: Enable Bell Urgency
*vtMenu*appkeypad*Label:    Enable Application Keypad
*vtMenu*tekshow*Label:  Show Tek Window
*vtMenu*poponbell*Label:    Enable Pop on Bell
*vtMenu*scrollbar*Label:    Enable Scrollbar
*vtMenu*scrollkey*Label:    Scroll to Bottom on Key Press
*vtMenu*tekmode*Label:  Switch to Tek Mode
*vtMenu*scrollttyoutput*Label:  Scroll to Bottom on Tty Output
*vtMenu*jumpscroll*Label:   Enable Jump Scroll
*vtMenu*cursorblink*Label:  Enable Blinking Cursor
*vtMenu*vthide*Label:   Hide VT Window
*vtMenu*allow132*Label: Allow 80/132 Column Switching
*vtMenu*reversevideo*Label: Enable Reverse Video
*vtMenu*titeInhibit*Label:  Enable Alternate Screen Switching
*vtMenu*altscreen*Label:    Show Alternate Screen
*vtMenu*keepSelection*Label:    Keep Selection
*vtMenu*autowrap*Label: Enable Auto Wraparound
*vtMenu*activeicon*Label:   Enable Active Icon
*vtMenu.Label:  VT Options
*SimpleMenu*menuLabel.font: -adobe-helvetica-bold-r-normal--*-120-*-*-*-*-iso8859-*
*SimpleMenu*menuLabel.vertSpace:    100
*SimpleMenu*Sme.height: 16
*SimpleMenu*BackingStore:   NotUseful
*SimpleMenu*HorizontalMargins:  16
*SimpleMenu*Cursor: left_ptr
*SimpleMenu*borderWidth:    2
*menubar.borderWidth:   0
*tek4014*fontLarge: 9x15
*tek4014*font2: 8x13
*tek4014*font3: 6x13
*tek4014*fontSmall: 6x10
*MenuButton*borderWidth:    0
*fontMenu*render-font*Label:    TrueType Fonts
*fontMenu*fontdefault*Label:    Default
*fontMenu*font6*Label:  Huge
*fontMenu*allow-window-ops*Label:   Allow Window Ops
*fontMenu*utf8-mode*Label:  UTF-8 Encoding
*fontMenu*font1*Label:  Unreadable
*fontMenu*fontescape*Label: Escape Sequence
*fontMenu*utf8-fonts*Label: UTF-8 Fonts
*fontMenu*fontsel*Label:    Selection
*fontMenu*allow-bold-fonts*Label:   Bold Fonts
*fontMenu*utf8-title*Label: UTF-8 Titles
*fontMenu*font-linedrawing*Label:   Line-Drawing Characters
*fontMenu*font2*Label:  Tiny
*fontMenu*allow-color-ops*Label:    Allow Color Ops
*fontMenu*font-doublesize*Label:    Doublesized Characters
*fontMenu*font3*Label:  Small
*fontMenu*allow-font-ops*Label: Allow Font Ops
*fontMenu*font-loadable*Label:  VT220 Soft Fonts
*fontMenu*font4*Label:  Medium
*fontMenu*allow-tcap-ops*Label: Allow Termcap Ops
*fontMenu*font-packed*Label:    Packed Font
*fontMenu*font5*Label:  Large
*fontMenu*allow-title-ops*Label:    Allow Title Ops
*fontMenu.Label:    VT Fonts
*colorD:    #AD7FA8
*color5:    #75507B
*backarrowKeyIsErase:   true
*colorE:    #34E2E2
*color6:    #06989A
*ptyInitialErase:   true
*colorF:    #EEEEEC
*background:    #000000
*color7:    #D3D7CF
*saveLines: 1024
*color8:    #555753
*color0:    #2E3436
*foreground:    #4E9A06
*IconFont:  nil2
*color9:    #EF2929
*color1:    #CC0000
*visualBell:    true
*colorA:    #8AE234
*color2:    #4E9A06
*visualBellLine:    true
*colorB:    #FCE94F
*color3:    #C4A000
*colorC:    #729FCF
*color4:    #3465A4
$ xterm -u8 -fa "DejaVu Sans Mono"
# the following is typed in the resulting terminal:
$ echo -e "\xE2\x98\xA0"
n
# however when i copy the result from `echo -e "\xE2\x98\xA0"`
# into my browser, i get this: ☠ (a skull) but it does not show
# up as a skull in my xterm

$ lsof -p $PPID | grep fonts
xterm   5990 me  mem    REG              254,1     4971 13501810 /usr/share/fonts/X11/misc/ter-u18b_iso-8859-1.pcf.gz
xterm   5990 me  mem    REG              254,1     4897 13505403 /usr/share/fonts/X11/misc/ter-u18n_iso-8859-1.pcf.gz

나도 그것을 실행했지만 $ fc-list출력이 너무 커서 이 질문에 붙여넣을 수 없었습니다. 그래서 내가 넣었어여기

내 브라우저에 표시되는 내용:

/usr/share/fonts/truetype/freefont/FreeSansBold.ttf: FreeSans:style=Bold,получерен,negreta,tučné,fed,Fett,Έντονα,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,gros,Полужирный,Fet,Kalın,huruf tebal,жирний,Krepko,treknraksts,pusjuodis,đậm,Lodia,धृष्ट

터미널에 보이는 것:

/usr/share/fonts/truetype/freefont/FreeSansBold.ttf: FreeSans:style=Bold,nnnnnnnnn,negreta,tunné,fed,Fett,nnnnnn,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,gros,nnnnnnnnnn,Fet,Kalın,huruf tebal,nnnnnn,Krepko,treknraksts,pusjuodis,nậm,Lodia,nnn

흥미롭게도 일부 "특수" 문자가 내 터미널에 표시되지만 대부분은 차단되어 있습니다 n. 이전 출력에서 ​​볼 수 있듯이 이들 중 아무 것도 получерен표시되지 않지만 tučné마지막 문자는 표시됩니다 č. n) 로 대체됩니다 .


@apaul의 의견에 따르면 xterm이 올바른 글꼴을 로드하지 않는 것 같습니다. xterm 리소스를 로드하지 않도록 더미 클래스를 설정해 보십시오.

$ xterm -class Foo -name foo -u8 -fa "DejaVu Sans Mono:style=Book"
$ # the following commands are all executed in the resulting terminal:
$ echo -e "\xE2\x98\xA0"
$ # the above skull actually shows up now. and so does the unicode
$ # output from sympy and also vi can display greek symbols now :)

남은 것은 왜 xterm을 사용하여 글꼴을 설정할 수 없는지 알아 ~/.Xresoureces내고 작동시키는 것입니다. 뭔가 글꼴 설정을 무시해야 하는 것 같나요?

실제로 방금 터미널 글꼴을 사용하여 위 명령을 시도했는데 그게 문제인 것 같습니다.

$ xterm -class Foo -name foo -u8 -fa "Terminus"
$ # the following commands are all executed in the resulting terminal:
$ echo -e "\xE2\x98\xA0"
n

터미널이 제대로 설치되지 않았을까요? 아니면 다른 것으로 매핑될 수도 있습니다. 이것을 어떻게 발견할 수 있나요?

답변1

2016년에 작성되었으며 xterm 패치 #278(2012년 출시)에 대해 설명합니다.

xterm은 글꼴이 아닌 단일 글꼴을 사용합니다.세트다른 여러 터미널도 이를 지원합니다. 그 안에 있는 의사 그래픽 문자(xterm에서 붙여넣음):

⎛     ⎽⎽⎽⎽⎽⎽⎽   ⎞
⎜    ╱    3     ⎟
⎜   ╱    x      ⎟
⎜  ╱   ───── , 1⎟
⎝╲╱    x + 1    ⎠

아니요여기에 지정된 TypeType 글꼴로 제공:

xterm.vt100.faceName: Terminus
xterm.vt100.faceSize: 14

다른 터미널에서 글꼴이 제공된다는 점을 고려다른폰트.

xterm을 작동시키는 방법은 다음과 같습니다.

  • 필요한 모든 문자를 포함하는 글꼴을 지정하고
  • UTF-8 인코딩을 사용하도록 지시합니다.

후자는 리소스의 기본 설정 으로 locale대부분의 사용자에게 해결됩니다 . xterm은 (보통) UTF-8 인코딩을 사용합니다. 그러나 기본 동작은 VT100 호환이므로 ISO-8859-1 호환 글꼴이 사용됩니다.

  • 종점은 더 많은 글리프를 사용했지만 삭제되었습니다.멀리유니코드의 모든 의사 그래픽을 재정의할 수 있는 것은 아닙니다.
  • nU+239B, U+239C, U+239D, U+239E, U+23A0 으로 표시됩니다 .
  • 데비안 7(및 데비안 테스트)의 Terminus 버전에는 256개 미만의 문자가 있으며 n질문에 설명된 대로 정확하게 표시됩니다.

이는 (xterm이 문자 모양이 누락되었음을 알고 있음에도 불구하고) 다음과 같이 가정하여 글꼴을 사용하여 문자열을 인쇄했기 때문에 발생합니다.최대기타 글꼴) 누락된 항목은 다음과 같이 표시됩니다.공백. 이 경우 freetype 라이브러리는 다음과 같습니다.매핑유니코드 값의 하위 바이트를 Terminus에서 지원하는 범위로 변환합니다. 이는 글꼴 표시 범위 내에 정확하게 해당됩니다.n("해당 문자 없음"의 경우):

여기에 이미지 설명을 입력하세요.

빠른 수정은 uxterm다른 글꼴을 선택하고 UTF-8 인코딩이 사용되도록 하는 스크립트를 사용하는 것입니다.

추가 자료:

Terminus 글꼴은 확장된 컴퓨터 사용(하루 8시간 이상)을 위해 설계된 깔끔한 고정 너비 비트맵 글꼴입니다. 버전 4.40에는 다음이 포함되어 있습니다.1241ISO8859-1/2/5/7/9/13/15/16, Paratype-PT154/PT254, KOI8-R/U/E/F, Esperanto, 다수의 IBM, Windows 및 Macintosh 코드 페이지, IBM VGA, vt100 및 xterm 의사 문자.

위의 내용은 xterm에 관한 것입니다.패치 #2782016년이 벌써 4주년이 되었습니다. xterm의 개발은 다음을 시작으로 진행 중입니다.패치 #338(2018년 말) 트루타입 글꼴 세트를 지원합니다. 다음은 xterm을 사용한 OP 리소스 설정의 스크린샷입니다.패치 #342(#343은 "곧" 출시될 수 있습니다):

xterm #342의 스크린샷

사용-report-fonts옵션을 선택했는데 이 글꼴 파일이 로드되는 것을 확인했습니다(처리 중).굵은 이탤릭체"동일"과 동일정상, 그리고 사용두번째특수 문자용 글꼴):

    file=/usr/share/fonts/X11/misc/ter-u18n\_iso-8859-1.pcf.gz              
    file=/usr/share/fonts/X11/misc/ter-u18b\_iso-8859-1.pcf.gz              
    file=/usr/share/fonts/X11/misc/ter-u18n\_iso-8859-1.pcf.gz              
    file=/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf

실제 글꼴 수는 수행하려는 작업에 따라 다릅니다. 기존 유니코드 값 범위를 테스트할 때 수십 개의 글꼴을 사용할 수 있습니다.

답변2

댓글의 해결책:

  • uxterm
  • Ctrl마우스 오른쪽 버튼을 클릭하고(컨텍스트 메뉴) UTF-8 인코딩을 수행합니다.
  • xterm -u8
  • X 자원: 사용글꼴 크기문자 집합과 대응 필드는 다음과 같이 설정됩니다.-iso10646-1

예를 들어 xterm(X-class Xterm) 및 Terminus 글꼴의 경우 ~/.Xresources에 추가할 수 있습니다.

XTerm*font: -*-terminus-medium-r-normal--18-*-*-*-*-*-iso10646-1

시스템에 설치된 글꼴과 해당 글꼴 사양을 찾으려면 /usr/share/fonts/*/*.dir설명서를 참조하세요. 편집한 후 ~/.Xresources를 사용하여 로드합니다 xrdb -merge ~/.Xresources.

답변3

불행하게도 나도 그렇게 할 수 없었습니다 xterm. 해결 방법으로 결국 설치하게 되었는데 rxvt, 에서 할 수 있었습니다.rpmforgeEL 배포에 대해. 아직 하나 있어요유니코드-256color나에게 아주 잘 맞는 이 프로그램 버전. 다음과 같이 설명됩니다.

Name        : rxvt
Arch        : x86_64
Epoch       : 18
Version     : 2.7.10
Release     : 2.el7.rf
Size        : 326 k
Repo        : rpmforge
Summary     : Color VT102 terminal emulator for the X Window System
URL         : http://www.rxvt.org/
License     : GPL
Description : Rxvt is a color VT102 terminal emulator for the X Window System. Rxvt
            : is intended to be an xterm replacement for users who don't need the
            : more esoteric features of xterm, like Tektronix 4014 emulation,
            : session logging and toolkit style configurability. Since it does not
            : support those features, rxvt uses much less swap space than xterm
            : uses. This is a significant advantage on a machine which is serving a
            : large number of X sessions.

건축 위키피디아항상 그렇듯이 구성 및 사용 사례에 대한 유용한 정보입니다.

답변4

아래와 같은 트루타입 글꼴을 사용해 보는 것은 어떨까요? xterm을 사용하여 작동하는 표준 옵션을 얻을 수 없지만 -fn *-*-...이것은 잘 작동합니다.

xterm -fa 'Inconsolata' -fs 12

Inconsolata 글꼴을 다운로드할 수 있습니다.여기

관련 정보