<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10chinesetwfull.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"><generator uri="http://www.habariproject.org/" version="0.7-alpha">Habari</generator><id>tag:blog.bcse.info,2010-03-22:atom/0b7d649d4e1b4b369409ea814509ecd4f65e39fe</id><title>Lvx ex Cælis</title><subtitle>虛實相歸，有無相生；寒暑相反，明晦相隨。</subtitle><updated>2009-07-26T21:16:27+08:00</updated><link rel="alternate" href="http://blog.bcse.info/" /><link rel="first" href="http://blog.bcse.info/atom/1/page/1" type="application/atom+xml" title="First Page" /><link rel="next" href="http://blog.bcse.info/atom/1/page/2" type="application/atom+xml" title="Next Page" /><link rel="last" href="http://blog.bcse.info/atom/1/page/11" type="application/atom+xml" title="Last Page" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/bcse" /><feedburner:info uri="bcse" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><geo:lat>23.97692</geo:lat><geo:long>121.57041</geo:long><link rel="license" type="text/html" href="http://creativecommons.org/licenses/by-nd/2.5/" /><xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /><logo>http://feeds.feedburner.com/~fc/bcse?bg=CCFFFF&amp;fg=444444&amp;anim=f</logo><feedburner:emailServiceId>bcse</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Fbcse" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fbcse" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/bcse" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fbcse" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fbcse" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fbcse" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2Fbcse" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><entry><title>Load Cufón font dynamically</title><link rel="alternate" href="http://feedproxy.google.com/~r/bcse/~3/S69YFE_fOrQ/load-cufon-font-dynamically" /><link rel="edit" href="http://blog.bcse.info/load-cufon-font-dynamically/atom" /><author><name>Joel Lee</name><uri>http://blog.bcse.info</uri></author><id>tag:blog.bcse.info,2009:load-cufon-font-dynamically/1248607329</id><updated>2009-07-26T21:16:27+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-27T23:13:58+08:00</app:edited><published>2009-07-26T21:16:27+08:00</published><category term="Typography" /><category term="Web Design" /><category term="canvas" /><content type="html">&lt;p&gt;前陣子我曾實驗利用 &lt;a href="http://cufon.shoqolate.com/"&gt;Cufón&lt;/a&gt; 在網頁上嵌入中文字型，當時的實驗結果是中文字型轉換為 JavaScript 格式，再經過 gzip 壓縮後，其大小雖然已經比原來的 TrueType 檔案小------以微軟正黑體為例，原始字型檔為 14 MB，經轉換後為 5.3 MB------但對於網路傳輸而言仍然過大，因此無法實際使用。&lt;/p&gt;

&lt;p&gt;最近發現 Google App Engine 的&lt;a href="http://code.google.com/appengine/docs/python/tools/uploadingdata.html"&gt;大量傳輸 API&lt;/a&gt; 已經&lt;a href="http://googleappengine.blogspot.com/2009/02/sdk-version-119-released.html"&gt;開放&lt;/a&gt;了，於是試著寫個東西來玩。我把 Cufón 字型的每個 Glyph 個別儲存到 Datastore，然後根據頁面的實際需要，重組成僅含所需字集的新檔案，藉此縮小所需傳輸的檔案大小。&lt;/p&gt;

&lt;table&gt;
    &lt;thead&gt;
        &lt;tr&gt;&lt;th rowspan="2"&gt;&amp;nbsp;&lt;/th&gt;&lt;th colspan="2"&gt;字型檔案大小&lt;/th&gt;&lt;/tr&gt;
        &lt;tr&gt;&lt;th&gt;使用 gzip 壓縮&lt;/th&gt;&lt;th&gt;不使用 gzip 壓縮&lt;/th&gt;&lt;/tr&gt;
    &lt;thead&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;a href="http://ex.bcse.info/cufon/msjh.gae.html"&gt;範例1：載入完整字型&lt;/a&gt;&lt;/td&gt;
            &lt;td class="aligncenter"&gt;10.5 MB&lt;/td&gt;
            &lt;td class="aligncenter"&gt;34.1 MB&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;a href="http://ex.bcse.info/cufon/msjh.dynamic.html"&gt;範例2：只載入所需的字集&lt;/a&gt;&lt;/td&gt;
            &lt;td class="aligncenter"&gt;22.3 KB&lt;/td&gt;
            &lt;td class="aligncenter"&gt;61.4 KB&lt;/td&gt;
        &lt;/tr&gt;
    &lt;tbody&gt;
