Re: std.file: read, readText and UTF-8 decoding

2023-09-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, September 22, 2023 12:28:39 AM MDT Uranuz via Digitalmars-d-learn wrote: > OK. Thanks for response. I wish that there it was some API to > handle it "out of the box". Do I need to write some issue or > something in order to not forget about this? You can open an issue if you want, thou

Re: std.file: read, readText and UTF-8 decoding

2023-09-21 Thread Uranuz via Digitalmars-d-learn
OK. Thanks for response. I wish that there it was some API to handle it "out of the box". Do I need to write some issue or something in order to not forget about this?

Re: std.file: read, readText and UTF-8 decoding

2023-09-21 Thread Jonathan M Davis via Digitalmars-d-learn
o width or endian conversions are performed. So, if > the width or endianness of the characters in the given file > differ from the width or endianness of the element type of S, > then validation will fail. > """ > So it's OK. But I understood that this function

Re: std.file: read, readText and UTF-8 decoding

2023-09-21 Thread Uranuz via Digitalmars-d-learn
Addition: Current solution to this problemme that I was found is: So I just check for BOM manually. Get length of bom.sequence and remove that count of items from beginning. But I dont' think that it's convenient solution, because `who knows` how much else issues with UTF could happend. And I d

std.file: read, readText and UTF-8 decoding

2023-09-21 Thread Uranuz via Digitalmars-d-learn
ess of the element type of S, then validation will fail. """ So it's OK. But I understood that this function "readText" is not usefull for me. So I tried to use plain "read" that returns "void[]". Problemmme is that I still don't understand wh

Re: How to use readText to read utf16 file?

2021-06-21 Thread Emil Perhinschi via Digitalmars-d-learn
On Tuesday, 17 November 2015 at 13:00:11 UTC, Gary Willoughby wrote: On Tuesday, 17 November 2015 at 02:40:14 UTC, Domain wrote: How to use readText to read utf16 file? Or other encoding file. Here's a helpful resource when working with text files in D. http://nomad.so/2015/09/working

Re: readText with added null-terminator that enables sentinel-based search

2017-08-09 Thread Marco Leise via Digitalmars-d-learn
Am Tue, 08 Aug 2017 20:48:39 + schrieb Nordlöw : > Has anybody written a wrapper around `std.file.readText` (or > similar) that appends a final zero-byte terminator in order to > realize sentinel-based search in textual parsers. What do you mean by similar? There are many ways to load a fil

readText with added null-terminator that enables sentinel-based search

2017-08-08 Thread Nordlöw via Digitalmars-d-learn
Has anybody written a wrapper around `std.file.readText` (or similar) that appends a final zero-byte terminator in order to realize sentinel-based search in textual parsers.

Re: D doesn't read the first character of a file (reads everything but the first chararacter) with either read() or readText()

2017-07-19 Thread bauss via Digitalmars-d-learn
On Wednesday, 19 July 2017 at 15:18:00 UTC, Steven Schveighoffer wrote: On 7/17/17 10:21 PM, Enjoys Math wrote: DMD32 D Compiler v2.074.1 import std.file; void main() { string bigInput = readText("input.txt"); } The file is 7 MB of ascii text, don't know if that matte

Re: D doesn't read the first character of a file (reads everything but the first chararacter) with either read() or readText()

2017-07-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/17/17 10:21 PM, Enjoys Math wrote: DMD32 D Compiler v2.074.1 import std.file; void main() { string bigInput = readText("input.txt"); } The file is 7 MB of ascii text, don't know if that matters... Should I upgrade versions? Looking at the implementation of readText

Re: D doesn't read the first character of a file (reads everything but the first chararacter) with either read() or readText()

2017-07-18 Thread Sebastien Alaiwan via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 02:21:59 UTC, Enjoys Math wrote: DMD32 D Compiler v2.074.1 import std.file; void main() { string bigInput = readText("input.txt"); } The file is 7 MB of ascii text, don't know if that matters... Should I upgrade versions? Could you please sha

Re: D doesn't read the first character of a file (reads everything but the first chararacter) with either read() or readText()

2017-07-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 02:21:59 UTC, Enjoys Math wrote: DMD32 D Compiler v2.074.1 import std.file; void main() { string bigInput = readText("input.txt"); } The file is 7 MB of ascii text, don't know if that matters... Should I upgrade versions? I wonder if it thinks

D doesn't read the first character of a file (reads everything but the first chararacter) with either read() or readText()

2017-07-17 Thread Enjoys Math via Digitalmars-d-learn
DMD32 D Compiler v2.074.1 import std.file; void main() { string bigInput = readText("input.txt"); } The file is 7 MB of ascii text, don't know if that matters... Should I upgrade versions?

Re: How to use readText to read utf16 file?

2015-11-17 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 17 November 2015 at 02:40:14 UTC, Domain wrote: How to use readText to read utf16 file? Or other encoding file. Here's a helpful resource when working with text files in D. http://nomad.so/2015/09/working-with-files-in-the-d-programming-language/

Re: How to use readText to read utf16 file?

2015-11-17 Thread ponce via Digitalmars-d-learn
On Tuesday, 17 November 2015 at 05:37:55 UTC, Domain wrote: Thank you! Now another question: how to handle endianness? If your file follow a file format: the endianness should be defined there. else it's a random text file: either it will have a BOM with endianness, or you will hav

Re: How to use readText to read utf16 file?

2015-11-16 Thread Domain via Digitalmars-d-learn
On Tuesday, 17 November 2015 at 03:12:47 UTC, Steven Schveighoffer wrote: On 11/16/15 10:00 PM, Adam D. Ruppe wrote: On Tuesday, 17 November 2015 at 02:50:44 UTC, Domain wrote: Thanks! But how to remove BOM? Slice the result myself? Yeah. Do something like if(result.length &&result[0] == bom)

