如何把区位码转换成汉字?
不用数据库的。

解决方案 »

  1.   

    const
      cMinGBCByte = 161;                          //最小国标字节
      cMaxGBCByte = 254;                          //最大国标字节function StrToGBC(mStr: string): Integer; { 返回汉字所对应的区位码 }
    begin
      if Length(mStr) = 2 then
        Result := (Ord(mStr[1]) - cMinGBCByte + 1) * 100 +
          Ord(mStr[2]) - cMinGBCByte + 1
      else Result := 0;
    end; { StrToGBC }function GBCToStr(mGBC: Integer): string; { 返回区位码所对应的汉字 }
    var
      I, J: Integer;
    begin
      I := mGBC;
      J := I mod 100;
      I := I div 100;
      I := I + cMinGBCByte - 1;
      J := J + cMinGBCByte - 1;
      Result := Chr(I) + Chr(J)
    end; { GBCToStr }