&lt;/table&gt;

&lt;p&gt;目前的作法是把需要的字集直接用 &lt;code&gt;GET&lt;/code&gt; 告訴伺服器，但這樣未來可能會遇上 &lt;a href="http://support.microsoft.com/kb/208427"&gt;&lt;code&gt;GET&lt;/code&gt; 長度限制問題&lt;/a&gt;…… 我想到的解法是可改用 JavaScript 載入這個檔案，用 &lt;code&gt;POST&lt;/code&gt; 傳遞字集資訊，同時或許也能用 JavaScript 自動整理出所需的字集（目前是用手動整理 :p）。&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/bcse?a=S69YFE_fOrQ:-O_O7NqLYG4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/bcse?i=S69YFE_fOrQ:-O_O7NqLYG4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/bcse/~4/S69YFE_fOrQ" height="1" width="1"/&gt;</content><link rel="replies" href="http://blog.bcse.info/load-cufon-font-dynamically/atom/comments" thr:count="4" thr:updated="2009-12-01T18:18:20+08:00" /><thr:total>4</thr:total><feedburner:origLink>http://blog.bcse.info/load-cufon-font-dynamically</feedburner:origLink></entry><entry><title>繁體版微軟雅黑字型 (2)</title><link rel="alternate" href="http://feedproxy.google.com/~r/bcse/~3/Bc98KLBd8mc/microsoft-yahei-traditional-6-02" /><link rel="edit" href="http://blog.bcse.info/microsoft-yahei-traditional-6-02/atom" /><author><name>Joel Lee</name><uri>http://blog.bcse.info</uri></author><id>tag:blog.bcse.info,2009:繁體版微軟雅黑字型-2/1245656368</id><updated>2009-06-22T15:39:30+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-07T17:09:09+08:00</app:edited><published>2009-06-22T15:28:29+08:00</published><category term="@斷簡" /><category term="typeface" /><content type="html">&lt;p&gt;&lt;a href="/microsoft-yahei-traditional#comment-14246"&gt;因為有人想要&lt;/a&gt;，所以更新了一下。&lt;/p&gt;

&lt;p&gt;此更新檔的功能為將微軟雅黑字型 6.02 版（MD5: EB525DCBA67C642CFA418424F8C7DFC7）更新為繁體版。原始字型檔取自 Windows 7 RC 版，本 blog 不提供原始字型檔，請自行取得。&lt;/p&gt;

&lt;p&gt;※ 註：微軟雅黑字型本來就包含繁體字，此更新檔是將微軟雅黑中的簡體字也取代為繁體，如此便能用繁體顯示原本為簡體的文字。如果您沒有這樣的需求，便無須使用本更新檔。&lt;/p&gt;

&lt;div class="download"&gt;&lt;a href="http://cdn.bcse.info/file/msyht_6.02.exe"&gt;Microsoft YaHei Traditional Patcher&lt;/a&gt; v6.02&lt;/div&gt;

&lt;p&gt;這裡是我的&lt;a href="https://spreadsheets.google.com/pub?key=tpSVh9q-1eXPP-M_k4o3Vcw"&gt;中文簡繁參考對應表&lt;/a&gt;，如果對此對應表有意見者，也歡迎幫忙修改。&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;這次製作我改用 &lt;a href="http://fontforge.sourceforge.net/"&gt;FontForge&lt;/a&gt;，FontForge 有強大的 &lt;a href="http://fontforge.sourceforge.net/scripting.html"&gt;Scripting&lt;/a&gt; 能力&lt;sup id="fnref:microsoft-yahei-traditional-6-02-1"&gt;&lt;a href="#fn:microsoft-yahei-traditional-6-02-1" rel="footnote"&gt;1&lt;/a&gt;&lt;/sup&gt;，所以製作起來速度超快！&lt;a href="http://cdn.bcse.info/file/remove_simplified_characters.pe"&gt;我的 script 可在此下載&lt;/a&gt;。&lt;/p&gt;