Re: How to use readText to read utf16 file?

2015-11-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/16/15 10:00 PM, Adam D. Ruppe wrote: On Tuesday, 17 November 2015 at 02:50:44 UTC, Domain wrote: Thanks! But how to remove BOM? Slice the result myself? Yeah. Do something like if(result.length &&result[0] == bom) { result = result[1..$]; } and you'll have it. To be technically correct

Re: How to use readText to read utf16 file?

2015-11-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 17 November 2015 at 02:50:44 UTC, Domain wrote: Thanks! But how to remove BOM? Slice the result myself? Yeah. Do something like if(result.length &&result[0] == bom) { result = result[1..$]; } and you'll have it.

Re: How to use readText to read utf16 file?

2015-11-16 Thread Domain via Digitalmars-d-learn
On Tuesday, 17 November 2015 at 02:42:29 UTC, Adam D. Ruppe wrote: On Tuesday, 17 November 2015 at 02:40:14 UTC, Domain wrote: How to use readText to read utf16 file? readText!wstring("filename") should do it for utf16. It will return a wstring, which is utf-16. You can do

How to use readText to read utf16 file?

2015-11-16 Thread Domain via Digitalmars-d-learn
How to use readText to read utf16 file? Or other encoding file.

Re: How to use readText to read utf16 file?

2015-11-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 17 November 2015 at 02:40:14 UTC, Domain wrote: How to use readText to read utf16 file? readText!wstring("filename") should do it for utf16. It will return a wstring, which is utf-16. You can do utf32 with readText!dstring. The default, of course, is string, which is

Re: readText for large files on Windows.

2015-04-19 Thread Kenny via Digitalmars-d-learn
Thanks. The bug is created. https://issues.dlang.org/show_bug.cgi?id=14469

Re: readText for large files on Windows.

2015-04-19 Thread Rikki Cattermole via Digitalmars-d-learn
On 20/04/2015 7:06 a.m., Kenny wrote: This function works fine for large text files like 100Mb or 1Gb but failed when I tried to read 6Gb file. This happens on Windows x64. The possible reason that it uses read(in char[], size_t) function and on windows it calls GetFileSize. This function return

readText for large files on Windows.

2015-04-19 Thread Kenny via Digitalmars-d-learn
This function works fine for large text files like 100Mb or 1Gb but failed when I tried to read 6Gb file. This happens on Windows x64. The possible reason that it uses read(in char[], size_t) function and on windows it calls GetFileSize. This function returns file size as 32 bit value. If you

Re: readText

2013-06-19 Thread Justin Whear
On Wed, 19 Jun 2013 20:18:17 +0200, Daemon wrote: > Was readText removed in later versions of Phobos? I don't have it, yet > it appears in the documentation.. std.file.readText has been around for a long time and still is. Here it is in Phobos HEAD: https://github.com/D-Programmi

Re: readText

2013-06-19 Thread Daemon
On Wednesday, 19 June 2013 at 18:18:18 UTC, Daemon wrote: Was readText removed in later versions of Phobos? I don't have it, yet it appears in the documentation.. Sorry for the false alarm, I accidentally had a different copy. Everything's alright.

Re: readText

2013-06-19 Thread Daemon
On Wednesday, 19 June 2013 at 18:21:09 UTC, Justin Whear wrote: On Wed, 19 Jun 2013 20:18:17 +0200, Daemon wrote: Was readText removed in later versions of Phobos? I don't have it, yet it appears in the documentation.. std.file.readText has been around for a long time and still is. He

readText

2013-06-19 Thread Daemon
Was readText removed in later versions of Phobos? I don't have it, yet it appears in the documentation..

Re: readText fails to open file

2012-06-17 Thread GreatEmerald
On Sunday, 17 June 2012 at 08:35:58 UTC, Jonathan M Davis wrote: Also, you need to check exists before you check isFile, otherwise isFile will blow up if the file doesn't exst. And both of those are properties, so you should be calling them like auto filename = args[1]; if(!filename.exists ||

Re: readText fails to open file

2012-06-17 Thread GreatEmerald
Oh, I just figured out what was going wrong. Apparently, args[0] is the path to the program itself, and not the first argument. args[1] is what I need to start reading from!

Re: readText fails to open file

2012-06-17 Thread Jonathan M Davis
On Sunday, June 17, 2012 10:21:17 GreatEmerald wrote: > This is kind of silly, and I probably missed something, but for > some reason I can't get any kind of text file opened when using > readText from std.file. This is what I'm trying to do: > >import std.st

Re: readText fails to open file

2012-06-17 Thread Ali Çehreli
On 06/17/2012 01:21 AM, GreatEmerald wrote: This is kind of silly, and I probably missed something, but for some reason I can't get any kind of text file opened when using readText from std.file. This is what I'm trying to do: import std.stdio; import std.file; int main(string[]

Re: readText fails to open file

2012-06-17 Thread Dmitry Olshansky
On 17.06.2012 12:21, GreatEmerald wrote: This is kind of silly, and I probably missed something, but for some reason I can't get any kind of text file opened when using readText from std.file. This is what I'm trying to do: import std.stdio; import std.file; int main(string[]

readText fails to open file

2012-06-17 Thread GreatEmerald
This is kind of silly, and I probably missed something, but for some reason I can't get any kind of text file opened when using readText from std.file. This is what I'm trying to do: import std.stdio; import std.file; int main(string[] args) { if (!isF