Re: Reading unicode string with readf (%s)

2014-11-04 Thread Kagamin via Digitalmars-d-learn
https://issues.dlang.org/show_bug.cgi?id=12990 this?

Re: Reading unicode string with readf (%s)

2014-11-04 Thread anonymous via Digitalmars-d-learn
On Monday, 3 November 2014 at 19:37:20 UTC, Ivan Kazmenko wrote: Hi! The following code does not correctly handle Unicode strings. - import std.stdio; void main () { string s; readf (%s, s); write (s); } - Example input (Test. in cyrillic): - Тест. -

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 3 November 2014 at 20:03:03 UTC, Ali Çehreli wrote: On 11/03/2014 11:47 AM, Ivan Kazmenko wrote: On Monday, 3 November 2014 at 19:37:20 UTC, Ivan Kazmenko wrote: readf (%s, s); Worth noting: this reads to end-of-file (not end-of-line or whitespace), and reading the whole file

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 3 November 2014 at 20:10:02 UTC, Gary Willoughby wrote: On Monday, 3 November 2014 at 19:47:17 UTC, Ivan Kazmenko wrote: So, if there is an idiomatic way to read the whole file into a string which is Unicode-compatible, it would be great to learn that, too. Maybe something like

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 11:46:24 UTC, Kagamin wrote: https://issues.dlang.org/show_bug.cgi?id=12990 this? Similar, but not quite that. Bugs 12990 and 1448 (linked from there) seem to have Windows console as an important part of the process. For me, the example does not work even

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 13:01:48 UTC, anonymous wrote: On Monday, 3 November 2014 at 19:37:20 UTC, Ivan Kazmenko wrote: Hi! The following code does not correctly handle Unicode strings. - import std.stdio; void main () { string s; readf (%s, s); write (s); }

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 18:09:48 UTC, Ivan Kazmenko wrote: On Monday, 3 November 2014 at 20:10:02 UTC, Gary Willoughby wrote: On Monday, 3 November 2014 at 19:47:17 UTC, Ivan Kazmenko wrote: So, if there is an idiomatic way to read the whole file into a string which is

Reading unicode string with readf (%s)

2014-11-03 Thread Ivan Kazmenko via Digitalmars-d-learn
Hi! The following code does not correctly handle Unicode strings. - import std.stdio; void main () { string s; readf (%s, s); write (s); } - Example input (Test. in cyrillic): - Тест. - (hex: D0 A2 D0 B5 D1 81 D1 82 2E 0D 0A) Example output: -

Re: Reading unicode string with readf (%s)

2014-11-03 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 3 November 2014 at 19:37:20 UTC, Ivan Kazmenko wrote: readf (%s, s); Worth noting: this reads to end-of-file (not end-of-line or whitespace), and reading the whole file into a string was what I indeed expected it to do. So, if there is an idiomatic way to read the whole

Re: Reading unicode string with readf (%s)

2014-11-03 Thread Ali Çehreli via Digitalmars-d-learn
On 11/03/2014 11:47 AM, Ivan Kazmenko wrote: On Monday, 3 November 2014 at 19:37:20 UTC, Ivan Kazmenko wrote: readf (%s, s); Worth noting: this reads to end-of-file (not end-of-line or whitespace), and reading the whole file into a string was what I indeed expected it to do. So, if there

Re: Reading unicode string with readf (%s)

2014-11-03 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 3 November 2014 at 19:47:17 UTC, Ivan Kazmenko wrote: So, if there is an idiomatic way to read the whole file into a string which is Unicode-compatible, it would be great to learn that, too. Maybe something like this: import std.stdio; import std.array; import std.conv; string