I am opening a .gz file and reading it chunk by chunk for uncompressing it.
The data in the uncompressed file is like : aRSbRScRSd, There are record separators(ASCII code 30) between each record (records in my dummy example a,b,c).
File file = File(mylog.gz, "r");
auto uc = new UnCompress();
foreach (ubyte[] curChunk; file.byChunk(4096*1024))
{
auto uncompressed = cast(string)uc.uncompress(curChunk);
writeln(uncompressed);
auto stringRange = uncompressed.splitLines();
foreach (string line; stringRange)
{
***************** Do something with line
The result of the code above is: abcd unfortunately record separators(ASCII 30) are missing.
I realized by examining the data record separators are missing after I cast ubyte[] to string.
Now I have two questions:
What should I change in the code to keep record separator?
How can I write the code above without for loops? I want to read line by line.
Edit
A more general and understandable code for first question :
ubyte[] temp = [ 65, 30, 66, 30, 67];
writeln(temp);
string tempStr = cast(string) temp;
writeln (tempStr);
Result is : ABC which is not desired.