basic question about text file encodings

Laeeth Isharc via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Apr 16 12:22:39 PDT 2015


What is the best way to figure out and then decode a file of 
unknown coding to dchar?

2½% Index-linked Treasury Stock 
2016,GB0009075325,26-Jul-2016,28-Feb-2014,8 
month,337.810000,338.577874,0.76787400,-1.953546,2.37

Eg I am not sure what encoding the 1/2 is in above, but treating 
it as utf8 leads to an exception.

I will post the answer to the wiki, as it's the typical kind of 
thing that stumps a newcomer to the language.

I can see how to figure out a guess at the file format from 
Tango, but what do I do with the bytes from std.file.read once I 
have guessed the encoding?

And more generally shouldn't we have an easy solution in Phobos 
for this common problem (presuming I am not just overlooking what 
is there?)


More information about the Digitalmars-d-learn mailing list