Presentation is loading. Please wait.

Presentation is loading. Please wait.

中文世界 Ensky.

Similar presentations


Presentation on theme: "中文世界 Ensky."— Presentation transcript:

1 中文世界 Ensky

2 編碼標準 電腦是老外發明的 我們也要用電腦顯示中文 ref: 五大中文套裝軟體為「文書處理」、「資料庫」、 「試算表」、「通訊」及「繪圖」
只有a-z A-Z 0-9 我們也要用電腦顯示中文 所以我們就自己設計了一套編碼系統,叫Big5 是「台灣財團法人資訊工業策進會」在1983年 為「五大中文套裝軟體」設計的編碼系統 原本的五大中文套裝軟體沒有成功推廣, 卻意料外的讓Big5普及於世 ref: 五大中文套裝軟體為「文書處理」、「資料庫」、 「試算表」、「通訊」及「繪圖」

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

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

5 Big5的問題 腦包使用者造字區 缺字 延伸版本繁雜 許功蓋 (\) 每個人都可以自己造字 於是自己造的字放到別人電腦上就看不到
堃、煊、栢、喆 延伸版本繁雜 倚天Big5延伸 Code Page 950 Big5+ Big-5E Big5-2003 許功蓋 (\)

6 編碼標準 - Unicode 全世界共有一百多種文字,因此也有很多種不同的編碼系統。 日本有JIS,中國有GB 2312,…
同樣的編碼在不同的編碼系統下顯示會不同 因此Unicode組織就誕生了

7 Unicode VS ISO 10646 1991年左右,同時有兩個組織著手規範世界字碼
過不了多久,他們就互相體認到 「這個世界不需要兩套不同的單一字符集」 因此他們決定共用同樣的字碼 現在這兩個組織各自存在,各自互相砥礪 ref:

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

9 編碼標準 – ISO10646 and Unicode (2)
BMP

10 Unicode 的問題 Big-Endian & Little Endian 空間浪費 U+4E59?(乙) U+594E?(奎)
ASCII字元用2byte記? 0x00 0x41 「A」 第一位永遠是0

11 Unicode Transformation Format
UTF: UCS/Unicode Transformation Format UTF-16(2、4 bytes) 將一個 32-bit ISO10646 字元轉成多個 16-bit Unicode UTF-8(1~4 bytes) 將一個32-bit ISO10646 字元轉成多個 8-bit Unicode 將一個16-bit Unicode 字元轉成多個 8-bit Unicode 128個US-ASCII字元只需1 bytes編碼 帶有附加符號的拉丁文、希臘文、西里爾字母、亞美尼亞語、希伯來文、阿拉伯文、敘利亞文及它拿字母則需要2 bytes編碼 其他基本多文種平面(BMP)中的字元 (這包含了大部分常用字)使用3 bytes編碼。 其他極少使用的Unicode 輔助平面的字元使用4 bytes編碼。

12 中文環境 (1) 要做到哪些事情 中文訊息 中文顯示 中文輸入 中文列印 中文處理 簡單 困難

13 中文環境 (2) 中文化方式 直接修改程式 18 chars 國際化(InternationalizatioN,i18n)
套件以排山倒海之勢而來 18 chars 國際化(InternationalizatioN,i18n) Multi-language architecture 程式設計人員按照該架構的機制與準則寫程式, 便可支援各式各樣的語言 Locale (LOCALization Environment database) 程式根據使用者選擇的 locale 聯繫到不同資料庫, 進而提供該語言的支援 在地化(LocalizatioN,L10n) 在 i18n 的大架構下,加入「在地化」的特性 通常i18n只需做一次,而L10n要針對每個語言個別做

14 i18n & L10n i18n + L10n L10n only 語言 文化 書寫習慣 翻譯 道德在地化 內容在地化 文化價值、社會環境
名字和稱謂的位置 電話號碼、位址和國際郵遞區號的格式 貨幣 度量衡 書寫習慣 日期時間 時區 數字格式 L10n only 翻譯 道德在地化 內容在地化 文化價值、社會環境

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

16 中文環境 (4) 設定 locale csh/tcsh shell Bourne Shell
setenv LC_CTYPE en_US.UTF-8 Bourne Shell export LC_CTYPE=en_US.UTF-8 Note: 或者是你可以寫在.tcshrc中讓他登入後自動執行 /usr/share/locale/ 各國的 locale 資訊 命名規則: 語言_地區名:字元編碼名稱 zh_TW.UTF-8 zh_CN.GBK

17 英文,但支援multibyte character
中文環境 (5) 中文 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 (csh/tcsh) export LC_CTYPE=en_US.UTF-8 (sh/bash) 即可看到中文 中文 Xwindow 建立支援 L10n 中文環境 安裝中文字型 設定 Shell locale 環境 安裝 ibus 中文輸入程式 英文,但支援multibyte character

