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 :(");
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
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
Greetings!
As subjected,how can I know whether a file is in UTF8 encoding or
ansi?
Thanks for the help in advance.
Regards,
Sam
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
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
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
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
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
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
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
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
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_
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
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
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
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
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
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
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.
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?
> >
> >
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.
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
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")
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
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?
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!
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
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
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).
I asked this question a couple of month ago but it is pending,is there any
solution now?
Thanks.
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
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
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
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="";
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!
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?
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.
import tango.io.Stdout;
void main()
{
Stdout.formatln;
}
dmd crashed.
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!!
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
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
Steven Schveighoffer Wrote:
> pyd?
>
> http://dsource.org/projects/pyd
>
> -Steve
Thanks a lot.
But it seems dead...
Is there any implementation that D can interop with Python?
Regards,
Sam
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
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
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
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
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
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
Thank you all for your help!
Regards,
Sam
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
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!
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
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
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
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
Ary Borenszweig Wrote:
> FQN = Fully Qualified Name
Got it.Thanks!
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
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"),
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
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;
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
Sorry.Under dmd2.031 ,windows XP
Given below code(Win32 SDK):
int /*LRESULT*/ wndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch(msg)
{
case WM_LBUTTONDOWN:
{
>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
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
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(
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:
Jarrett Billingsley Wrote:
> http://www.digitalmars.com/d/2.0/features2.html
Thank you so much.So silly a question :P
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
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
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...
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
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?
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
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
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
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
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;
}
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
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
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<<"Öйú"<
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.
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(
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.
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"
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
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
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
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
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
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.
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)
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
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
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
> 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.
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
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 - 100 of 143 matches
Mail list logo