Computer Center CS NCTU Ref http www cns

  • Slides: 32
Download presentation

Computer Center, CS, NCTU 編碼標準 Ref: http: //www. cns 11643. gov. tw/web/word. jsp q

Computer Center, CS, NCTU 編碼標準 Ref: http: //www. cns 11643. gov. tw/web/word. jsp q ASCII • 8 bits (理論上有 256 種可能) • 0 x 00 ~ 0 x 7 F 共 128 種字元 Ø 0 x 00 ~ 0 x 1 F control characters Ø 0 x 20 ~ 0 x 7 F printable characters q Big 5 • 使用 2 bytes 來存放中文字 (理論上有 65536 種可能) • 實際上為與 ASCII 相容, 只能使用 19782 個 Ø [0 x 81 ~ 0 x. FE][0 x 40~0 x 7 E, 0 x. A 1 ~ 0 x. FE] = 126 * (63 + 94) = 126 * 157 = 19782 2

Computer Center, CS, NCTU 4 編碼標準 – Microsoft Windows Codepage 950

Computer Center, CS, NCTU 4 編碼標準 – Microsoft Windows Codepage 950

Computer Center, CS, NCTU 編碼標準 – ISO 10646 and Unicode (1) q Goal •

Computer Center, CS, NCTU 編碼標準 – ISO 10646 and Unicode (1) q Goal • 集結全球通用字符集, 成一大聯集 • UCS Ø Universal multiple-octet coded Character Set • 4 bytes encoding Ø 128 Groups Ø 256 Planes each group Ø 256 Rows each plane Ø 256 Cells each row • BMP Ø Basic Multilingual Plane Ø 00 group, 00 plane Ø 65536 encoding space Ø UCS-2 Ø Unicode • Why in BMP 5 Ø 若所有字集都在 BMP 中, 就可以只使用 2 bytes, 否則就要用 4 bytes, 不能混用

Computer Center, CS, NCTU 6 編碼標準 – ISO 10646 and Unicode (2) q BMP

Computer Center, CS, NCTU 6 編碼標準 – ISO 10646 and Unicode (2) q BMP

Computer Center, CS, NCTU 中文環境 (4) q 設定 locale • csh/tcsh shell Ø setenv

Computer Center, CS, NCTU 中文環境 (4) q 設定 locale • csh/tcsh shell Ø setenv LC_CTYPE zh_TW. UTF-8 • Bourne Shell Ø export LC_CTYPE=zh_TW. UTF-8 • /usr/share/locale/ Ø 各國的 locale 資訊 Ø 命名規則: 語言_地區名: 字元編碼名稱 – zh_TW. UTF-8 – zh_CN. GBK 11

Computer Center, CS, NCTU 12 中文環境 (5) q 中文 Terminal (Remote Login) • M$

Computer Center, CS, NCTU 12 中文環境 (5) q 中文 Terminal (Remote Login) • M$ Windows: putty, pietty, netterm, multi-term, telnet, …etc. • X Window: xterm, rxvt, aterm, mterm, roxterm…etc. • 設定好中文支援,登入後 Ø setenv LC_CTYPE en_US. UTF-8 Ø export LC_CTYPE=en_US. UTF-8 即可看到中文 q 中文 Xwindow • 建立支援 L 10 N 中文環境 Ø 安裝中文字型 Ø 設定 Shell locale 環境 Ø 安裝 ibus 中文輸入程式 (csh/tcsh) (sh/bash) 英文,但支援 multibyte character

Computer Center, CS, NCTU 13 Steps of Exercise q 安裝中文字型 q 安裝中文 Terminal q

Computer Center, CS, NCTU 13 Steps of Exercise q 安裝中文字型 q 安裝中文 Terminal q 安裝 ibus 中文輸入程式 q 其他設定

Computer Center, CS, NCTU 14 安裝中文字型 (1) q 兩大中文字型種類 • 點陣字型 (Bitmapped Font) Ø