&lt;div class="footnotes"&gt;
&lt;hr /&gt;
&lt;ol&gt;

&lt;li id="fn:microsoft-yahei-traditional-6-02-1"&gt;
&lt;p&gt;這樣說可能會引起誤會，因此特別註明一下：其實 FontCreator、FontLab Studio 等產品也都有 Scripting 的能力，只是我以前不會用 :p&amp;#160;&lt;a href="#fnref:microsoft-yahei-traditional-6-02-1" rev="footnote"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;
&lt;/div&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/bcse?a=Bc98KLBd8mc:5pkP6eHk0Rc:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/bcse?i=Bc98KLBd8mc:5pkP6eHk0Rc:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/bcse/~4/Bc98KLBd8mc" height="1" width="1"/&gt;</content><link rel="replies" href="http://blog.bcse.info/microsoft-yahei-traditional-6-02/atom/comments" thr:count="12" thr:updated="2010-01-30T12:13:10+08:00" /><thr:total>12</thr:total><feedburner:origLink>http://blog.bcse.info/microsoft-yahei-traditional-6-02</feedburner:origLink></entry><entry><title>How to get the latest Droid font family</title><link rel="alternate" href="http://feedproxy.google.com/~r/bcse/~3/4F0vlVcZs2M/how-to-get-the-latest-droid-font-family" /><link rel="edit" href="http://blog.bcse.info/how-to-get-the-latest-droid-font-family/atom" /><author><name>Joel Lee</name><uri>http://blog.bcse.info</uri></author><id>tag:blog.bcse.info,2009:how-to-get-the-latest-droid-font/1245137917</id><updated>2009-06-16T15:38:51+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-16T15:48:08+08:00</app:edited><published>2009-06-16T15:38:51+08:00</published><category term="@斷簡" /><category term="Google" /><category term="typeface" /><content type="html">&lt;p&gt;這篇只是給自己作個紀錄。&lt;/p&gt;

&lt;p&gt;最新版 Droid 字型可以直接從 Android 的 Git repository 取得，不需要從 Android SDK 解出來。位址在 &lt;a href="http://android.git.kernel.org/?p=platform/frameworks/base.git;a=tree;f=data/fonts"&gt;platform/frameworks/base.git/data/fonts&lt;/a&gt;，點選 snapshot 可以將這個資料夾打包下載。&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/bcse?a=4F0vlVcZs2M:HNDi7FiXQGA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/bcse?i=4F0vlVcZs2M:HNDi7FiXQGA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/bcse/~4/4F0vlVcZs2M" height="1" width="1"/&gt;</content><link rel="replies" href="http://blog.bcse.info/how-to-get-the-latest-droid-font-family/atom/comments" thr:count="1" thr:updated="2009-06-16T23:07:20+08:00" /><thr:total>1</thr:total><feedburner:origLink>http://blog.bcse.info/how-to-get-the-latest-droid-font-family</feedburner:origLink></entry><entry><title>A Non-Free OpenType Font Pack</title><link rel="alternate" href="http://feedproxy.google.com/~r/bcse/~3/KC1LeT5aHLE/a-non-free-opentype-font-pack" /><link rel="edit" href="http://blog.bcse.info/a-non-free-opentype-font-pack/atom" /><author><name>Joel Lee</name><uri>http://blog.bcse.info</uri></author><id>tag:blog.bcse.info,2009:non-free-opentype-font-pack/1239153396</id><updated>2009-04-08T09:16:36+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-04-08T13:43:06+08:00</app:edited><published>2009-04-08T09:42:33+08:00</published><category term="Typography" /><category term="Microsoft" /><category term="typeface" /><category term=".NET" /><content type="html">&lt;div class="floatright"&gt;&lt;a href="http://www.flickr.com/photos/bcse/3422105999/" title="OpenTypeFontsSample (by BCSEEATI)"&gt;&lt;img src="http://farm4.static.flickr.com/3390/3422105999_bb7c1ea40f_o.png" title="OpenTypeFontsSample (by BCSEEATI)" alt="OpenTypeFontsSample (by BCSEEATI)" width="181" height="240" /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;p&gt;意外發現 MSDN 中有一包還不錯的 OpenType 字型。這包字型的本意只是用來展示 WPF 的 OpenType 處理能力，所以僅包含英文、數字及部份標點符號，版權則仍由 Ascender 持有，如果要用於其他用途，必須聯絡 Ascender。&lt;/p&gt;

