Chinese World ) 種可能 個 65536 19782 理論上有 ) ( 只能使用 , 種可能 種字元 相容 control characters printable characters 256   128 來存放中文字 共 ASCII ASCII 理論上有 2 bytes 0x000x1F~ 0x200x7F~ [0x810xFE][0x40~0x7E,~ 0xA10xFE] ~ = 126 = * (6394) + 126 = *19782 157 =    使用 實際上為與 http://www.cns11643.gov.tw/web/word.jsp • • •bits 8 ( • ~ 0x7F 0x00 Big5 ASCII  編碼標準 Ref: 

Computer Center, CS, NCTU 2 – ├ ♂

(5809) ∩ (441) 。 Big5 、控制碼 (13502) 你我他的媽 朸旯朿鐰飉 : !    常用字 次常用字 符號 罕用符號 三段 • • • • • 特殊符號 使用者造字 標準字 編碼標準   

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

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

Computer Center, CS, NCTU 5 – BMP 編碼標準 and ISO10646 Unicode (2) 

Computer Center, CS, NCTU 6 16-bitUnicode 8-bit Unicode 8-bit 8-bitUnicode 字元轉成多個 字元轉成多個 字元轉成多個 4 bytes) 4 32-bit ISO10646 32-bitISO10646 – 32-bit ISO10646 32-bitISO10646 16-bitUnicode 、 將一個 將一個 將一個 ISO10646 and ISO10646 Unicode (3)    •bytes) UTF-8(1~4 • UTF-16(2 UTF: UCS Format UCS UTF: Transformation 編碼標準 

Computer Center, CS, NCTU 7 困難 困難 困難 困難 簡單 簡單 簡單 簡單 (1) 中文訊息 中文顯示 中文輸入 中文列印 中文處理 • • • • • 要做到哪些事情 中文環境 

Computer Center, CS, NCTU 8 進而提供該語言 , , 便可支援各式各樣 , , ” 的工作 聯繫到不同資料庫 “中文支援 locale 加入 的大架構下 I18N (2) 程式設計人員按照該架構的機制與準則寫程式 的語言 程式根據使用者選擇的 在 的支援 – – Locale (LOCALization Environment database) – – 套件以排山倒海之勢而來 InternationalizatioN I18N architecture Multi-language LocalizatioN L10N       國際化 中文區域化 直接修改程式 • • • 中文化方式 中文環境 

Computer Center, CS, NCTU 9 中所有字元的處理方式 locale LC_ALL > LC_* > LANG LANG >LC_ALLLC_*> : (3) 掌管該 掌管程式訊息輸出所用的語言 時間格式 數字格式 貨幣格式 字母順序與特殊字元比較 語言顯示 – – – – – – – LC_ALL LC_CTYPE LC_MESSAGES LC_TIME LC_NUMERIC LC_MONETARY LC_COLLATE LANG         效力優先性 地區性語言的資訊 • • locale 中文環境 

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

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

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

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

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

Computer Center, CS, NCTU 15 ng.ttf fireflysung.ttf" l/share/fonts/TrueType/fireflysung.ttf -r-normal--0-0-0-0-p-0-big5-0" -r-normal--0-0-0-0-p-0-gb2312.1980-0" -r-normal--0-0-0-0-p-0-jisx0208.1983-0" (3) 字型管理工具 字型格式資訊的程式 ttf TrueType – 讀取 % % ttfinfo /usr/local/share/fonts/TrueType/fireflysu  ttfm ttfm • ttfinfo 安裝 ttfm 安裝中文字型   TTFINFO_FONT_FILE="/usr/local/share/fonts/TrueType/ TTFINFO_FACE_NUM="1" TTFINFO_FACE_INDEX="0" Sung" New PL TTFINFO_FONT_NAME="AR TTFINFO_FONT_PSNAME="AR-PL-New-Sung" TTFINFO_FOUNDRY_NAME="misc" TTFINFO_WEIGHT_NAME="medium" TTFINFO_WIDTH="normal" TTFINFO_NUMCMAP="3" TTFINFO_CMAP0="0,3" Unicode,(v.2.0)" TTFINFO_CMAPNAME0="Apple TTFINFO_CMAP1="1,0" TTFINFO_CMAPNAME1="Apple,Roman" TTFINFO_CMAP2="3,1" TTFINFO_CMAPNAME2="Windows,Unicode" TTFINFO_MAPNUM="3" Sung-medium New PL TTFINFO_FONTMAP1="-misc-AR Sung-medium New PL TTFINFO_FONTMAP2="-misc-AR Sung-medium New PL TTFINFO_FONTMAP3="-misc-AR (21:38)wjguo@[oopc6:/home/wjguo] >ttfinfo (21:38)wjguo@[oopc6:/home/wjguo] /usr/loca

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

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

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

Computer Center, CS, NCTU 19 (7) fa“MingLiU” – 來看 xfd • % setenvzh_TW.Big5 LC_CTYPE • % xfd 用 安裝中文字型 

Computer Center, CS, NCTU 20 (8) ModulePath ModulePath "/usr/local/lib/xorg/modules" FontPath "/usr/local/lib/X11/fonts/misc/" FontPath "/usr/local/lib/X11/fonts/TTF/" FontPath "/usr/local/lib/X11/fonts/OTF" FontPath "/usr/local/lib/X11/fonts/Type1/" FontPath "/usr/local/lib/X11/fonts/100dpi/" FontPath "/usr/local/lib/X11/fonts/75dpi/" FontPath "/usr/local/lib/X11/fonts/TrueType/" FontPath "/usr/local/lib/X11/fonts/local/" Section Section "Files" EndSection Font Path Font •/etc/X11/xorg.conf Edit •xwindow Restart 增加 安裝中文字型 

Computer Center, CS, NCTU 21 Terminal (1) /usr/ports/chinese/rxvt-big5 I18Ncompletely /usr/ports/x11/rxvt-devel    • /usr/ports/chinese/aterm • /usr/ports/chinese/eterm • /usr/ports/x11/roxterm • /usr/ports/x11/mlterm • is removed Now, it • Before aterm eterm ROXterm mlterm rxvt     安裝中文 

Computer Center, CS, NCTU 22 color color color -color -- 0 00 -0 -- big5 big5- big5 -big5 -- *- ** -* -- p- pp -p -- *- ** -* -- 16pt 16pt 16pt 16pt *- ** -* -- 160- 160160 國喬 國喬 國喬 -160 -- *- ** -* -- *- ** -* -- 16pt, 16pt, 16pt, 16pt, 國喬 16pt, 16pt, normal normal- normal 國喬 國喬 國喬 -normal -- 您可選擇想要的字體大小 您可選擇想要的字體大小 您可選擇想要的字體大小 r- rr rxvt.font: 8x16 8x16 rxvt.font: rxvt.font: kc15f kc15f rxvt.mfont: rxvt.mfont: configuartion configuartion ports/chinese/rxvt ports/chinese/rxvt End End ! ! rxvt.troughColor: black black rxvt.troughColor: rxvt.troughColor: ! ! ! rxvt.borderColor: black black rxvt.borderColor: rxvt.borderColor: black black rxvt.background: rxvt.background: "^H" "^H" rxvt.backspacekey: rxvt.backspacekey: IndianRed IndianRed rxvt.cursorColor: rxvt.cursorColor: gray98 gray98 rxvt.foreground: rxvt.foreground: 80x24 80x24 rxvt.geometry: rxvt.geometry: xcin xcin rxvt.inputMethod: rxvt.inputMethod: yes yes rxvt.multibyte_cursor: rxvt.multibyte_cursor: big5 big5 rxvt.multichar_encoding: rxvt.multichar_encoding: OverTheSpot OverTheSpot rxvt.preeditType: rxvt.preeditType: True True rxvt.scrollTtyKeypress: rxvt.scrollTtyKeypress: False False rxvt.scrollTtyOutput: rxvt.scrollTtyOutput: True True rxvt.scrollBar_right: rxvt.scrollBar_right: xterm xterm rxvt.termName: rxvt.termName: rxvt.font: 8x16 8x16 rxvt.font: rxvt.font: kc15f kc15f rxvt.mfont: rxvt.mfont: configuartion configuartion ports/chinese/rxvt ports/chinese/rxvt End End ! ! rxvt.troughColor: black black rxvt.troughColor: rxvt.troughColor: !您可選擇想要的字體大小 !! ! ! ! 國喬 ! ! rxvt.borderColor: black black rxvt.borderColor: rxvt.borderColor: black black rxvt.background: rxvt.background: "^H" "^H" rxvt.backspacekey: rxvt.backspacekey: IndianRed IndianRed rxvt.cursorColor: rxvt.cursorColor: gray98 gray98 rxvt.foreground: rxvt.foreground: 80x24 80x24 rxvt.geometry: rxvt.geometry: xcin xcin rxvt.inputMethod: rxvt.inputMethod: yes yes rxvt.multibyte_cursor: rxvt.multibyte_cursor: big5 big5 rxvt.multichar_encoding: rxvt.multichar_encoding: OverTheSpot OverTheSpot rxvt.preeditType: rxvt.preeditType: True True rxvt.scrollTtyKeypress: rxvt.scrollTtyKeypress: False False rxvt.scrollTtyOutput: rxvt.scrollTtyOutput: True True rxvt.scrollBar_right: rxvt.scrollBar_right: xterm- xterm rxvt.termName: rxvt.termName: -r -- medium medium- medium -medium -- ar pl new sung new pl ar ar pl new sung- sung new new pl pl ar ar -ar pl new sung new pl -ar -- Terminal (2) To use AR PL New Sung AR PL use To aliasmisc aliasmisc- aliasmisc -aliasmisc -- •~/.Xdefaults Edit rxvt 安裝中文  rxvt.mfont: rxvt.mfont: rxvt.mfont: rxvt.mfont: - rxvt.mfont: rxvt.mfont:

Computer Center, CS, NCTU 23 0 00 -0 -- big5 big5- big5 -big5 -- *- ** -* -- p- pp -p -- *- ** -* -- *- ** 16pt -* -- 160- 160160 -160 -- *- ** -* -- *- ** -* -- 16pt, 國喬 16pt, normal normal- normal -normal -- r- rr -r -- aterm.font: 8x16 aterm.font: kc15f aterm.mfont: configuartion ports/chinese/aterm End ! aterm.borderColor: black aterm.borderColor: black aterm.background: "^H" aterm.backspacekey: IndianRed aterm.cursorColor: gray98 aterm.foreground: 80x24 aterm.geometry: xcin aterm.inputMethod: big5 aterm.multichar_encoding: OverTheSpot aterm.preeditType: True aterm.scrollTtyKeypress: False aterm.scrollTtyOutput: True aterm.scrollBar_right: 30 aterm.shading: xterm-color aterm.termName: True aterm.transparent: True aterm.transpscrollbar: black aterm.troughColor: !您可選擇想要的字體大小 國喬 ! medium medium- medium -medium -- ar pl new sung new pl ar ar pl new sung new pl ar ar pl new sung- new pl ar -ar pl new sung new pl -ar -- Terminal (3) To use AR PL New Sung AR PL use To aliasmisc aliasmisc- aliasmisc -aliasmisc -- •~/.Xdefaults Edit aterm 安裝中文  aterm.mfont: aterm.mfont: aterm.mfont: aterm.mfont: - aterm.mfont: aterm.mfont:

Computer Center, CS, NCTU 24 inyin,tables}) •chinese/scim-{chewing,fcitx,p (textproc/scim, scim • oxim(chinese/oxim) •(chinese/iiimf-le-xcin) xcin •(chinese/gcin) gcin Choices 安裝中文輸入程式 

Computer Center, CS, NCTU 25 (1) (csh/tcsh) (sh/bash) session & & session session & & & session session -session & & -session -- zh_TW.Big5 zh_TW.Big5 中文輸入程式 d dd -d -- % cd/usr/ports/chinese/scim ; make install clean setenv LC_CTYPE export LC_CTYPE= Edit xinitrc scim scim scim /usr/local/bin/xfce4 /usr/local/bin/xfce4 scim - scim scim /usr/local/bin/xfce4- /usr/local/bin/xfce4 scim 1. 2. 3. scim • Smart Method Common Input 安裝 

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

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

Computer Center, CS, NCTU 28 (1) click [select] click 滑鼠中間鍵貼上 滑鼠左右鍵貼上    • xlsfont •– xfontsel selector X font 顯示所有可用字型 選擇字型程式 其他設定  

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

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

Computer Center, CS, NCTU 31 /index.html http://www.cns11643.gov.tw/web/word.jsp http://netlab.cse.yzu.edu.tw/~statue/freebsd/zh-tut http://www.debian.org/doc/manuals/intro-i18n/ • • • 中文碼介紹 中文碼介紹 FreeBSD Chinese HOWTO FreeBSD Introductioni18n to 中文碼介紹 中文碼介紹 References   

Computer Center, CS, NCTU 32