Re: How to know whether a file's encoding is ansi or utf8?

2014-07-22 Thread Sam Hu via Digitalmars-d-learn
bom[3] == 0xff) return Encoding.UTF32; return Encoding.ASCII; } void main(string[] args) { if(GetFileEncoding("test.txt") == Encoding.UTF8) writeln("The file is UTF8"); else writeln("File is not UTF8 :(");

Re: How to know whether a file's encoding is ansi or utf8?

2014-07-22 Thread Sam Hu via Digitalmars-d-learn
On Tuesday, 22 July 2014 at 11:09:36 UTC, FreeSlave wrote: On Tuesday, 22 July 2014 at 09:50:00 UTC, Sam Hu wrote: Greetings! As subjected,how can I know whether a file is in UTF8 encoding or ansi? Thanks for the help in advance. Regards, Sam By ANSI do you mean Windows code pages? Text

Re: How to know whether a file's encoding is ansi or utf8?

2014-07-22 Thread Sam Hu via Digitalmars-d-learn
On Tuesday, 22 July 2014 at 09:50:00 UTC, Sam Hu wrote: Greetings! As subjected,how can I know whether a file is in UTF8 encoding or ansi? Thanks for the help in advance. Regards, Sam Sorry,I mean by by code,for example,when I try to read a file content and printed to a text control in

How to know whether a file's encoding is ansi or utf8?

2014-07-22 Thread Sam Hu via Digitalmars-d-learn
Greetings! As subjected,how can I know whether a file is in UTF8 encoding or ansi? Thanks for the help in advance. Regards, Sam

Re: MS ODBC encoding issue

2013-01-22 Thread Sam Hu
I've tested and the Chinese character issue really fixed! But I have two more issues here. 1.for connect with DSNless string function provided by my original code as below,I can not make it to connect successfully with really database file.Don't now why yours works. bool connect(string connec

Re: MS ODBC encoding issue

2013-01-22 Thread Sam Hu
On Thursday, 17 January 2013 at 18:36:16 UTC, Regan Heath wrote: On Mon, 14 Jan 2013 10:02:04 -, Regan Heath wrote: Ok, solved the issue I think. Appreciatd all the help and am very excited that it finaly works,WOW! Now I can see (in Visual-D debugger) the Chinese characters in the ro

Re: MS ODBC encoding issue

2013-01-13 Thread Sam Hu
On Monday, 31 December 2012 at 11:01:17 UTC, Regan Heath wrote: On Mon, 24 Dec 2012 07:18:51 -, Sam Hu wrote: On Friday, 21 December 2012 at 15:20:39 UTC, Regan Heath wrote: On Wed, 19 Dec 2012 06:33:16 -, Sam Hu wrote: On Monday, 10 December 2012 at 14:43:08 UTC, Regan Heath

Re: MS ODBC encoding issue

2012-12-23 Thread Sam Hu
On Friday, 21 December 2012 at 15:20:39 UTC, Regan Heath wrote: On Wed, 19 Dec 2012 06:33:16 -, Sam Hu wrote: On Monday, 10 December 2012 at 14:43:08 UTC, Regan Heath wrote: > Ahh, of course. Now I'm having linking issues :p I'm using VisualD and I've added odbc3

Re: MS ODBC encoding issue

2012-12-18 Thread Sam Hu
On Monday, 10 December 2012 at 14:43:08 UTC, Regan Heath wrote: > Ahh, of course. Now I'm having linking issues :p I'm using VisualD and I've added odbc32.lib to the right place, but some symbols are still missing - specifically the W versions. I've dumped the symbols in the DMC odbc32.lib a

Re: Writing unicode strings to the console

2012-12-18 Thread Sam Hu
On Tuesday, 18 December 2012 at 00:29:56 UTC, Jeremy DeHaan wrote: I was playing with unicode strings the other day, and have been searching for a way to correctly write unicode to the console. If I try something like: dstring String = "さいごの果実"; writeln(String); All I get is

Re: MS ODBC encoding issue

2012-12-06 Thread Sam Hu
On Thursday, 6 December 2012 at 16:44:01 UTC, Regan Heath wrote: On Thu, 06 Dec 2012 01:26:32 -, Sam Hu wrote: Known issues: Under console reading Access table recordsets works fine ,inserting a new record which contains only English characters works fine as well,but inserting new

Re: MS ODBC encoding issue

2012-12-05 Thread Sam Hu
Known issues: Under console reading Access table recordsets works fine ,inserting a new record which contains only English characters works fine as well,but inserting new record which contains Chinese character will crash; If calling the fetchAll in a DFL gui form and try to display the res

Re: MS ODBC encoding issue

2012-12-05 Thread Sam Hu
On Wednesday, 5 December 2012 at 11:33:16 UTC, Regan Heath wrote: On Wed, 05 Dec 2012 03:29:50 -, Sam Hu wrote: On Tuesday, 4 December 2012 at 10:05:16 UTC, Nathan M. Swan wrote: I've never used ODBC before, but a quick scan of the MSDN docs suggests that you should use SQL_C_

Re: MS ODBC encoding issue

2012-12-04 Thread Sam Hu
On Tuesday, 4 December 2012 at 10:05:16 UTC, Nathan M. Swan wrote: I've never used ODBC before, but a quick scan of the MSDN docs suggests that you should use SQL_C_WCHAR instead, maybe using some D wstring functions too. BTW, convert sql.ptr -> std.string.toStringz(sql); this is good pract

Re: MS ODBC encoding issue

2012-12-04 Thread Sam Hu
On Tuesday, 4 December 2012 at 10:05:16 UTC, Nathan M. Swan wrote: I've never used ODBC before, but a quick scan of the MSDN docs suggests that you should use SQL_C_WCHAR instead, maybe using some D wstring functions too. BTW, convert sql.ptr -> std.string.toStringz(sql); this is good pract

MS ODBC encoding issue

2012-12-04 Thread Sam Hu
Greetings! Any help would be much appreicated in advance as I've really struggled for quite long time! I wrote a class wrapper for MS ODBC Access database.When I try to run query on an Access database file,all fields contains English character are fine with the result,but for those Asian cha

Re: std.net.curl get webpage asia font issue

2012-06-07 Thread Sam Hu
On Thursday, 7 June 2012 at 10:38:53 UTC, Kevin wrote: On 07/06/12 02:57, Sam Hu wrote: string content = get("dlang.org"); writefln("%s\n",content); So my very simple question is how to retrieve information from a webpage which could possibily contains asia font (like C

Re: std.net.curl get webpage asia font issue

2012-06-07 Thread Sam Hu
On Thursday, 7 June 2012 at 10:43:32 UTC, Dmitry Olshansky wrote: string content = get("dlang.org"); It's simple this line you "convert" whatever site content was to unicode. Problem is that "convert" is either broken or it's simply a cast whereas it should re-encode source as unicode. So th

std.net.curl get webpage asia font issue

2012-06-06 Thread Sam Hu
Greeting! The document on this website provide an example on how to get webpage information by std.net.curl.It is quite straightforward: [code] import std.net.curl, std.stdio; void main(){ // Return a string containing the content specified by an URL string content = get("dlang.org"); write

Can DFL/Entice generate code in classes for (common) controls?

2010-12-02 Thread Sam Hu
MFC wizard can generate code in classes for many windows native controls which are not presented in the resource editor panel.I am wondering can DFL or Entice do the same way for us to make use of these controls? Thanks for your help in advance.

Re: Where is module dstats.all for dflplot?

2010-09-25 Thread Sam Hu
Lars T. Kyllingstad Wrote: > On Sat, 18 Sep 2010 07:15:35 -0400, Sam Hu wrote: > > > Greetings! > > > > I want to have a try on dflplot.But I don't find module dstats.all which > > is used by dflplot.d,could anybody let me where it is? > > > >

Where is module dstats.all for dflplot?

2010-09-18 Thread Sam Hu
Greetings! I want to have a try on dflplot.But I don't find module dstats.all which is used by dflplot.d,could anybody let me where it is? Thank you.

Re: cannot evalute mixin(uuid("bla")) at compile time

2010-08-03 Thread Sam Hu
Richard Webb Wrote: > The Juno library has a 'uuid' that works like that, and the posted example > seems > to build ok here using DMD 1.062. > > Theres also a Tango version of the same code in the dwin library, but i > haven't > tried that for ages. Thank you both for the reply.Sorry for the la

cannot evalute mixin(uuid("bla")) at compile time

2010-08-03 Thread Sam Hu
Base on D1: interface IADsPropertyEntry : IDispatch { mixin(uuid("05792c8e-941f-11d0-8529-00c04fd8d503")); ... Error when compile: argument to mixin must be a string,not mixin(uuid("05792c8e-941f-11d0-8529-00c04fd8d503")) cannot evaluate uuid("05792c8e-941f-11d0-8529-00c04fd8d503")

Re: Solution to print Chinese font in console under D2

2009-12-09 Thread Sam Hu
Kagamin Wrote: Does sutil work? http://pr.stewartsplace.org.uk/d/sutil/ > If not, you can wait for fix for bug 2742 or do it yourself. Thank you very much for your help!Pity I can not access the link ;p

Re: Solution to print Chinese font in console under D2

2009-12-06 Thread Sam Hu
Kagamin Wrote: > Sam Hu Wrote: > > > I asked this question a couple of month ago but it is pending,is there any > > solution now? > > > > Thanks. > > As you know from previous discussions, there're various solutions, which of > them do you want? Sorry,for example?

Re: Startup from registry program doesn't work

2009-12-01 Thread Sam Hu
Richard Webb Wrote: > Is the > > DWORD length=pFileName.sizeof; > > setting length to the size of the pointer, when you need the length of the > string? That would explain why only 4 bytes have been written. > Solved.Thank you so much for your help!

Re: Startup from registry program doesn't work

2009-11-30 Thread Sam Hu
Richard Webb Wrote: > Do you need to be calling RegOpenKeyEx with KEY_WRITE instead of KEY_READ ? > Thanks,I changed to KEY_WRITE and the function now return true when the app executes.However the specified app dosn't start up automatically,when I check the startup settings by some third party

Re: Solution to print Chinese font in console under D2

2009-11-30 Thread Sam Hu
Spacen Jasset Wrote: > Sam Hu wrote: > > Sam Hu Wrote: > > > >> I asked this question a couple of month ago but it is pending,is there any > >> solution now? > >> > >> Thanks. > > Sorry,Windows (XP). > Have you set-up an appropriate c

Re: Solution to print Chinese font in console under D2

2009-11-30 Thread Sam Hu
Sam Hu Wrote: > I asked this question a couple of month ago but it is pending,is there any > solution now? > > Thanks. Sorry,Windows (XP).

Solution to print Chinese font in console under D2

2009-11-30 Thread Sam Hu
I asked this question a couple of month ago but it is pending,is there any solution now? Thanks.

Re: reading files from a directory

2009-11-27 Thread Sam Hu
miriac Wrote: > I really do want to stick to tongo, i instaled it with the instructions in > the tongo book but i can try downlding it again and see if it works > thanks Below link contains information on how to setup Tango workspace: http://www.dsource.org/projects/tango/forums/topic/827 Hope

Startup from registry program doesn't work

2009-11-26 Thread Sam Hu
Greetings! Below program is purpose to execute a program(exe) from registry upon system startup.It was built successfuly,but unfortunately it does not work as expected,nothing would happen.It prints: "Oh..no,not a good doctor." when the program runs. What's problem?It is under DMD2.036 under

Re: How to set non-static variable in static method within class

2009-11-19 Thread Sam Hu
Ary Borenszweig Wrote: > > You can't access non-static data from a static method. Non-static data > is related to an instance of a class, and a static method is not bound > to any instance. > > Why do you want to do that? Say I want to implement an utility dialog, InputDialog in DFL which is

How to set non-static variable in static method within class

2009-11-19 Thread Sam Hu
Greetings! How to set value to non-static variable in a static method within a class? Given below code: import std.stdio; class InputDialog { string name; static string s_name; static this() { s_name="";

Re: anonymous function/delegate usage

2009-11-12 Thread Sam Hu
BCS Wrote: > If the function has no args the first () can be dropped. > If the return type can be inferred, that can be dropped. > Nested functions can access vars in the outer function. > Got it.Thanks a lot!

Re: anonymous function/delegate usage

2009-11-12 Thread Sam Hu
Don Wrote: > You need to call the delegate you've made. I missed this key point. So to summary: int a=1; int b=2; 1.nested function; 2.int c=(int a,int b){return a+b;}(a,b); 3.int c=(int,int){return a+b;}(a,b); 4.int c=(){return a+b;}(); 5.int c={return a+b;}(); How come the last one is legal?

anonymous function/deleget usage

2009-11-12 Thread Sam Hu
How can I reach something like below code: int a=1; int b=2; int c=(int a,int b){ return a+b;} writefln("Result:%d",c); Thanks in advance.

Stdout.formatln crashed dmd1.051

2009-11-10 Thread Sam Hu
import tango.io.Stdout; void main() { Stdout.formatln; } dmd crashed.

Re: DLL under windows

2009-11-10 Thread Sam Hu
Don Wrote: > Beware of bug 3342: at present you CANNOT use DLLs with D2 on Windows XP > or earlier. That's not the problem here, but you need to know it. Just > telling you before you waste lots of time. Thank you very much for letting me know!!

DLL under windows

2009-11-09 Thread Sam Hu
DMD2.036. Under dmd/phobos release package,inside samples\d\mydll folder,there is a sample to write dll and import lib fille from.It compiled and runs fine.But when I try to modify a bit,it produce strange error problem.Kindly refer to the sample for source. In mydll2.d which contains the expor

Long has no effect in expression (0)

2009-11-01 Thread Sam Hu
Given below code segment under DMD1.050 : class COM : OS { ... //public static const int OLEWHICHMK_OBJREL = 2; public static const int S_FALSE = 1; public static const int S_OK = 0 ; //Error ocurred here!! } Got the subjected error message.What does this mean? Th

Re: D and Python Interop

2009-10-21 Thread Sam Hu
Steven Schveighoffer Wrote: > pyd? > > http://dsource.org/projects/pyd > > -Steve Thanks a lot. But it seems dead...

D and Python Interop

2009-10-21 Thread Sam Hu
Is there any implementation that D can interop with Python? Regards, Sam

std.socket again

2009-10-07 Thread Sam Hu
Greetings! Is there anybody kindly write several pieces of code to demonstrate how to use socket in D2.Say ,just download the D main page and print the content in the console should be enough. I tried several days but still got lost.The sample accompany with DMD 2032/3 does not work . Thank

std.socket again

2009-10-07 Thread Sam Hu
Greetings! Is there anybody kindly write several pieces of code to demonstrate how to use socket in D2.Say ,just download the D main page and print the content in the console should be enough. I tried several days but still got lost.The sample accompany with DMD 2032/3 does not work . Thank

Re: Socket sample (and others) in DMD/samples

2009-09-28 Thread Sam Hu
For the sample htmlget.d,after modification again,now it gets compiled,but when it gets running,nothing show in the console: /* HTMLget written by Christopher E. Miller This code is public domain. You may use it for any purpose. This code has no warranties and is

Socket sample (and others) in DMD/samples

2009-09-28 Thread Sam Hu
I was wondering why some of the samples accompany with DMD2032 can not get compiled?If they are not updated together with DMD,why bother include them?It may confuses ppl who are new to D the first time to give D a try but found that it does not work. Given below sample from DMD/samples/d/htmlg

Re: What if gc.disable at all

2009-09-25 Thread Sam Hu
Daniel Keep Wrote: > How about by reading the error message? > > Error 42:Symbol Undefined _D5tango4core6Memory2GC6addrOfFpvZPv > > --> > > Error 42:Symbol Undefined void* tango.core.Memory.GC.addrOf(void*) > > Ergo, you didn't link in tango.core.Memory, which it wants. Thanks a lot.But may I

Re: What if gc.disable at all

2009-09-24 Thread Sam Hu
Tom S Wrote: > As for AAs, you should be able to replace them with Tango's > tango.util.container.HashMap with the > tango.util.container.Container.Container.Malloc (or .Chunk) allocator. > > It might be tricky to find memory leaks due to accidental GC usage, but > you could e.g. hook the GC m

Re: What if gc.disable at all

2009-09-23 Thread Sam Hu
Thank you all for your help! Regards, Sam

What if gc.disable at all

2009-09-23 Thread Sam Hu
Greeting to everybody, If this is too silly a question,please just ignore it. I was wondering what if GC is turned off during the lifetime of the application?Just as if D is a better,safer/unsafer C with class?Can't work?Or some special stuff need to handle? Thanks for your help in advance. Re

Re: Can I use resource file(*.rc,*.res) in D under Win32 API?(Yes)

2009-09-15 Thread Sam Hu
Stewart Gordon Wrote: > No, it's because you put a cast in to suppress the error. > > Stewart. You are right.It is the switch statement.I followed your guide and finally make it.Great! Thank you so much!

Re: Can I use resource file(*.rc,*.res) in D under Win32 API?

2009-09-15 Thread Sam Hu
Stewart Gordon Wrote: > Your problem is right here: In D, switch statements must have default > clauses of there's any chance of the value being switched not matching > any of the switches. If there isn't, a SwitchError is thrown at > runtime. Presumably, the program crashes because there's no

Re: Can I use resource file(*.rc,*.res) in D under Win32 API?

2009-09-14 Thread Sam Hu
Don Wrote: > Sam Hu wrote: > > int DialogFunc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) > > This should be extern(Windows). I'm surprised that compiled, it > shouldn't have. Yes.it compiled even without extern(Windows) ,maybe because I import

Re: Can I use resource file(*.rc,*.res) in D under Win32 API?

2009-09-14 Thread Sam Hu
Thank you so much for your help! Below is the resource file,I compiled it with rcc -32 testd.rc it then generated testd.res. testd.rc: #include 101 DIALOG 129, 26, 180, 70 STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Show Info" FONT 8, "MS Sans Serif" BEGIN EDITTEXT

Can I use resource file(*.rc,*.res) in D under Win32 API?

2009-09-11 Thread Sam Hu
Greetings to everybody! As subjected.I use vc++ to generate a very simple dialog resource,and then compiled with rcc.exe accompanied with dmc: rcc -32 mydialog.rc it generated mydialog.res file. In my main win32 SDK source file,I use DialogBox to try to load the dialog,but it failed. Doesn't

Re: Cannot convert of type HANDLE to HANDLE

2009-09-09 Thread Sam Hu
Ary Borenszweig Wrote: > FQN = Fully Qualified Name Got it.Thanks!

Re: Cannot convert of type HANDLE to HANDLE

2009-09-08 Thread Sam Hu
div0 Wrote: > You must have two different HANDLEs around. > The one in phobos is aliased to void* and there is no LoadLibraryEx call > in phobos, so you must be using something else. > Try using the FQN of the import where you are getting the LoadLibraryEx > from. Thanks for your help. Yeah.I use

Cannot convert of type HANDLE to HANDLE

2009-09-08 Thread Sam Hu
Under DMD 2.032+Window Xp: Can I use HMODULE LoadLibraryEx( LPCTSTR lpFileName, // file name of module HANDLE hFile, // reserved, must be NULL DWORD dwFlags // entry-point execution option ); in D2?Given below code : HMODULE hDll=LoadLibraryEx(toStringz("netmsg.dll"),

Re: A writefln issue or a Thread issue?

2009-09-05 Thread Sam Hu
Fyi: 1.with DMD2032 under windows xp; 2.Tried printf,write,writeln,writef,writefln but all the same result:blank DOS console under current exe path; 3.In c/c++ it opens total 2 DOS windows which works properly: the main one and the one created by CREATE_NEW_CONSOLE ;but in D it opens total 3 DOS

A writefln issue or a Thread issue?

2009-09-05 Thread Sam Hu
Given below code: module testWin32Process; import win32.windows;//get from:http://www.dsource.org/projects/bindings/wiki/WindowsApi import std.string; import std.conv; import std.stdio; import core.stdc.stdlib; string startupProcess() { STARTUPINFO si; si.cb=si.sizeof;

Re: wchar* question

2009-09-03 Thread Sam Hu
Hi both: Thank you so much for your help! ps:just found other than write : wchar* szFileName=cast(wchar[])(new wchar[1024); It works also if I write: wchar[1024] szFileName; I am annoying everytime when pass D strings to/from OS API... Regards, Sam

Re: wchar* question

2009-09-03 Thread Sam Hu
Sorry.Under dmd2.031 ,windows XP

wchar* question

2009-09-03 Thread Sam Hu
Given below code(Win32 SDK): int /*LRESULT*/ wndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch(msg) { case WM_LBUTTONDOWN: {

Enum name convention consistency

2009-08-18 Thread Sam Hu
>From std.range: enum StoppingPolicy { /// Stop when the shortest range is exhausted shortest, /// Stop when the longest range is exhausted longest, /// Require that all ranges are equal requireSameLength, } >From std.thread:( phobos webpage) enum State; A fiber may occup

Re: win32 capCreateCaptureWindow problem

2009-08-17 Thread Sam Hu
John C Wrote: > Those are warnings, not errors. Ignore them, it will compile anyway. Ah ..yes.It work .BTW,just cfw32.lib is needed,no need gdi32.lib to compile. Thank you so much! Regards, Sam

Re: win32 capCreateCaptureWindow problem

2009-08-13 Thread Sam Hu
John C Wrote: > Sam Hu Wrote: > > > John C Wrote: > > > > > Ivan Boritsky wrote: > > > > i work on a win32 application. i try to access my web camera. > > > > when i use this api funtion; > > > > capCreateCaptureWindow(

Re: win32 capCreateCaptureWindow problem

2009-08-12 Thread Sam Hu
John C Wrote: > Ivan Boritsky wrote: > > i work on a win32 application. i try to access my web camera. > > when i use this api funtion; > > capCreateCaptureWindow("cam", WS_VISIBLE + WS_CHILD, 10, 10,266, 252, hWnd, > > 0); > > That should be: WS_VISIBLE | WS_CHILD. > > > > > i get this error:

Re: D1 vs D2 Feature comparison list

2009-07-28 Thread Sam Hu
Jarrett Billingsley Wrote: > http://www.digitalmars.com/d/2.0/features2.html Thank you so much.So silly a question :P

D1 vs D2 Feature comparison list

2009-07-28 Thread Sam Hu
Is there such stuff available in D website? Or the only choice to quick check what features are supported by D2 also supported by D1 is to go through the spec? Thanks in advance. Regards, Sam

Question on rewrite boost.timer with D2.031

2009-07-20 Thread Sam Hu
Sorry for it is a bit long... As an exercise,I was tring to rewrite boost.timer ,boost.progress and the timer_test.cpp program accompany with the boost doc in D2.Although it works now,I compared the two result of the timer_test.cpp & timer_test.d and I found the timing result is quite differen

Re: void myMethod() throw()

2009-07-20 Thread Sam Hu
Lars T. Kyllingstad Wrote: > > Yes, it's called nothrow. :) > > nothrow void myMethod() { ... } > > -Lars Thanks a lot.I have tried to search in section Expression,Statment,Classes ,Handling Errors of D2 spec but no found...

void myMethod() throw()

2009-07-19 Thread Sam Hu
Does D2 has the equivalent implemenation of exception no throw out of a method: void myMethod() throw(){} Or,D2 has its own/better implementation on such feature,if yes,what is that? Thanks in advance. Regards, Sam

Re: Why can't return an object instance by ref?

2009-07-17 Thread Sam Hu
Jarrett Billingsley Wrote: > > Because 'new A' is not an lvalue. Why do you want to return a > reference to a class, anyway? Classes already *are* by reference. Thank you.I got it. So how about q2: but why this one also works? ref createA(){return new A;} // no return type A?

Why can't return an object instance by ref?

2009-07-16 Thread Sam Hu
Hi, With below code: class A { } class B { public: ref A createA() // q2:without type name A is also OK? { return new A;//q1 } } My questions are: q1.why this can't work? q2.I can understand below code works: A createA(){return new A;} but why this one also works? ref createA(){return new

Re: D2 phobos std.date question

2009-07-15 Thread Sam Hu
John C Wrote: > > > > There's a bug in Phobos where the value used to calculate timezone offsets > (localTZA) never gets initialised, because std_date_static_this() is not > called. > > A temporary fix is to import std.datebase. > > John. Thank you so much John!! You help me solved the pro

Re: D2 phobos std.date question

2009-07-14 Thread Sam Hu
Stewart Gordon Wrote: > > Read the source of std.date and see for yourself. If it's getting it > wrong, it suggests either your system is misconfigured or you're using > it wrongly. But since you still haven't posted your code, I still can't > comment further. > > Stewart. Thank you so muc

Re: D2 phobos std.date question

2009-07-13 Thread Sam Hu
Stewart Gordon Wrote: > Sam Hu wrote: > > Which method/ how can I produce proper result of local datetime? > > getUTCtime,UTCtoLocalTime,localTimeToUTC all can not produce the proper > > result. > > > > Could any body help?Thanks. > > Not without se

ulong divides (by) int cause dmd crash

2009-07-12 Thread Sam Hu
Below codes cause dmd crash in dmd2.031,but OK in dmd2.030: module dmdCrash; void main() { ulong num1=100; int num2=10; int result=num1/num2; }

D2 phobos std.date question

2009-07-07 Thread Sam Hu
Which method/ how can I produce proper result of local datetime? getUTCtime,UTCtoLocalTime,localTimeToUTC all can not produce the proper result. Could any body help?Thanks. Regards, Sam

Tango can do it(OT:how to print Chinese font in console in windows)

2009-06-30 Thread Sam Hu
Hello, Just found under DMD1.043_+Tango0.998 I can print Chinese font in console in Windows XP without any extra effort except just saving in Unicode or UTF-8: module test; import tango.io.Stdout; import tango.io.Console; int main(char[][] args) { Stdout.formatln("{}","Öйú");//It works! Cin.g

Re: How to print Chinese characters in console in window XP?

2009-06-27 Thread Sam Hu
Dear All: Thank you so much for all your help! Yes,I am using xp+sp3 Chinese version and can print Chinese font in the console in C++ program: #include int main(int argc,char* argv[]) { std::cout<<"Öйú"<

Re: How to print Chinese characters in console in window XP?

2009-06-27 Thread Sam Hu
and I start cmd.exe with /u switch. I also tried being inspired by below article: http://www.codeproject.com/KB/cpp/unicode_console_output.aspx?display=Print but unfortunately also failed.

Re: How to print Chinese characters in console in window XP?

2009-06-27 Thread Sam Hu
Jarrett Billingsley Wrote: > On Sat, Jun 27, 2009 at 5:53 AM, Sam Hu wrote: > > In DMD2030 I just found that Chinese characters the like can not print > > properly into console. > > > > //Below code does not show output properly in windows console: > > void main(

How to print Chinese characters in console in window XP?

2009-06-27 Thread Sam Hu
In DMD2030 I just found that Chinese characters the like can not print properly into console. //Below code does not show output properly in windows console: void main() { wstring country="Öйú"; writefln(country); } Is this an OS issue or is there any way to reach the goal? Thanks in advance.

std.algorithm.reduce & std.metastrings.Format

2009-06-27 Thread Sam Hu
Below 2 code snippets are both from phobos2.030 source.Compile with 'bud.exe -O -release -cleanup '. 1.std.metastrings: string s=Format!("Arg %s=%s","foo",27); writefln(s);// "Arg foo = 27" can't compile,error msg: testFormat.d(30): Error: cannot implicitly convert expression ("Arg %s=%sfoo27"

Re: Object.factory create instance failed?

2009-06-25 Thread Sam Hu
Ary Borenszweig Wrote: > Sam Hu escribi? > > John C Wrote: > > > >> Object.factory requires a fully qualified class name, so if class Dog > >> resides in module animals, call Object.factory("animals.Dog"). > > > > It works now.Great!Thanks

Re: Object.factory create instance failed?

2009-06-25 Thread Sam Hu
John C Wrote: > Object.factory requires a fully qualified class name, so if class Dog resides > in module animals, call Object.factory("animals.Dog"). It works now.Great!Thanks so much! But...may I ask how do you know that?(requires full name).I went through the object.di but nothing relative

Re: Object.factory create instance failed?

2009-06-25 Thread Sam Hu
Sam Hu Wrote: > The Dmd2.030 spec. said: > > static Object factory(string classname); > Create instance of class specified by classname. The class must either have > no constructors or have a default constructor. > > and said also: > class ClassInfo > st

Object.factory create instance failed?

2009-06-25 Thread Sam Hu
The Dmd2.030 spec. said: static Object factory(string classname); Create instance of class specified by classname. The class must either have no constructors or have a default constructor. and said also: class ClassInfo static ClassInfo find(in char[] classname); Search all modules for ClassI

Re: why __traits not in trait module and not name it trait

2009-06-24 Thread Sam Hu
Thank you so much for your help! Just feel not so good that there are so many "__" in the code when making use of reflection from __traits. Regards, Sam

why __traits not in trait module and not name it trait

2009-06-24 Thread Sam Hu
Yes,__traits did not stole my girl friend,but isn't better to name it trait? And I have thought I can find it in trait moudle but I was wrong.

Re: Three questions on std.range

2009-06-17 Thread Sam Hu
Max Samukha Wrote: > 3. This is a (hackish) way to detect if Range.empty's value is > statically known. Infinite ranges must define a boolean 'empty' member > that evaluates at compile time to false. > > Probably, there should be a more generic way to do it. Something like > isCT(alias expression)

Three questions on std.range

2009-06-16 Thread Sam Hu
Hello, Just get to my point to save time: 1.retro: void testRetro() { int[] arr=[1,2,3,4,5]; auto retArr=retro(arr); for(int i=0;i

Re: Inside the switch statement

2009-06-08 Thread Sam Hu
Thanks so much for all your help!I am studying hard to *loop unrolling*. > BTW: where is this from? It is from the spec: http://www.digitalmars.com/d/1.0/template-mixin.html BTW,is this Duff? http://groups.google.com/group/net.lang.c/msg/66008138e07aa94c

Inside the switch statement

2009-06-08 Thread Sam Hu
To save time ,just get to my point:I do not understand why such code below inside the switch ... case statement is allowed ,what is the point of do ... while...: This example uses a mixin to implement a generic Duff's device for an arbitrary statement (in this case, the arbitrary statement is i

Re: Garbage collection in D

2009-06-03 Thread Sam Hu
> D's performance is unexpectedly bad, so much that I expect that it might > be using dynamic memory allocation anyway despite the 'scope' keyword. I am sorry to hear that,really,really sorry.

Re: Garbage collection in D

2009-06-03 Thread Sam Hu
bearophile Wrote: > I have tried the new JavaVM on Win, that optionally performs escape analysis, > and the results are nice: > > Timings, N=100_000_000, Windows, seconds: > D 1: 40.20 DMD > D 2: 21.83 DMD > D 2: 18.80 DMD, struct + scope > C++: 18.06 > D 1: 8.47 DMD > D 2: 7

Simple file manipulation

2009-05-20 Thread Sam Hu
I looked up in D2 in std.stdio,std.file,std.cstream and std.stream and try to find a very simple method which can read from a file once a value other than once an entire row.I just can not find it maybe this idea is wrong.Say how to simply read & write key/value pairs to and from a file like t

  1   2   >