Re: lower case only first letter of word

2017-12-06 Thread codephantom via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 13:31:17 UTC, Marc wrote: Does D have a native function to capitalize only the first letter of the word? (I'm asking that so I might avoid reinvent the wheel, which I did sometimes in D) // module test; import std.stdio; void main() {

Re: lower case only first letter of word

2017-12-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/5/17 2:41 PM, kdevel wrote: On Tuesday, 5 December 2017 at 17:25:57 UTC, Steven Schveighoffer wrote: [...] struct LowerCaseFirst(R) // if(isSomeString!R) {    R src;    bool notFirst; // terrible name, but I want default false    dchar front() {   import std.uni: toLower;   return

Re: lower case only first letter of word

2017-12-05 Thread Ali Çehreli via Digitalmars-d-learn
On 12/05/2017 11:41 AM, kdevel wrote: On Tuesday, 5 December 2017 at 17:25:57 UTC, Steven Schveighoffer wrote: But one cannot use the return value of lowerCaseFirst as argument for foo(string). Only the use as argument to writeln seems to work. That's how ranges work. LowerCaseFirst

Re: lower case only first letter of word

2017-12-05 Thread kdevel via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 17:25:57 UTC, Steven Schveighoffer wrote: [...] struct LowerCaseFirst(R) // if(isSomeString!R) { R src; bool notFirst; // terrible name, but I want default false dchar front() { import std.uni: toLower; return notFirst ? src.front :

Re: lower case only first letter of word

2017-12-05 Thread Ali Çehreli via Digitalmars-d-learn
On 12/05/2017 09:25 AM, Steven Schveighoffer wrote: Non-allocating version: struct LowerCaseFirst(R) // if(isSomeString!R) {    R src;    bool notFirst; // terrible name, but I want default false    dchar front() {   import std.uni: toLower;   return notFirst ? src.front :

Re: lower case only first letter of word

2017-12-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/5/17 10:00 AM, Mengu wrote: On Tuesday, 5 December 2017 at 14:34:57 UTC, Mengu wrote: On Tuesday, 5 December 2017 at 14:01:35 UTC, Marc wrote: On Tuesday, 5 December 2017 at 13:40:08 UTC, Daniel Kozak wrote: [...] Yes, this is not what I want. I want to convert only the first letter

Re: lower case only first letter of word

2017-12-05 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-05 15:34, Mengu wrote: this is how i'd do it: string upcaseFirst(string wut) {   import std.ascii : toUpper;   import std.array : appender;   auto s = appender!string;   s ~= wut[0].toUpper;   s ~= wut[1..$];   return s.data; } That's not Unicode aware and is only safe to

Re: lower case only first letter of word

2017-12-05 Thread Mengu via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 14:34:57 UTC, Mengu wrote: On Tuesday, 5 December 2017 at 14:01:35 UTC, Marc wrote: On Tuesday, 5 December 2017 at 13:40:08 UTC, Daniel Kozak wrote: [...] Yes, this is not what I want. I want to convert only the first letter of the word to lower case and left

Re: lower case only first letter of word

2017-12-05 Thread Mengu via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 14:01:35 UTC, Marc wrote: On Tuesday, 5 December 2017 at 13:40:08 UTC, Daniel Kozak wrote: but this will change all other uppercase to lowercase, so maybe it is not what you want. If you really want just change first char to upper, then there is nothing wrong to

Re: lower case only first letter of word

2017-12-05 Thread Marc via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 13:40:08 UTC, Daniel Kozak wrote: but this will change all other uppercase to lowercase, so maybe it is not what you want. If you really want just change first char to upper, then there is nothing wrong to do it yourself On Tue, Dec 5, 2017 at 2:37 PM, Daniel

Re: lower case only first letter of word

2017-12-05 Thread Daniel Kozak via Digitalmars-d-learn
but this will change all other uppercase to lowercase, so maybe it is not what you want. If you really want just change first char to upper, then there is nothing wrong to do it yourself On Tue, Dec 5, 2017 at 2:37 PM, Daniel Kozak wrote: > Something like this:

Re: lower case only first letter of word

2017-12-05 Thread ketmar via Digitalmars-d-learn
Marc wrote: Does D have a native function to capitalize only the first letter of the word? (I'm asking that so I might avoid reinvent the wheel, which I did sometimes in D) http://dpldocs.info/experimental-docs/std.string.capitalize.html

Re: lower case only first letter of word

2017-12-05 Thread Daniel Kozak via Digitalmars-d-learn
Something like this: https://dlang.org/phobos/std_uni.html#asCapitalized On Tue, Dec 5, 2017 at 2:31 PM, Marc via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Does D have a native function to capitalize only the first letter of the > word? (I'm asking that so I might avoid