tupper fails

2010-08-22 Thread Erin Sheldon
Hi All -

I'm just getting started with D, and I'm liking it so far, thanks to
everyone for all the hard work.


I was doing some string work and found that toupper() is failing on my char[]
array, although tolower() does work.  E.g.  these two examples:

char[] s;
s ~= Hello;
auto s_low = s.tolower();
auto s_up = s.toupper();

The tolower works but the toupper fails (error at the bottom of this message).
For reference I'm using 2.048.


I noticed that tolower() and toupper() have different implementations, although
there was a section commented out in tolower() that looks just like the toupper
implementation.  

I converted toupper() to use essentially the same code as tolower() and all
seems to work well. e.g.


S toupper(S)(S s) if (isSomeString!S)
{
foreach (i, dchar c; s)
{
if (!std.uni.isUniLower(c)) continue;
auto result = s[0.. i].dup;
foreach (dchar c; s[i .. $])
{
if (std.uni.isUniLower(c))
{
c = std.uni.toUniUpper(c);
}
result ~= c;
}
return cast(S) result;
}
return s;
}


Perhaps toupper() was in the midst of being changed when this snapshot of the
code was made?  Anyway, I thought I would bring it to your attention.

Thanks again,
Erin Scott Sheldon




/home/esheldon/local/dmd2/linux/bin/../../src/phobos/std/string.d(968): Error: 
cannot implicitly convert expression (changed ? 
cast(const(char)[])assumeUnique(r) : s) of type const(char)[] to char[]
/home/esheldon/local/dmd2/linux/bin/../../src/phobos/std/string.d(11): Error: 
template instance std.string.toupper!(char[]) error instantiating


Re: tupper fails

2010-08-22 Thread Erin Sheldon
Excerpts from Yao G.'s message of Sun Aug 22 20:30:08 -0400 2010:
 Hi.
 
 This newsgroup is used only for messages from D's Bugzilla. Maybe you  
 could repost this message on the digitalmars.D.learn NG?
 

My mistake.  I'll do that.
Erin