Delphi Unicode |
|
is_tem
一般會員 發表:17 回覆:15 積分:11 註冊:2002-04-17 發送簡訊給我 |
|
h@visli
資深會員 發表:103 回覆:429 積分:431 註冊:2004-02-13 發送簡訊給我 |
<textarea class="delphi" rows="10" cols="60" name="code">procedure TForm1.Button1Click(Sender: TObject);
var
s: WideString;
c: integer;
i: Integer;
begin
s := '中文字';
for i := 1 to Length(s) do
begin
c := Ord(s[i]);
Edit1.Text := Edit1.Text IntToStr(c shr 8) ', ' IntToStr(c and $FF) ', ';
end;
end;</textarea><br />
希望有更好的方法! <textarea class="c#" rows="10" cols="60" name="code"> using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string s = "中文字"; byte[] bts = System.Text.Encoding.Unicode.GetBytes(s); PrintHexBytes(bts); Console.ReadLine(); } public static void PrintHexBytes(byte[] bytes) { if ((bytes == null) || (bytes.Length == 0)) Console.WriteLine("
------
------------------------ 博采眾家之長,奉獻綿薄之力 ------------------------ |
h@visli
資深會員 發表:103 回覆:429 積分:431 註冊:2004-02-13 發送簡訊給我 |
Sorry, 前面寫倒了,正確的應該是:
<textarea class="delphi" rows="10" cols="60" name="code"> procedure TForm1.Button1Click(Sender: TObject); var s: WideString; c: integer; i: Integer; begin s := '中文字'; for i := 1 to Length(s) do begin c := Ord(s[i]); Edit1.Text := Edit1.Text IntToStr(c and $FF) ', ' IntToStr(c shr 8) ', '; end; end; </textarea>
------
------------------------ 博采眾家之長,奉獻綿薄之力 ------------------------ |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |