MozTW 討論區 https://forum.moztw.org/ |
|
關於CSS3 lists的CJK list-type-style https://forum.moztw.org/viewtopic.php?f=13&t=3043 |
第 1 頁 (共 1 頁) |
發表人: | BuriBuri [ 2004-09-14, 04:15 ] |
文章主題 : | 關於CSS3 lists的CJK list-type-style |
前幾天在w3c的網站閒逛的時候,無意間看到CSS3-lists的Working Draft,發現中文數字已經被加入list-style-type裡面了(真是太好了,我已經等好久了),但不幸的是,我也在裡面看到許多的bug,在這裡簡單跟大家報告一下 CJK世界裡面常用的計數系統,有大,小寫數字,天干,地支,數字系統比較複雜,除了數字當中夾雜著單位量詞(130460 -> 十三萬零四百六十),而且還有各種不同的寫法(大,小寫;簡,繁體,日文),所以CSS3裡面也分成兩個部分定義 1. cjk-ideographic algorithm (先轉換成CJK數字的格式) 2. cjk numbering system's table (再轉換成不同文字的寫法) 首先說一下我認為有哪些問題 1. cjk-ideographic algorithm內容有誤 2. 大,小寫的cjk-ideographic algorithm應該不同(目前都是用同一套演算法) 3. suffix跟我們的使用習慣不合,而且搭配起來有點難看 @_@ 4. cjk numbering system's table的內容寫錯了 1. cjk-ideographic algorithm內容有誤 下面是CSS3對cjk-ideographic algorithm的說明: 引言回覆: The cjk-ideographic algorithm is used by several numbering systems, using different sets of digits. These systems are defined for numbers greater than or equal to 0 and less than 1016. Numbers less than zero or equal to or greater than 1016 should use the decimal system. The core algorithm is as follows:
1. Split the decimal number into groups of four digits, starting with the least significant digit. 2. Ignoring groups that have the value zero, append the second group marker to the second group, the third group marker to the third group, and the fourth group marker to the fourth group. These markers are defined in the tables for the specific numbering systems. The first group has no marker. 3. For each group, ignoring digits that have the value zero, append the second digit marker to the second digit, the third digit marker to the third digit, and the fourth digit marker to the fourth digit. These markers are defined in the tables for the specific numbering systems. The first digit has no marker. 4. For any group with a value less than 20, remove the second digit (the 1 in the tens column). Leave any associated markers. 5. Concatenate the groups back into a single string, least significant group last. 6. Collapse any consecutive runs of 0 digits to a single 0. 7. Replace each digit with the relevant character selected from the numbering system's table. The suffix for the cjk-ideographic numbering systems is a dot . U+002E. Is there a better suffix to use? If specified explicitly, the cjk-ideograph keyword should be handled like trad-chinese-informal. 那我們就按照他的步驟實際轉換一次看看吧,假設現在有一個數字1035000030050011,轉換的過程如下: step1: 1035 / 0000 / 3005 / 0011 step2: 1035<GM4> / 0000 / 3005<GM2> / 0011 step3: 1<DM4>03<DM2>5<GM4> / 0000 / 3<DM4>005<GM2> / 001<DM2>1 step4: 1<DM4>03<DM2>5<GM4> / 0000 / 3<DM4>005<GM2> / 00<DM2>1 step5: 1<DM4>03<DM2>5<GM4>00003<DM4>005<GM2>00<DM2>1 step6: 1<DM4>03<DM2>5<GM4>03<DM4>05<GM2>0<DM2>1 step7: 一千零三十五兆零三千零五萬零十一 看到哪裡不對勁了嗎?應該是一千零三十五兆零三千零五萬零一十一,step 4把十位數字的一砍掉是錯誤的,一般只有在20以下的數字(例如:十一,十二)才會省略掉十位數字的一,但是step 4把所有小於20的group的十位數字都砍掉了,這條規則應該改成If the total number less than 20才對,(神奇的是,我用FireFox 0.93去看我的測試網頁,結果居然是正確的,看來FireFox並沒有完全遵循W3C的規範...呵 ![]() 2. 大,小寫的cjk-ideographic algorithm應該不同 第二個問題也跟第一個問題有關,即使是20以下的數字,用大寫數字(國字數字)書寫的時候也不應該省略掉十位數字的壹(例如:壹拾貳,壹拾參),大寫數字本來就是為了防止紀錄錯誤而定義的比較嚴謹的格式,而且大多被使用在金錢往來,帳目紀錄方面,據我所了解是不能省略壹的 3. suffix跟我們的使用習慣不合,而且搭配起來很難看 @_@ 目前定義的suffix是. U+002E,但是在台灣一般是習慣用、 U+3001,不知道大陸跟日本的習慣是怎麼樣,請知道的網友幫忙提供一下意見吧 ![]() 4. cjk numbering system's table的內容寫錯了 一共有japanese-formal, japanese-informal, simp-chinese-formal, simp-chinese-informal, trad-chinese-formal, trad-chinese-informal六種,只要是中文字的使用者應該可以很容易看出來錯在哪裡吧!在此列出正確的版本 simp-chinese-formal Second Group Marker 万 U+4E07 Third Group Marker 億 U+5104 Fourth Group Marker 兆 U+5146 Second Digit Marker 拾 U+62FE Third Digit Marker 佰 U+4F70 Fourth Digit Marker 仟 U+4EDF Digit 0 零 U+96F6 Digit 1 壹 U+58F9 Digit 2 贰 U+8D30 Digit 3 叁 U+53C1 Digit 4 肆 U+8086 Digit 5 伍 U+4F0D Digit 6 陆 U+9646 Digit 7 柒 U+67D2 Digit 8 捌 U+634C Digit 9 玖 U+7396 simp-chinese-informal Second Group Marker 万 U+4E07 Third Group Marker 億 U+5104 Fourth Group Marker 兆 U+5146 Second Digit Marker 十 U+534E Third Digit Marker 百 U+767E Fourth Digit Marker 千 U+5343 Digit 0 零 U Digit 1 一 U+4E00 Digit 2 二 U+4E8C Digit 3 三 U+4E09 Digit 4 四 U+56DB Digit 5 五 U+4E94 Digit 6 六 U+516D Digit 7 七 U+4E03 Digit 8 八 U+516B Digit 9 九 U+4E5D trad-chinese-formal Second Group Marker 萬 U+842C Third Group Marker 億 U+5104 Fourth Group Marker 兆 U+5146 Second Digit Marker 拾 U+62FE Third Digit Marker 佰 U+4F70 Fourth Digit Marker 仟 U+4EDF Digit 0 零 U+96F6 Digit 1 壹 U+58F9 Digit 2 貳 U+8CB3 Digit 3 參 U+53C3 Digit 4 肆 U+8086 Digit 5 伍 U+4F0D Digit 6 陸 U+9678 Digit 7 柒 U+67D2 Digit 8 捌 U+634C Digit 9 玖 U+7396 trad-chinese-informal Second Group Marker 萬 U+842C Third Group Marker 億 U+5104 Fourth Group Marker 兆 U+5146 Second Digit Marker 十 U+534E Third Digit Marker 百 U+767E Fourth Digit Marker 千 U+5343 Digit 0 零 U+96F6 Digit 1 一 U+4E00 Digit 2 二 U+4E8C Digit 3 三 U+4E09 Digit 4 四 U+56DB Digit 5 五 U+4E94 Digit 6 六 U+516D Digit 7 七 U+4E03 Digit 8 八 U+516B Digit 9 九 U+4E5D japanese-formal Second Group Marker 万 U+4E07 Third Group Marker 億 U+5104 Fourth Group Marker 兆 U+5146 Second Digit Marker 拾 U+62FE Third Digit Marker 佰 U+4F70 Fourth Digit Marker 仟 U+4EDF Digit 0 零 U+96F6 Digit 1 壹 U+58F9 Digit 2 貳 U+8CB3 Digit 3 參 U+53C3 Digit 4 肆 U+8086 Digit 5 伍 U+4F0D Digit 6 陸 U+9678 Digit 7 柒 U+67D2 Digit 8 捌 U+634C Digit 9 玖 U+7396 japanese-informal Second Group Marker 万 U+4E07 Third Group Marker 億 U+5104 Fourth Group Marker 兆 U+5146 Second Digit Marker 拾 U+62FE Third Digit Marker 佰 U+4F70 Fourth Digit Marker 仟 U+4EDF Digit 0 零 U+96F6 Digit 1 一 U+4E00 Digit 2 二 U+4E8C Digit 3 三 U+4E09 Digit 4 四 U+56DB Digit 5 五 U+4E94 Digit 6 六 U+516D Digit 7 七 U+4E03 Digit 8 八 U+516B Digit 9 九 U+4E5D 關於1, 3項是以台灣的使用習慣為準,不知道大陸香港日本的習慣會不會與我們不同,而關於第2項,可能就連台灣人的看法都不一定一樣吧 ^^||| 這份CSS3 module: lists, Working Draft是2002年11月發布的,我想在這一段時間應該已經有人把這些Bug呈報上去了吧,不知道在哪裡可以找到Bug report(我在Mail Archives裡面找不到相關的討論),請大家提供一些意見吧 ![]() |
發表人: | 訪客 [ 2004-09-14, 17:10 ] |
文章主題 : | |
我估計Mozilla在這方面是參考CSS 2的規格書(CSS 2定義的太含糊, 故在CSS 2.1刪除了), 而不是CSS 3. 再者, Mozilla以前的開發團隊有幾位是東方人, 顯示出來的效果跟我們預期的一樣並不出奇. 的確呢, CSS 3 Lists涉及許多i18n問題, 需要我們幫忙指正. 但亦如你所述, 這份草案沒更新足足一年多, 問題可能已經回報了. 不管如何, 我建議你先去www-style回報試試, 反正這能令討論公開化. |
發表人: | BuriBuri [ 2004-09-14, 19:30 ] |
文章主題 : | |
我在www-style搜尋到一篇相關的文章 cjk-ideographic list style : correction and addition 不但更正了第四點cjk numbering system's table的問題,還添增了韓國的表格,並且還補充中文的大數(億10^8以上一直到無量大數10^68的單位,真是厲害),關於這一點的修正我想應該是沒有問題的 關於第一點我很好奇,雖然從台灣人的觀點來看他的演算法明顯有誤,但是既然他能夠列出如此詳細的算法,會不會其實日本人或者其他地方有人使用那種演算法呢?而且標點符號"、"在台灣以外的地方有在使用嗎(大陸使用的標點符號好像跟台灣有點不同)? 還有,目前天干地支的系統是分開的,要不要建議他新增一個干支系統呢?(紀年用,突然想到不知道可不可以用 li::marker {content: counter(counter, cjk-heavenly-stem) counter(counter, cjk-earthly-branch) "、"} 自己產生干支系統,呵,真妙) 其實中文的數字標示方法實在是太多了,而且隨著時代演進,定義好像會有些許的不同(參考這篇兆有多大),我本來想找看看教育部的網站有沒有官方的定義可供參考,目前為止還找不到... 請大家多提供一點意見囉,感謝 ![]() |
發表人: | BuriBuri [ 2004-09-14, 20:14 ] |
文章主題 : | |
對了,關於演算法的部分之前忽略了一點: 100 step1: 100 step2: 100 step3: 1百00 step4: 1百00 step5: 1百00 step6: 1百0 step7: 一百零 10000000 step1: 1000 / 0000 step2: 1000萬 / 0000 step3: 1千000萬 / 0000 step4: 1千000萬 / 0000 step5: 1千0萬 / 0 step6: 1千0萬0 step7: 一千零萬零 所以第五六點應該修改一下,如果Group marker前面有零的話應該要砍掉,尾數有零的話也要砍掉,但這裡又牽涉到一點,100005000大家是習慣稱之為一億五千還是一億零五千呢?如果是一億零五千的話,那麼<group marker>0<group marker>中間的零就不能砍掉了 |
發表人: | MilchFlasche [ 2004-09-16, 12:48 ] |
文章主題 : | |
BuriBuri真是有sense又有心的好人……可惜我還無法提供什麼資源 ![]() ![]() |
發表人: | kanashimi [ 2005-01-01, 17:32 ] |
文章主題 : | |
之前寫過一個Javascript的演算法,畫蛇添足一下: // 將數字轉為漢字表示法 ,turn2kanjiD,turn2kanjiInit,"turn2kanjiInit;",_turn2kanji,turn2kanji var turn2kanjiD; function turn2kanjiInit(){ turn2kanjiD={ 'num':['O,一,二,三,四,五,六,七,八,九'.split(','),'零,壹,貳,參,肆,伍,陸,柒,捌,玖'.split(',')] // 數字 ,'d':',萬,億,兆,京,垓,秭,穰,溝,澗,正,載,極,恒河沙,阿僧祇,那由他,不可思議,無量大數' // denomination,單位 ,'bd':0 // 暫時定義 }; with(turn2kanjiD) bd=[(',十,百,千'+turn2kanjiD.d).split(','),(',拾,佰,仟'+turn2kanjiD.d).split(',')] // base denomination ,d=d.split(','); } turn2kanjiInit(); // 處理1-99999的數,尚有bug function _turn2kanji(numStr,kind){ if(!kind)kind=0; var i=0,r='',l=numStr.length-1,d,tnum=turn2kanjiD.num[kind],tbd=turn2kanjiD.bd[kind],zero=tnum[0]; // 用r=[]約多花一倍時間! for(;i<=l;i++) if((d=numStr.charAt(i))!='0')//if(d=parseInt(numStr.charAt(i)))比較慢 r+=tnum[d]+tbd[l-i];//'O一二三四五六七八'.charAt(d)比較慢 else if(r.charAt(r.length-1)!=zero)if(parseInt(numStr.substr(i+1)))r+=zero;else break; return r; } //2.016,2.297,2.016 //{var d=new Date,v='12345236',i=0,a;for(;i<10000;i++)a=turn2kanji(v);alert(v+'\n→'+a+'\ntime:'+gDate(new Date-d));} // 將數字轉為漢字表示法 num>1京時僅會取概數,此時得轉成string再輸入! // 統整:尚有bug function turn2kanji(num,kind){ //num=parseFloat(num); if(typeof num=='number')num=num.toString(10); num=(''+num).replace(/[,\s]/g,''); if(isNaN(num))return '(非數值)'; if(num.match(/(-?[\d.]+)/))num=RegExp.$1; if(!kind)kind=0; var j,i,d=num.indexOf('.'),k,l,m,addZero=false,tnum=turn2kanjiD.num[kind],zero=tnum[0],td=turn2kanjiD.d;//i:integer,整數;d:decimal,小數 if(d==-1)d=0; else for(num=num.replace(/0+$/,''),i=num.substr(d+1),num=num.substr(0,d),d='',j=0;j<i.length;j++) d+=tnum[i.charAt(j)]; // 至此num為整數 if(num.charAt(0)=='-')i='負',num=num.substr(1);else i=''; num=num.replace(/^0+/,''); for(m=num.length%4,j=m-4,l=(num.length-(m||4))/4;j<num.length;m=0,l--)//addZero=false, l=Math.floor((num.length-1)/4) if(parseInt(m=m?num.substr(0,m):num.substr(j+=4,4))) m=_turn2kanji(m,kind),addZero=addZero&&m.charAt(0)!=zero, i+=(addZero?(addZero=false,zero):'')+m+td[l]; else addZero=true; return (i?i.substr(0,2)=='一十'?i.substr(1):i:zero)+(d?'點'+d:''); } // 轉換成金錢表示法 function turn2Money(num){ var i=(num=turn2kanji(num,1)).indexOf('點'); return i==-1?num+'圓整':num.substr(0,i)+'圓'+num.charAt(++i)+'角'+(++i==num.length?'':num.charAt(i++)+'分')+num.substr(i); } |
發表人: | 風痕影 [ 2005-01-01, 17:54 ] |
文章主題 : | |
我在去年五月也寫了一個以中文語法印出數字的PHP計數器。 不過單位陣列的部分我沒把「十、百、千」分離出來, 是直接寫成「十、百、千、萬、十、百、千、億、十、百、千、兆……」。 |
發表人: | 風痕影 [ 2005-08-05, 09:50 ] |
文章主題 : | |
kanashimi 寫: 萬,億,兆,京,垓,秭,穰,溝,澗,正,載,極,恒河沙,阿僧祇,那由他,不可思議,無量大數' // denomination,單位
根據我查的資料,古代記數法有上、中、下三種 而kanashimi用的萬進法則是民國二十二年確定下來的 不過,關於〔無量大數〕,我卻查到兩種說法: (前略)...那由他、不可思議、無量、大數 (前略)...那由他、不可思議、無量大數、無量、大數 |
第 1 頁 (共 1 頁) | 所有顯示的時間為 UTC + 8 小時 |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |