線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1415
推到 Plurk!
推到 Facebook!

有關wchar_t之宣告一問

尚未結案
kelvin00929
一般會員


發表:6
回覆:6
積分:2
註冊:2004-04-22

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-09-21 19:13:23 IP:192.72.xxx.xxx 未訂閱
請問各位先進: 我想將一串IP宣告成wchar_t的型態,是否要以下列的形式宣告才行: wchar_t DeviceAddress[11]={'1','9','2','.','1','6','8','.','1','.','3'}; 我試過其他的宣告都不行,這是唯一的宣告形式嗎?
justdo
高階會員


發表:2
回覆:359
積分:222
註冊:2004-08-17

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-09-21 19:56:31 IP:221.169.xxx.xxx 未訂閱
應該有簡單的可行方法,不過我不清楚 但你可以先用這種方式..     AnsiString a("192.168.1.1"); wchar_t *w=new wchar_t[a.WideCharBufSize() 1]; a.WideChar(w, a.WideCharBufSize()); .... delete [] w;
bass15
高階會員


發表:24
回覆:171
積分:119
註冊:2003-10-27

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-09-22 09:43:39 IP:61.66.xxx.xxx 未訂閱
WideString DeviceAddress="192.168.1.3"; 這樣不知道符不符合你的要求阿?? WideString represents strings of 16-bit characters (wchar_t). As such, it is useful when working with COM. WideString values are easily converted to or from BSTR values. WideString also supports sharing the value of an existing BSTR. The C class WideString is functionally equivalent to an Object Pascal intrinsic type, also called WideString.
kelvin00929
一般會員


發表:6
回覆:6
積分:2
註冊:2004-04-22

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-09-22 10:46:04 IP:220.228.xxx.xxx 未訂閱
引言: WideString DeviceAddress="192.168.1.3"; 這樣不知道符不符合你的要求阿?? WideString represents strings of 16-bit characters (wchar_t). As such, it is useful when working with COM. WideString values are easily converted to or from BSTR values. WideString also supports sharing the value of an existing BSTR. The C class WideString is functionally equivalent to an Object Pascal intrinsic type, also called WideString.
謝謝你,這樣可以用了, 可是我還是有一點不懂, 因為我有import 一個VC 寫的OCX, 其中一個method的參數所需的type即為wchar_t, 但如果我以我上面所說或是依照justdo大大所說的宣告, 雖然可以compile,但是在執行時都會有很奇怪的錯誤發生, 這三種宣告方式難道不一樣嗎?
way99
一般會員


發表:10
回覆:10
積分:4
註冊:2003-06-16

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-09-24 17:24:08 IP:140.125.xxx.xxx 未訂閱
wchar_t 字符的宣告方式要用 L'' wchar_t 字串的宣告方式要用 L""    EX:
wchar_t wc=L'我';
wchar_t wc1=L'\x0041';          // == L'A'
wchar_t wstr[]=L"三二一";
wchar_t wstr1[]=L"A\x0042"L"C"; // == L"ABC"
Compiler 會自動將字串轉成 Unicode 格式。
系統時間:2024-06-30 14:32:06
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!