Computer Center, CS, NCTU 14 安裝中文字型 (1) q 兩大中文字型種類 • 點陣字型 (Bitmapped Font) Ø BDF (Bitmap Distribution Format) 點陣分散格式 Ø HBF (Hanzi Bitmap Font) 漢字點陣字體 Ø PCF (Portable Compiled Font) • 曲線描邊字型 (Outline Fonts) Ø True Type Font (TTF)

Computer Center, CS, NCTU 安裝中文字型 (2) q Font Path • % xset q •

Computer Center, CS, NCTU 安裝中文字型 (2) q Font Path • % xset q • % xset fp+ [directory] • % xset fp rehash Font Path: /usr/local/lib/X 11/fonts/misc/, /usr/local/lib/X 11/fonts/TTF/, /usr/local/lib/X 11/fonts/Type 1/, /usr/local/lib/X 11/fonts/75 dpi/, /usr/local/lib/X 11/fonts/100 dpi/, /usr/local/lib/X 11/fonts/local/ q 安裝字型步驟 • 透過 ports 安裝字型檔案 Ø 使用 ttfm 安裝該字型 Ø 使用 fc-cache 建立字型資料庫 • 修改各軟體設定使用別的字型 15

Computer Center, CS, NCTU 16 安裝中文字型 (3) q 安裝 ttfm – True. Type 字型管理

Computer Center, CS, NCTU 16 安裝中文字型 (3) q 安裝 ttfm – True. Type 字型管理 具 q ttfm • ttfinfo 讀取 ttf 字型格式資訊的程式 Ø % ttfinfo /usr/local/share/fonts/True. Type/fireflysung. ttf (21: 38)wjguo@[oopc 6: /home/wjguo] >ttfinfo /usr/local/share/fonts/True. Type/fireflysung. ttf TTFINFO_FONT_FILE="/usr/local/share/fonts/True. Type/fireflysung. ttf" TTFINFO_FACE_NUM="1" TTFINFO_FACE_INDEX="0" TTFINFO_FONT_NAME="AR PL New Sung" TTFINFO_FONT_PSNAME="AR-PL-New-Sung" TTFINFO_FOUNDRY_NAME="misc" TTFINFO_WEIGHT_NAME="medium" TTFINFO_WIDTH="normal" TTFINFO_NUMCMAP="3" TTFINFO_CMAP 0="0, 3" TTFINFO_CMAPNAME 0="Apple Unicode, (v. 2. 0)" TTFINFO_CMAP 1="1, 0" TTFINFO_CMAPNAME 1="Apple, Roman" TTFINFO_CMAP 2="3, 1" TTFINFO_CMAPNAME 2="Windows, Unicode" TTFINFO_MAPNUM="3" TTFINFO_FONTMAP 1="-misc-AR PL New Sung-medium-r-normal--0 -0 -p-0 -big 5 -0" TTFINFO_FONTMAP 2="-misc-AR PL New Sung-medium-r-normal--0 -0 -p-0 -gb 2312. 1980 -0" TTFINFO_FONTMAP 3="-misc-AR PL New Sung-medium-r-normal--0 -0 -p-0 -jisx 0208. 1983 -0"

Computer Center, CS, NCTU 17 安裝中文字型 (4) • ttfm. sh (21: 38)wjguo@[oopc 6: /home/wjguo]

Computer Center, CS, NCTU 17 安裝中文字型 (4) • ttfm. sh (21: 38)wjguo@[oopc 6: /home/wjguo] >ttfm. sh True-Type Font Manager 0. 9. 3 Usage: /usr/local/bin/ttfm. sh [option] --add [module] <file>. . . install ttf font --remove [module] <file>. . . remove ttf font from the system --list <module>. . . list all ttf fonts on the system --modules list all ttf manager modules on the system --setdefault <module> <file> set default ming font of module to file --setdefault_kai <module> <file> set default kai font of module to file --initm <module>. . initialize modules --help show this info

q 選一個來裝 … Computer Center, CS, NCTU 18 安裝中文字型 (5)

q 選一個來裝 … Computer Center, CS, NCTU 18 安裝中文字型 (5)

Computer Center, CS, NCTU 安裝中文字型 (6) q fireflyttf • % cd /usr/ports/chinese/fireflyttf • %

Computer Center, CS, NCTU 安裝中文字型 (6) q fireflyttf • % cd /usr/ports/chinese/fireflyttf • % make install clean • 透過 ports 安裝的都會自己跑 Ø % ttfm. sh --add xttfm /usr/local/share/fonts/True. Type/fireflysung. ttf Ø % fc-cache –f –v /usr/local/lib/X 11/fonts/True. Type/ • File: Ø /usr/local/share/fonts/True. Type/fireflysung. ttf Ø /usr/local/lib/X 11/fonts/True. Type/fireflysung. ttf symbolic link 19

Computer Center, CS, NCTU 20 *安裝中文字型 (7) q 用 xfd 來看 • • %

Computer Center, CS, NCTU 20 *安裝中文字型 (7) q 用 xfd 來看 • • % setenv LC_CTYPE zh_TW. Big 5 % xfd –fa “Ming. Li. U”

Computer Center, CS, NCTU 21 安裝中文字型 (8) q 增加 Font Path • Edit /etc/X

Computer Center, CS, NCTU 21 安裝中文字型 (8) q 增加 Font Path • Edit /etc/X 11/xorg. conf • Restart xwindow Section "Files" Module. Path "/usr/local/lib/xorg/modules" Font. Path "/usr/local/lib/X 11/fonts/misc/" Font. Path "/usr/local/lib/X 11/fonts/TTF/" Font. Path "/usr/local/lib/X 11/fonts/OTF" Font. Path "/usr/local/lib/X 11/fonts/Type 1/" Font. Path "/usr/local/lib/X 11/fonts/100 dpi/" Font. Path "/usr/local/lib/X 11/fonts/75 dpi/" Font. Path "/usr/local/lib/X 11/fonts/True. Type/" Font. Path "/usr/local/lib/X 11/fonts/local/" End. Section

Computer Center, CS, NCTU 安裝中文 Terminal (1) q rxvt • Before Ø /usr/ports/chinese/rxvt-big 5

Computer Center, CS, NCTU 安裝中文 Terminal (1) q rxvt • Before Ø /usr/ports/chinese/rxvt-big 5 • Now, it is removed Ø I 18 N completely Ø /usr/ports/x 11/rxvt-unicode q aterm • /usr/ports/chinese/aterm q eterm • /usr/ports/chinese/eterm q ROXterm • /usr/ports/x 11/roxterm q mlterm • /usr/ports/x 11/mlterm 22

Computer Center, CS, NCTU 安裝中文 Terminal (2) q urxvt • Edit ~/. Xdefaults To

Computer Center, CS, NCTU 安裝中文 Terminal (2) q urxvt • Edit ~/. Xdefaults To use AR PL New Sung 23 rxvt. mfont: rxvt. border. Color: black rxvt. background: black rxvt. backspacekey: "^H" rxvt. cursor. Color: Indian. Red rxvt. foreground: gray 98 rxvt. geometry: 80 x 24 rxvt. input. Method: xcin rxvt. multibyte_cursor: yes rxvt. multichar_encoding: big 5 rxvt. preedit. Type: Over. The. Spot rxvt. scroll. Tty. Keypress: True rxvt. scroll. Tty. Output: False rxvt. scroll. Bar_right: True rxvt. term. Name: xterm-color rxvt. trough. Color: black !您可選擇想要的字體大小 ! 國喬 16 pt, 國喬 16 pt rxvt. font: 8 x 16 rxvt. mfont: kc 15 f ! End ports/chinese/rxvt configuartion -aliasmisc-ar pl new sung-medium-r-normal-*-*-160 -*-*-p-*-big 5 -0

Computer Center, CS, NCTU 安裝中文 Terminal (3) q aterm • Edit ~/. Xdefaults To

Computer Center, CS, NCTU 安裝中文 Terminal (3) q aterm • Edit ~/. Xdefaults To use AR PL New Sung 24 aterm. mfont: aterm. border. Color: black aterm. background: black aterm. backspacekey: "^H" aterm. cursor. Color: Indian. Red aterm. foreground: gray 98 aterm. geometry: 80 x 24 aterm. input. Method: xcin aterm. multichar_encoding: big 5 aterm. preedit. Type: Over. The. Spot aterm. scroll. Tty. Keypress: True aterm. scroll. Tty. Output: False aterm. scroll. Bar_right: True aterm. shading: 30 aterm. Name: xterm-color aterm. transparent: True aterm. transpscrollbar: True aterm. trough. Color: black !您可選擇想要的字體大小 ! 國喬 16 pt, 國喬 16 pt aterm. font: 8 x 16 aterm. mfont: kc 15 f ! End ports/chinese/aterm configuartion -aliasmisc-ar pl new sung-medium-r-normal-*-*-160 -*-*-p-*-big 5 -0

Computer Center, CS, NCTU 25 安裝中文輸入程式 q Choices • ibus-chewing(chinese/ibus-chewing) • ibus-pinyin(chinese/ibus-pinyin)

Computer Center, CS, NCTU 25 安裝中文輸入程式 q Choices • ibus-chewing(chinese/ibus-chewing) • ibus-pinyin(chinese/ibus-pinyin)

Computer Center, CS, NCTU 安裝 ibus 中文輸入程式 (1) q ibus • Intelligent Input Bus

Computer Center, CS, NCTU 安裝 ibus 中文輸入程式 (1) q ibus • Intelligent Input Bus 1. 2. 3. % cd /usr/ports/textproc/ibus-chewing ; make install clean setenv LC_CTYPE zh_TW. UTF-8 (csh/tcsh) export LC_CTYPE=zh_TW. UTF-8 (sh/bash) Edit. xinitrc (或是可以 setenv in. cshrc/. bashrc) XIM=ibus GTK_IM_MODULE=ibus QT_IM_MODULE=xim XMODIFIERS='@im=ibus' XIM_PROGRAM="ibus-daemon" XIM_ARGS="--daemonize --xim" 26

Computer Center, CS, NCTU 27 安裝 ibus中文輸入程式 (2) 4. Switch to chinese input: Ctrl

Computer Center, CS, NCTU 27 安裝 ibus中文輸入程式 (2) 4. Switch to chinese input: Ctrl -Space

Computer Center, CS, NCTU 28 安裝 ibus 中文輸入程式 (3) q 調成自己要的樣子 • % ibus-setup

Computer Center, CS, NCTU 28 安裝 ibus 中文輸入程式 (3) q 調成自己要的樣子 • % ibus-setup (UTF-8)

Computer Center, CS, NCTU 30 其他設定 (2) q 安裝 zh-auto-tw-l 10 n • •

Computer Center, CS, NCTU 30 其他設定 (2) q 安裝 zh-auto-tw-l 10 n • • # cd /usr/ports/chinese/auto-tw-l 10 n/ # make install clean # cd /usr/local/share/skel/zh_TW. Big 5/ # ls (21: 57)wjguo@[oopc 6: /usr/local/share/skel/zh_TW. Big 5] >ls MANIFEST dot. cshrc dot. gtkrc dot. vimrc dot. Xdefaults dot. emacs dot. inputrc dot. xinitrc dot. bashrc dot. fonts. conf dot. muttrc make. conf

Computer Center, CS, NCTU 31 其他設定 (3) q 設定適合的 Locale(in X window) • en_US.

Computer Center, CS, NCTU 31 其他設定 (3) q 設定適合的 Locale(in X window) • en_US. ISO 8859 -1 vs. zh_TW. Big 5(zh_TW. UTF-8) • edit /etc/csh. cshrc (or ~/. cshrc) if ( $MY_TTY == cons || $MY_TTY == ttyv ) then setenv LC_CTYPE zh_TW. Big 5 else setenv LC_CTYPE en_US. ISO 8859 -1 endif

Computer Center, CS, NCTU 32 References q 中文碼介紹 • http: //www. cns 11643. gov.

Computer Center, CS, NCTU 32 References q 中文碼介紹 • http: //www. cns 11643. gov. tw/web/word. jsp q Free. BSD Chinese HOWTO • http: //netlab. cse. yzu. edu. tw/~statue/freebsd/zh-tut/index. html q Introduction to i 18 n • http: //www. debian. org/doc/manuals/intro-i 18 n/