refuses to open file

Ali Çehreli acehreli at yahoo.com
Wed Apr 17 20:57:00 PDT 2013


On 04/17/2013 04:48 PM, rbtwms at digitalpath.net wrote:

I said:

 > That doesn't look right: char is a UTF-8 code unit. Unless you are sure
 > that the file contains UTF-8, I recommend you use something else, e.g.
 > ubyte.

You said:

 > It' a pure ascii file.

That means that every byte value in the file is in the range [0, 127], 
right? ASCII...

 >      string c = to!string (buf[107..111]);

For that to work, every one of those bytes must be in the range [0, 127].

 >      if (c == "    ") break;
 >      int z = to!int(c);

The fact that you are trying to convert those four bytes to a 32 value 
makes me think that the file is not "pure ascii" after all. Unless the 
int value written in that location of the file has the property that 
none of the four 8 bits of it are above 127.

However, I don't understand whether your actual problem is related to that.

Ali



More information about the Digitalmars-d-learn mailing list