gdufo

           

          繁體與簡體轉換

          unit   GB2BIG;  
             
            interface  
             
            uses  
                Windows,   Messages,   SysUtils,   Classes;  
             
            const  
                GBfirst     =   $A1A1;   //   first   code   of   GB   */  
                GBlast       =   $FEFE;   //last   code   of   GB   */  
                GBsize       =   $5E5E;   //   GBlast   -   GBfirst   +   1   */  
            type  
                TGB2BIG   =   class(TComponent)  
                private  
                    {   Private   declarations   }  
                    Instance:   THandle;  
                    GBTAB,   DupCode,   DupData:   TResourceStream;  
                protected  
                    {   Protected   declarations   }  
                public  
                    {   Public   declarations   }  
                    function   GBtoBIG5(S:   string):   string;  
                    function   GetBIGS(S:   string):   string;  
                    constructor   Create(AOwner:   TComponent);   override;  
                    destructor   Destroy;   override;  
                published  
                    {   Published   declarations   }  
                end;  
             
            procedure   Register;  
             
             
             
            implementation  
            {$R   GB2BIG32.res}  
             
            procedure   Register;  
            begin  
                RegisterComponents('代剛',   [TGB2BIG]);  
            end;  
            constructor   TGB2BIG.Create(AOwner:   TComponent);  
            begin  
                inherited   Create(AOwner);  
                if   Not(csDesigning   in   ComponentState)   then  
                begin  
                GBTAB   :=   TResourceStream.Create(Instance,   'GB2BIG',   RT_RCDATA);  
                DupCode   :=   TResourceStream.Create(Instance,   'DUPCODE',   RT_RCDATA);  
                DupData   :=   TResourceStream.Create(Instance,   'DUPDATA',   RT_RCDATA);  
                end;  
            end;  
             
            destructor   TGB2BIG.Destroy;  
            begin  
                GBTAB.free;  
                DupCode.free;  
                DupData.free;  
                inherited   Destroy;  
            end;  
             
            function   TGB2BIG.GetBIGS(S:   string):   string;  
            var  
                C     :   array[0..5]   of   Char;  
                W     :   PWordArray;  
                CA   :   array[0..2]   of   Char;  
                I     :   Integer;                          
                bak:   string;                            
            begin  
                bak   :=   '';  
                if   Byte(S[1])   >   $A0   then  
                begin  
                    W   :=   @(C[0]);  
                    C[2]   :=   S[1];  
                    C[3]   :=   S[2];  
                    C[5]   :=   S[1];  
                    C[4]   :=   S[2];  
                    W[2]   :=   W[2]   -   GBfirst;  
                    GBTAB.Position   :=   W[2]   *   2;  
                    GBTAB.read   (CA,   2);  
                    CA[2]   :=   #0;  
                    bak   :=   bak   +   StrPas(CA);  
                    I   :=   0;  
                    while   I   <   DupCode.Size   do  
                    begin  
                        DupCode.Position   :=   I;  
                        DupCode.read   (C,   2);  
                        if   W[0]   =   W[1]   then  
                        begin  
                            DupData.Position   :=   I;  
                            DupData.read   (CA,   2);  
                            CA[2]   :=   #0;  
                            bak   :=   bak   +   CA;  
                        end;  
                        inc(I,   2);  
                    end;  
                end;  
                Result   :=   bak;  
            end;  
             
            function   TGB2BIG.GBtoBIG5(S:   string):   string;  
            var  
                bak:   string;                            
                C     :   array[0..1]   of   Byte;  
                I     :   Integer;                          
                W     :   PWordArray;                    
                CA   :   array[0..2]   of   Char;  
            begin  
                bak   :=   '';  
                W   :=   @(C[0]);  
                I   :=   1;  
                while   I   <=   Length(S)   do  
                begin  
                    C[1]   :=   Byte(S[I]);  
                    if   C[1]   >   $A0   then  
                    begin  
                        inc(I,   1);  
                        C[0]   :=   Byte(S[I]);  
                        inc(I,   1);  
                        W[0]   :=   W[0]   -   GBfirst;  
                        GBTAB.Position   :=   W[0]   *   2;  
                        GBTAB.read   (CA,   2);  
                        CA[2]   :=   #0;  
                        bak   :=   bak   +   StrPas(CA);  
                    end  
                    else  
                    begin  
                        bak   :=   bak   +   S[I];  
                        inc(I,   1);  
                    end;  
                end;  
                Result   :=   bak;  
            end;  
             
            end.  
             
             
             
             
             
            ////////////////////////////////  
             
             
             
             
            unit   BIG2GB;  
             
            interface  
             
            uses  
                Windows,   Classes,   Messages,   SysUtils;  
            const  
                 
                BIGfirst   =   $A140;   //   first   code   of   BIG  
                BIGlast     =   $F9FE;   //   last   code   of   BIG    
                BIGsize     =   $58BF;   //   BIGlast   -   BIGfirst   +   1    
                 
                 
            type  
                TBIG2GB   =   class(TComponent)  
                private  
                    {   Private   declarations   }  
                    Instance   :   THandle;  
                    BIGTAB   :   TResourceStream;  
                protected  
                    {   Protected   declarations   }  
                public  
                    {   Public   declarations   }  
                    function   BIG5toGB(S:   string):   string;  
                    constructor   Create(AOwner:   TComponent);   override;  
                    destructor   Destroy;   override;  
                published  
                    {   Published   declarations   }  
                end;  
                 
            procedure   register;  
             
                 
            implementation  
            {$R   BIG2GB32.res}  
            constructor   TBIG2GB.Create(AOwner:   TComponent);  
            begin  
                inherited   Create(AOwner);  
                if   Not(csDesigning   in   ComponentState)   then  
                begin  
                BIGTAB   :=   TResourceStream.Create(Instance,   'BIG2GB',   RT_RCDATA);  
                 
                end;  
            end;  
             
            destructor   TBIG2GB.Destroy;  
            begin  
                BIGTAB.free;  
                inherited   Destroy;  
            end;  
             
             
            function   TBIG2GB.BIG5toGB(S:   string):   string;  
            var  
                bak       :   string;    
                C     :   array[0..1]   of   Byte;  
                I     :   Integer;                          
                W     :   PWordArray;                    
                CA   :   array[0..2]   of   Char;  
            begin  
                bak   :=   '';  
                I   :=   1;  
                w:=@(C[0]);  
                while   I   <=   Length(S)   do  
                begin  
                    C[1]   :=   Byte(S[I]);  
                    if   C[1]   >   $A0   then  
                    begin  
                        inc(I,   1);  
                        C[0]   :=   byte(S[I]);  
                        inc(I,   1);  
                        W[0]   :=   W[0]   -   BIGfirst;  
                        BigTAB.Position:=   W[0]*2;  
                        BIGTAB.Read(CA,2);  
                        CA[2]:=#0;  
                        bak   :=   bak   +   StrPas(CA);  
                    end  
                    else  
                    begin  
                        bak   :=   bak   +   S[I];  
                        inc(I,   1);  
                    end;  
                end;  
                Result   :=   bak;  
            end;  
             
            procedure   register;  
            begin  
                RegisterComponents('代剛',[TBIG2GB]);  
            end;  
             
            end.  

          posted on 2008-08-26 11:24 gdufo 閱讀(526) 評論(1)  編輯  收藏 所屬分類: 其它

          評論

          # re: 繁體與簡體轉換 2008-12-28 22:04 繁體

          hao  回復  更多評論   


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          導航

          統計

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          收藏夾

          Hibernate

          友情鏈接

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 枝江市| 南江县| 洛川县| 波密县| 庆安县| 临武县| 瓮安县| 乌兰浩特市| 扶风县| 昌都县| 澄迈县| 邵阳市| 莱州市| 新闻| 镇雄县| 南岸区| 晋城| 广南县| 连城县| 银川市| 太和县| 尼木县| 海门市| 崇信县| 永定县| 安西县| 明星| 平陆县| 怀化市| 大埔县| 宾阳县| 英德市| 孝感市| 邓州市| 齐齐哈尔市| 如皋市| 巴马| 南华县| 永川市| 德清县| 鄯善县|