&lt;p&gt;這些字型的特色是它們分別支援了不同的 OpenType Features，例如  Small Caps、Ligatures、Old Style Figures、Swashes、Alternates 等，如果不在意以上所述缺點並想要玩玩看 OpenType Features 的話，可到 &lt;a href="http://msdn.microsoft.com/en-us/library/ms771464.aspx"&gt;Using OpenType Fonts Sample&lt;/a&gt; 這一頁下載。&lt;/p&gt;

&lt;p&gt;P.S. 如果想玩 OpenType Features，請找 Windows 7 中附帶的 Gabriola 字型會更好玩，實在很難得可以看到檔案大小這麼大的英文字型。&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/bcse?a=KC1LeT5aHLE:U1rAxHNLnsM:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/bcse?i=KC1LeT5aHLE:U1rAxHNLnsM:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/bcse/~4/KC1LeT5aHLE" height="1" width="1"/&gt;</content><link rel="replies" href="http://blog.bcse.info/a-non-free-opentype-font-pack/atom/comments" thr:count="0" /><thr:total>0</thr:total><feedburner:origLink>http://blog.bcse.info/a-non-free-opentype-font-pack</feedburner:origLink></entry><entry><title>I don't know what is this pattern.</title><link rel="alternate" href="http://feedproxy.google.com/~r/bcse/~3/G1pD1YexiYY/i-dont-know-what-is-this-pattern" /><link rel="edit" href="http://blog.bcse.info/i-dont-know-what-is-this-pattern/atom" /><author><name>Joel Lee</name><uri>http://blog.bcse.info</uri></author><id>tag:blog.bcse.info,2009:post/1237384162</id><updated>2009-03-18T21:49:22+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-18T22:32:46+08:00</app:edited><published>2009-03-18T22:28:49+08:00</published><category term="@言語" /><category term="C#" /><category term=".NET" /><content type="html">&lt;p&gt;最近幾天每天都在寫 C#，寫的是某個自己要用的程式，由於只是自己用的，就只求速成，沒有花太多精神在設計上，直到這兩天才感覺到這樣不行，我實在重複了太多次相同的程式，因此決定改寫。&lt;/p&gt;

&lt;p&gt;要描述我的需求太麻煩，直接看 code！我理想中的介面是長這樣：&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Console.WriteLine(English.Hello());
Console.WriteLine(Chinese.Hello());
Console.WriteLine(Japanese.Hello());
Console.WriteLine(French.Hello());
&lt;/code&gt;&lt;/pre&gt;

&lt;ol&gt;
&lt;li&gt;上面的 &lt;code&gt;English&lt;/code&gt;、&lt;code&gt;Chinese&lt;/code&gt;、&lt;code&gt;Japanese&lt;/code&gt;、&lt;code&gt;French&lt;/code&gt; 都是 subclass，&lt;code&gt;Hello()&lt;/code&gt; 是 static method，所以不需要實例就能直接呼叫，呼叫了之後就會回傳各國語言的 Hello。&lt;/li&gt;
&lt;li&gt;同時我希望上述這些 subclass 只要繼承某個 class，就能有一個預設的 &lt;code&gt;Hello()&lt;/code&gt;，當有必要時我再 override 這個 method。&lt;/li&gt;
&lt;/ol&gt;

&lt;!--more--&gt;

&lt;p&gt;起初我是朝 &lt;a href="http://en.wikipedia.org/wiki/Singleton_pattern"&gt;Singleton&lt;/a&gt; 的方向研究，由於我想要的是透過繼承，讓 subclass 輕鬆成為 Singleton，所以我應該用 Registry of Singletons。但是我實作出來後，發現我還是得在每個 subclass 複製貼上相同的 code，要不然就是呼叫方式會變成像 &lt;code&gt;English.Instance.Hello()&lt;/code&gt; 這般冗贅。有關 C# 如何實做 Registry of Singletons，請參考這篇：&lt;a href="http://www.c-sharpcorner.com/UploadFile/snorrebaard/GenericSingleton11172008110419AM/GenericSingleton.aspx"&gt;The Quest for the Generic Singleton in C#&lt;/a&gt;&lt;sup id="fnref:i-dont-know-what-is-this-pattern-1"&gt;&lt;a href="#fn:i-dont-know-what-is-this-pattern-1" rel="footnote"&gt;1&lt;/a&gt;&lt;/sup&gt;。&lt;/p&gt;

