Greetings!
As subjected,how can I know whether a file is in UTF8 encoding or
ansi?
Thanks for the help in advance.
Regards,
Sam
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
On Tuesday, 22 July 2014 at 07:58:50 UTC, Puming wrote:
Is there a fork()/wait() API similar to std.concurrency spawn()?
The best thing I've got so far is module
core.sys.posix.unistd.fork(), but it seems to only work in
posix. Is there a unified API for process level concurrency?
ideally
Read the BOM ?
module main;
import std.stdio;
enum Encoding
{
UTF7,
UTF8,
UTF32,
Unicode,
BigEndianUnicode,
ASCII
};
Encoding GetFileEncoding(string fileName)
{
import std.file;
auto bom = cast(ubyte[]) read(fileName, 4);
On Saturday, 19 July 2014 at 11:12:00 UTC, Marc Schütz wrote:
Casting to pure would break purity if the called function is
not actually pure. AFAIU, the problem is that the mutable
function pointers are not accessible from inside the pure
function at all, in which case the solution is to cast
I've only found spawnProcess/spawnShell and the like, which
executes a new command, but not a function pointer, like fork()
and std.concurrency.spawn does.
What is the function that does what I describe?
On Tuesday, 22 July 2014 at 10:43:58 UTC, FreeSlave wrote:
On Tuesday, 22 July 2014 at
On Tuesday, 22 July 2014 at 11:59:34 UTC, Alexandre wrote:
Read the BOM ?
module main;
import std.stdio;
enum Encoding
{
UTF7,
UTF8,
UTF32,
Unicode,
BigEndianUnicode,
ASCII
};
Encoding GetFileEncoding(string fileName)
{
import std.file;
Note that BOMs are optional and may be not presented in Unicode
file. Also presence of leading bytes which look BOM does not
necessarily mean that file is encoded in some kind of Unicode.
I'm just confused about how static while is supposed to work
because static foreach, to my understanding, would have to work
by making a new type for each iteration. I say this because, 1)
runtime foreach works like that (with type = range), and 2)
without ctfe foreach, the only way I know of
http://www.architectshack.com/TextFileEncodingDetector.ashx
On Tuesday, 22 July 2014 at 15:53:23 UTC, FreeSlave wrote:
Note that BOMs are optional and may be not presented in Unicode
file. Also presence of leading bytes which look BOM does not
necessarily mean that file is encoded in some kind
On Tuesday, 22 July 2014 at 14:26:05 UTC, Puming wrote:
I've only found spawnProcess/spawnShell and the like, which
executes a new command, but not a function pointer, like fork()
and std.concurrency.spawn does.
What is the function that does what I describe?
On Tuesday, 22 July 2014 at
On Tue, Jul 22, 2014 at 03:52:14PM +, Vlad Levenfeld via
Digitalmars-d-learn wrote:
I'm just confused about how static while is supposed to work because
static foreach, to my understanding, would have to work by making a
new type for each iteration. I say this because, 1) runtime foreach
I have been writing several lexers and parsers. The grammars I
need to
parse are really complex, and consequently I didn't feel
confident about
the code quality, especially in the lexers. So I decided to jump
on the functional progamming bandwagon to see if that would help.
It definitely
Eric:
while (!buf.empty())
{
p++;
buf.popFront();
Those () can be omitted, if you mind the noise (but you can also
keep them).
if (buf.front() = '0' || buf.front() = '9') break;
std.ascii.isDigit helps.
curTok.image = cast(string) cbuffer[0 .. (p -
On Tuesday, 22 July 2014 at 16:50:47 UTC, Eric wrote:
private void getNumber(MCInputStreamRange buf)
{
auto s = buf.until(a = '0' || a = '9');
curTok.kind = Token_t.NUMBER;
curTok.image = to!string(s);
}
The problem is that until seems to not stop at the end of the
number,
and
By the way, do you really mean to stop on '0' and '9'? Do you
perhaps mean a '0' || a '9'?
Yes, my bad...
On Tuesday, 22 July 2014 at 17:09:29 UTC, bearophile wrote:
Eric:
while (!buf.empty())
{
p++;
buf.popFront();
Those () can be omitted, if you mind the noise (but you can
also keep them).
if (buf.front() = '0' || buf.front() = '9') break;
std.ascii.isDigit
On Tuesday, 22 July 2014 at 17:09:29 UTC, bearophile wrote:
Eric:
while (!buf.empty())
{
p++;
buf.popFront();
Those () can be omitted, if you mind the noise (but you can
also keep them).
Actually, the ones behind `empty` and `front` are wrong, because
these are
On Tuesday, 22 July 2014 at 16:42:14 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
On Tue, Jul 22, 2014 at 03:52:14PM +, Vlad Levenfeld via
Digitalmars-d-learn wrote:
Anyway my actual question is: if all values are constant at
compile
time, how would a static while loop terminate?
Yes, though the loop unrolling is news to me. I'll have to keep
that in mind next time I'm trying to squeeze some extra
performance out of a loop.
btw, found a static switch enhancement request here:
https://issues.dlang.org/show_bug.cgi?id=6921
20 matches
Mail list logo