18 中文世界 Exercise hwchiu

19 Steps of Exercise 安裝中文字型 安裝中文 Terminal 安裝 ibus 中文輸入程式 其他設定

20 中文字型 兩大中文字型種類 點陣字型 (Bitmapped Font) 曲線描邊字型 (Outline Fonts)
BDF (Bitmap Distribution Format) 點陣分散格式 HBF (Hanzi Bitmap Font) 漢字點陣字體 PCF (Portable Compiled Font) 曲線描邊字型 (Outline Fonts) True Type Font (TTF) 點陣(黑白)=>放大鋸齒,記憶體大 曲線=>數學運算=>放大縮小都完美

21 安裝中文字型 (2) Font Path 安裝字型 % xset q % xset fp+ [directory]
/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/ Font Path % xset q % xset fp+ [directory] % xset fp rehash 安裝字型 直接從Windows下複製過去 / 透過 ports 安裝字型檔案 使用 ttfm 安裝該字型 使用 fc-cache 建立字型資料庫 修改各軟體設定使用別的字型

22 安裝中文字型 (3) 安裝 ttfm – TrueType 字型管理工具 ttfm ttfinfo 讀取 ttf 字型格式資訊的程式
% ttfinfo /usr/local/share/fonts/TrueType/fireflysung.ttf >ttfinfo /usr/local/share/fonts/TrueType/fireflysung.ttf TTFINFO_FONT_FILE="/usr/local/share/fonts/TrueType/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_CMAP0="0,3" TTFINFO_CMAPNAME0="Apple Unicode,(v.2.0)" TTFINFO_CMAP1="1,0" TTFINFO_CMAPNAME1="Apple,Roman" TTFINFO_CMAP2="3,1" TTFINFO_CMAPNAME2="Windows,Unicode" TTFINFO_MAPNUM="3" TTFINFO_FONTMAP1="-misc-AR PL New Sung-medium-r-normal p-0-big5-0" TTFINFO_FONTMAP2="-misc-AR PL New Sung-medium-r-normal p-0-gb " TTFINFO_FONTMAP3="-misc-AR PL New Sung-medium-r-normal p-0-jisx "

23 安裝中文字型 (4) ttfm.sh (21:38)wjguo@[oopc6:/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

24 安裝中文字型 (5) 選一個來裝 …

25 安裝中文字型 (6) fireflyttf 透過 ports 安裝的都會自己跑 portmaster chinese/fireflyttf
% ttfm.sh --add xttfm /usr/local/share/fonts/TrueType/fireflysung.ttf % fc-cache –f –v /usr/local/lib/X11/fonts/TrueType/ portmaster chinese/fireflyttf –f –v --force --verbose

26 *安裝中文字型 (7) 用 xfd 來看 % setenv LC_CTYPE zh_TW.Big5 % xfd –fa “MingLiU”
man xfd

27 安裝中文字型 (8) 增加 Font Path Edit /etc/X11/xorg.conf /usr/local/share/fonts/TrueType/fireflysung.ttf /usr/local/lib/X11/fonts/TrueType/fireflysung.ttf Restart xwindow symbolic link Section "Files" 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/" EndSection

28 安裝中文 Terminal rxvt aterm eterm ROXterm mlterm
/usr/ports/x11/rxvt-unicode aterm /usr/ports/chinese/aterm eterm /usr/ports/chinese/eterm ROXterm /usr/ports/x11/roxterm mlterm /usr/ports/x11/mlterm xlsfonts

29 ROXterm X11/roxterm roxterm-config xlsfonts

30 安裝中文輸入程式 Choices ibus-chewing(chinese/ibus-chewing)
ibus-pinyin(chinese/ibus-pinyin)

31 安裝 ibus 中文輸入程式 (1) ibus Intelligent Input Bus
% 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 XIM_PROGRAM="ibus-daemon" XIM_ARGS="--daemonize --xim"

32 安裝 ibus中文輸入程式 (2) Switch to chinese input: Ctrl -Space

33 安裝 ibus 中文輸入程式 (3) 調成自己要的樣子 % ibus-setup (UTF-8)

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

35 其他設定 (2) 安裝 zh-auto-tw-l10n # cd /usr/ports/chinese/auto-tw-l10n/
# make install clean # cd /usr/local/share/skel/zh_TW.Big5/ # ls >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

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

37 References 中文碼介紹 FreeBSD Chinese HOWTO Introduction to i18n
FreeBSD Chinese HOWTO Introduction to i18n


Download ppt "中文世界 Ensky."

Similar presentations


Ads by Google