&lt;p&gt;我現在實際作出的介面是長這樣：&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Console.WriteLine(Say&amp;lt;English&amp;gt;.Hello());
Console.WriteLine(Say&amp;lt;Japanese&amp;gt;.Hello());
Console.WriteLine(Say&amp;lt;Chinese&amp;gt;.Hello());
Console.WriteLine(Say&amp;lt;French&amp;gt;.Hello());
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;雖然還沒達到理想，但我覺得不錯了。整個實作如下：&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;namespace Speaking
{
    // 介面
    interface ILanguage
    {
        string Hello();
    }

    // 基底類別，加上 abstract 是為了避免它被實例化
    abstract class DefaultLanguage : ILanguage
    {
        public virtual string Hello()
        {
            return "Hello!";
        }
    }

    // 呼叫用的類別
    static class Say&amp;lt;TLanguage&amp;gt; where TLanguage : ILanguage, new()
    {
        private static TLanguage instance;
        public static TLanguage Language
        {
            get
            {
                // 這裡有點像 Registry of Singletons
                // 但我不需要 Registry 就能管理多個 Singletons
                // 我也覺得很奇妙 XD
                if (instance == null)
                {
                    instance = new TLanguage();
                }
                return instance;
            }
        }

        // 這才是上面範例中呼叫到的 Hello()
        public static string Hello()
        {
            return Language.Hello();
        }
    }

    // 以下是幾個子類別
    class English : DefaultLanguage
    {
        // 一切都照基底類別，所以我什麼都不用寫
        // 附帶一提，這裡不可以寫 private constructor
    }

    class Chinese : DefaultLanguage
    {
        // 繼承基底類別，並且 override
        public override string Hello()
        {
            return "你好!";
        }
    }

    class Japanese : ILanguage
    {
        // 也可以只實作 ILanguage 介面，不繼承基底類別
        public string Hello()
        {
            return "こんにちは!";
        }
    }

    class French : DefaultLanguage, ILanguage
    {
        // 也可以繼承、實作一起來，其實這個跟只有繼承是一樣的
        public override string Hello()
        {
            return "Bonjour!";
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;這個方法有個毛病，那些子類別還是可以建立實例，所以不能保證 Singleton。&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;// 這樣寫的話，就會產生一個新的 English 物件
ILanguage en = new English();
&lt;/code&gt;&lt;/pre&gt;

&lt;div class="footnotes"&gt;
&lt;hr /&gt;
&lt;ol&gt;

&lt;li id="fn:i-dont-know-what-is-this-pattern-1"&gt;
&lt;p&gt;這篇文章的標題寫得就像要在 C# 中實作 Singleton 是個天大的謎似的 XD&amp;#160;&lt;a href="#fnref:i-dont-know-what-is-this-pattern-1" rev="footnote"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;
&lt;/div&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/bcse?a=G1pD1YexiYY:d5woZHJSB0E:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/bcse?i=G1pD1YexiYY:d5woZHJSB0E:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/bcse/~4/G1pD1YexiYY" height="1" width="1"/&gt;</content><link rel="replies" href="http://blog.bcse.info/i-dont-know-what-is-this-pattern/atom/comments" thr:count="1" thr:updated="2009-03-24T04:01:49+08:00" /><thr:total>1</thr:total><feedburner:origLink>http://blog.bcse.info/i-dont-know-what-is-this-pattern</feedburner:origLink></entry><entry><title>ViewSonic VA1916w Color Profile for Mac</title><link rel="alternate" href="http://feedproxy.google.com/~r/bcse/~3/F065bdc-7M8/viewsonic-va1916w-color-profile-for-mac" /><link rel="edit" href="http://blog.bcse.info/viewsonic-va1916w-color-profile-for-mac/atom" /><author><name>Joel Lee</name><uri>http://blog.bcse.info</uri></author><id>tag:blog.bcse.info,2009:viewsonic-va1916w-color-profile-for-mac/1237075228</id><updated>2009-03-15T08:00:28+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-15T08:08:26+08:00</app:edited><published>2009-03-15T08:04:12+08:00</published><category term="@斷簡" /><category term="Monitor" /><content type="html">&lt;p&gt;心血來潮，幫我的另一台螢幕也作了 Color Profile，我自己覺得這次做得還不錯。&lt;/p&gt;

&lt;div class="download"&gt;&lt;a href="http://sites.google.com/a/bcse.info/doc/downloads/ViewSonic-VA1916w.icc"&gt;ViewSonic VA1916w Color Profile for Mac&lt;/a&gt;&lt;/div&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/bcse?a=F065bdc-7M8:OlnOpXLfNHo:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/bcse?i=F065bdc-7M8:OlnOpXLfNHo:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/bcse/~4/F065bdc-7M8" height="1" width="1"/&gt;</content><link rel="replies" href="http://blog.bcse.info/viewsonic-va1916w-color-profile-for-mac/atom/comments" thr:count="2" thr:updated="2009-03-15T16:38:32+08:00" /><thr:total>2</thr:total><feedburner:origLink>http://blog.bcse.info/viewsonic-va1916w-color-profile-for-mac</feedburner:origLink></entry><entry><title>ASUS PW101S Color Profile for Mac</title><link rel="alternate" href="http://feedproxy.google.com/~r/bcse/~3/nTqO3hTNlGo/asus-pw101s-color-profile-for-mac" /><link rel="edit" href="http://blog.bcse.info/asus-pw101s-color-profile-for-mac/atom" /><author><name>Joel Lee</name><uri>http://blog.bcse.info</uri></author><id>tag:blog.bcse.info,2009:asus-pw101s-color-profile-for-mac/1237037883</id><updated>2009-03-14T21:38:03+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-15T08:02:52+08:00</app:edited><published>2009-03-14T21:33:25+08:00</published><category term="@斷簡" /><category term="Monitor" /><content type="html">&lt;p&gt;網路上找不到，安裝光碟也沒附，只好憑肉眼自己作一份，好像還是有色偏（而且也是不難察覺的程度 XD），不過至少比預設值好很多了 :p&lt;/p&gt;

&lt;div class="download"&gt;&lt;a href="http://sites.google.com/a/bcse.info/doc/downloads/ASUS-PW191S.icc"&gt;ASUS PW101S Color Profile for Mac&lt;/a&gt;&lt;/div&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/bcse?a=nTqO3hTNlGo:f6aWZx3J2dA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/bcse?i=nTqO3hTNlGo:f6aWZx3J2dA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/bcse/~4/nTqO3hTNlGo" height="1" width="1"/&gt;</content><link rel="replies" href="http://blog.bcse.info/asus-pw101s-color-profile-for-mac/atom/comments" thr:count="0" /><thr:total>0</thr:total><feedburner:origLink>http://blog.bcse.info/asus-pw101s-color-profile-for-mac</feedburner:origLink></entry><entry><title>Using SQLite Aggregate Functions in C#</title><link rel="alternate" href="http://feedproxy.google.com/~r/bcse/~3/LqrgIBnJ6Fs/using-sqlite-in-c-sharp" /><link rel="edit" href="http://blog.bcse.info/using-sqlite-in-c-sharp/atom" /><author><name>Joel Lee</name><uri>http://blog.bcse.info</uri></author><id>tag:blog.bcse.info,2009:using-sqlite-in-c/1236986238</id><updated>2009-03-14T07:17:18+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-14T21:38:39+08:00</app:edited><published>2009-03-14T07:52:19+08:00</published><category term="@言語" /><category term="C#" /><category term=".NET" /><category term="SQLite" /><content type="html">&lt;p&gt;昨天遇到一個 &lt;a href="http://sqlite.phxsoftware.com/"&gt;System.Data.SQLite&lt;/a&gt; 的 bug，老實說我不是很肯定它是不是 bug，因為這個 bug 在 2005 年就&lt;a href="http://sqlite.phxsoftware.com/forums/p/110/6565.aspx"&gt;有人提出&lt;/a&gt;，卻到現在都沒有解決，可能其實是個 feature 也不一定 :p&lt;/p&gt;

&lt;p&gt;一般我們使用 SQLite 查詢資料後，會先用 &lt;code&gt;HasRows&lt;/code&gt; 確定資料存在，然後用 &lt;code&gt;Read()&lt;/code&gt; 開始讀，用 &lt;code&gt;GetValue()&lt;/code&gt;、&lt;code&gt;GetString()&lt;/code&gt;、&lt;code&gt;GetDouble()&lt;/code&gt; 等方法取資料。但是當 SQL 查詢句中包含了 &lt;a href="http://www.sqlite.org/lang_aggfunc.html"&gt;Aggregate Functions&lt;/a&gt;&lt;sup id="fnref:using-sqlite-in-c-sharp-1"&gt;&lt;a href="#fn:using-sqlite-in-c-sharp-1" rel="footnote"&gt;1&lt;/a&gt;&lt;/sup&gt; 時，&lt;code&gt;HasRows&lt;/code&gt; 便必為 &lt;code&gt;true&lt;/code&gt;。如果實際上查詢結果是空的，&lt;code&gt;GetValue()&lt;/code&gt; 取得的值就會是 &lt;code&gt;DBNull.Value&lt;/code&gt;，&lt;code&gt;GetString()&lt;/code&gt; 會取得空字串，而使用 &lt;code&gt;GetDouble()&lt;/code&gt; 來取值則會發生錯誤，因為 &lt;code&gt;null&lt;/code&gt; 無法隱含轉換為 &lt;code&gt;double&lt;/code&gt; 型態。&lt;/p&gt;

&lt;p&gt;這有許多 Workaround，例如用 &lt;code&gt;GetValue()&lt;/code&gt; 取出後，先判斷是否為 &lt;code&gt;DBNull.Value&lt;/code&gt;，不是的話再轉換為 &lt;code&gt;double&lt;/code&gt;。最簡便的方法則是先使用 &lt;code&gt;IsDBNull()&lt;/code&gt; 檢查欄位是否為 &lt;code&gt;DBNull&lt;/code&gt;，不是的話才執行 &lt;code&gt;GetDouble()&lt;/code&gt;。&lt;/p&gt;

&lt;div class="footnotes"&gt;
&lt;hr /&gt;
&lt;ol&gt;

&lt;li id="fn:using-sqlite-in-c-sharp-1"&gt;
&lt;p&gt;例如 avg、count、max、min、sum 等。&amp;#160;&lt;a href="#fnref:using-sqlite-in-c-sharp-1" rev="footnote"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;
&lt;/div&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/bcse?a=LqrgIBnJ6Fs:jxUt-4bRjxs:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/bcse?i=LqrgIBnJ6Fs:jxUt-4bRjxs:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/bcse/~4/LqrgIBnJ6Fs" height="1" width="1"/&gt;</content><link rel="replies" href="http://blog.bcse.info/using-sqlite-in-c-sharp/atom/comments" thr:count="0" /><thr:total>0</thr:total><feedburner:origLink>http://blog.bcse.info/using-sqlite-in-c-sharp</feedburner:origLink></entry><entry><title>Google App Engine 收費計畫</title><link rel="alternate" href="http://feedproxy.google.com/~r/bcse/~3/ajygJ4lYIF0/google-app-engine-announced-commercial-service" /><link rel="edit" href="http://blog.bcse.info/google-app-engine-announced-commercial-service/atom" /><author><name>Joel Lee</name><uri>http://blog.bcse.info</uri></author><id>tag:blog.bcse.info,2009:google-app-engine-收費計畫/1235543735</id><updated>2009-02-25T14:35:35+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-25T18:02:30+08:00</app:edited><published>2009-02-25T14:40:35+08:00</published><category term="@斷簡" /><category term="Google App Engine" /><content type="html">&lt;p&gt;Google App Engine 即將開始提供&lt;a href="http://googleappengine.blogspot.com/2009/02/new-grow-your-app-beyond-free-quotas.html"&gt;收費&lt;/a&gt;服務，免費服務內容同時將&lt;a href="http://code.google.com/intl/zh-TW/appengine/docs/quotas.html#Free_Changes"&gt;縮減&lt;/a&gt;。&lt;/p&gt;

&lt;p&gt;對我比較有影響的部份是頻寬由原來的每天 10 GB 縮減為每天 1 GB，我看不出來這是指對外、對內流量各 1 GB 還是總共 1 GB，如果是後者的話更慘。我目前只用在 &lt;a href="http://userscripts.org/scripts/show/42324"&gt;Ikariam Graphics CDN&lt;/a&gt; 這個 User script 上，但用量已經到達每天 3.x GB :p&lt;/p&gt;

&lt;p&gt;這個 1 GB 的限制是針對單一 Application，所以如果 Google App Engine 仍然提供 10 個免費 Application 的話，總共就還有 10 GB 可用。&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/bcse?a=o3NMG7ug"&gt;&lt;img src="http://feeds.feedburner.com/~f/bcse?i=o3NMG7ug" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/bcse/~4/ajygJ4lYIF0" height="1" width="1"/&gt;</content><link rel="replies" href="http://blog.bcse.info/google-app-engine-announced-commercial-service/atom/comments" thr:count="3" thr:updated="2009-02-25T18:51:49+08:00" /><thr:total>3</thr:total><feedburner:origLink>http://blog.bcse.info/google-app-engine-announced-commercial-service</feedburner:origLink></entry><entry><title>驗證 Base64 編碼字串</title><link rel="alternate" href="http://feedproxy.google.com/~r/bcse/~3/1DJ0Gb-UvTY/how-to-validate-base64-encoded-strings" /><link rel="edit" href="http://blog.bcse.info/how-to-validate-base64-encoded-strings/atom" /><author><name>Joel Lee</name><uri>http://blog.bcse.info</uri></author><id>tag:blog.bcse.info,2009:how-to-validate-base64-encoded-strings/1235543063</id><updated>2009-02-25T14:24:23+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-25T18:07:59+08:00</app:edited><published>2009-02-25T16:06:05+08:00</published><category term="@言語" /><category term="C#" /><category term="PHP" /><category term="Development" /><category term=".NET" /><content type="html">&lt;p&gt;以往我以為驗證 Base64 編碼字串只要檢查它是由英文、數字、加號(+)、斜線(/)、等號(=)組成就好，但最近寫某個程式時踢到鐵板。我從原始資料中抓出一段 Base64 字串，無法使用 .NET 中的 &lt;a href="http://msdn.microsoft.com/zh-tw/library/system.convert.frombase64string.aspx"&gt;&lt;code&gt;Convert.FromBase64String()&lt;/code&gt;&lt;/a&gt; 對其進行轉換，但將同樣的字串交給 PHP 的 &lt;a href="http://php.nctu.edu.tw/manual/en/function.base64-decode.php"&gt;&lt;code&gt;base64_decode()&lt;/code&gt;&lt;/a&gt; 卻又能正確處理。&lt;/p&gt;

&lt;p&gt;經過我研究之後發現，Base64 編碼字串長度必為 4 的倍數，而等號的功能就是加在字串末端，確保其長度為 4 的倍數，因此等號也只會出現在字串末端，並不會出現在中間。此外，由於等號的功能只是要讓字串長度為 4 的倍數，故正確來說等號最多只能有 3 個，PHP 的 &lt;code&gt;base64_decode()&lt;/code&gt; 則比較隨和，你高興的話，只要沒有 Out of Memory，要加幾個等號都沒關係 XD&lt;/p&gt;

&lt;p&gt;最後整理一下驗證 Base64 編碼字串的方法：&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;字串由英文、數字、加號(+)、斜線(/)組成，末端可能還有 1--3 個等號(=)。&lt;/li&gt;
&lt;li&gt;字串長度必為 4 的倍數，可以自行在字串末端增減等號的數目以符合此條件。&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/bcse?a=jwynUhNq"&gt;&lt;img src="http://feeds.feedburner.com/~f/bcse?i=jwynUhNq" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/bcse/~4/1DJ0Gb-UvTY" height="1" width="1"/&gt;</content><link rel="replies" href="http://blog.bcse.info/how-to-validate-base64-encoded-strings/atom/comments" thr:count="0" /><thr:total>0</thr:total><feedburner:origLink>http://blog.bcse.info/how-to-validate-base64-encoded-strings</feedburner:origLink></entry></feed>
