digitalmars.D - Issue with writefln ?
- 0ffh (16/16) Apr 04 2007 Hija,
- Marcin Kuszczak (12/38) Apr 04 2007 I think that your file has non UTF-8 characters inside (characters with
- BCS (6/32) Apr 04 2007 unless it is being used from a format string, all char[] are assumed to
- 0ffh (2/9) Apr 04 2007 Works and is soundly explained! Cheers to you, good sir! :)
- Dan (2/9) Apr 04 2007 Wow! I never thought of that. (sincerely) I'll be sure to do that in...
- Frank Benoit (keinfarbton) (4/4) Apr 04 2007 hehe, i am your neighbor :)
- 0ffh (8/12) Apr 04 2007 I have sent pm to you, but no reply yet,
Hija,
I get an exception (std.format string) thrown
after I read a file with std.file.read and try
to writefln its content, while it works fine
with toStringz and printf.
Code is something like:
char[] s=cast(char[])stf.file.read("name.ext");
printf("<%s>\n",toStringz(s)); // works fine
writelnf("<",s,">"); // exception generated
I have shrunk the file to:
garble"%"urgh
I do strongly suppose that the problem lies
somewhere in part saying "%" , but... ?
Is this a Hemiptera? :-)
Regards,
frank
Apr 04 2007
0ffh wrote:
Hija,
I get an exception (std.format string) thrown
after I read a file with std.file.read and try
to writefln its content, while it works fine
with toStringz and printf.
Code is something like:
char[] s=cast(char[])stf.file.read("name.ext");
printf("<%s>\n",toStringz(s)); // works fine
writelnf("<",s,">"); // exception generated
I have shrunk the file to:
garble"%"urgh
I do strongly suppose that the problem lies
somewhere in part saying "%" , but... ?
Is this a Hemiptera? :-)
Regards,
frank
I think that your file has non UTF-8 characters inside (characters with
codes >= 128).
char[] is in D UTF8 sequence.
You probably should first recode your file.
--
Regards
Marcin Kuszczak (Aarti_pl)
-------------------------------------
Ask me why I believe in Jesus - http://zapytaj.dlajezusa.pl (en/pl)
Doost (port of few Boost libraries) - http://www.dsource.org/projects/doost/
-------------------------------------
Apr 04 2007
0ffh wrote:
Hija,
I get an exception (std.format string) thrown
after I read a file with std.file.read and try
to writefln its content, while it works fine
with toStringz and printf.
Code is something like:
char[] s=cast(char[])stf.file.read("name.ext");
printf("<%s>\n",toStringz(s)); // works fine
writelnf("<",s,">"); // exception generated
I have shrunk the file to:
garble"%"urgh
I do strongly suppose that the problem lies
somewhere in part saying "%" , but... ?
Is this a Hemiptera? :-)
Regards,
frank
unless it is being used from a format string, all char[] are assumed to
be format strings. Try this:
writelnf("<%s>",s);
In general it is bad practice to have a non literal string used in
writef/writelnf unless you only reference it by way of a format string.
Apr 04 2007
BCS wrote:
unless it is being used from a format string, all char[] are assumed to
be format strings. Try this:
writelnf("<%s>",s);
In general it is bad practice to have a non literal string used in
writef/writelnf unless you only reference it by way of a format string.
Works and is soundly explained! Cheers to you, good sir! :)
Apr 04 2007
BCS Wrote:
unless it is being used from a format string, all char[] are assumed to
be format strings. Try this:
writelnf("<%s>",s);
In general it is bad practice to have a non literal string used in
writef/writelnf unless you only reference it by way of a format string.
Wow! I never thought of that. (sincerely) I'll be sure to do that in the
future.
Apr 04 2007
hehe, i am your neighbor :) I am driving everyday through LB. Frank http://www.frappr.com/d
Apr 04 2007
Frank Benoit (keinfarbton) wrote:hehe, i am your neighbor :) I am driving everyday through LB. Frank http://www.frappr.com/dI have sent pm to you, but no reply yet, hope I got the despamming right... otherwise you may want to mail me? Regards, Frank p.s. The address /does/ actually work, as of now... otherwise try frank at etc...
Apr 04 2007









Marcin Kuszczak <aarti interia.pl> 