请问如何将一段unicode编码转成一段二进制编码. 求实例! 急!

解决方案 »

  1.   

    先用IntToHex
    再根据'0','1','2'...'D','E','F'和'0000','0001','0010'...'1101','1110','1111'的对应关系转化为二进制字符串
      

  2.   

    ShowMessage(UnicodeToBinary('......'));
    function UnicodeToBinary(W:WideString):string;
    function getSingleChar(W:WideChar):string;
        var tmp:DWORD;sOut:string;iPos:integer;
        begin
            CopyMemory(@tmp,@W,2);
            sOut:='';
            for iPos:=1 to 16 do
            begin
                if (tmp and 1)=1 then sOut:=sout+'1' else sOut:=sOut+'0';
                tmp:=tmp shr 1;
            end;
            Result:=sOut;
        end;
    var s:string;i:integer;
    begin
        for i:=1 to length(w) do
            s:=s+getSingleChar(w[i]);
        Result:=s;
    end;