943,807 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 681
  • C++ RSS
May 14th, 2009
0

->ToLower() (Mixing letters and numbers)

Expand Post »
I use this command to check for the Computername wich returns:
C++ Syntax (Toggle Plain Text)
  1. SystemInformation::ComputerName->ToString();
  2. //returns: MYCOMP-EG03R8F

When manually rightclicking "My Computer" and check what name I have, it says with lowcase letters:

mycomp-eg03r8f

So it doesn´t return the correct name. It shows Capitals.

But if I do this command instead:
C++ Syntax (Toggle Plain Text)
  1. SystemInformation::ComputerName->ToLower()->ToString();

I do get the same computername:

mycomp-eg03r8f


Is it okay to use ->ToLower() when it is a mix with letters and numbers. The function is intelligent and separates letters from numbers ?

Thank you if someone can confirm that...
Similar Threads
Reputation Points: 33
Solved Threads: 6
Junior Poster
Liszt is offline Offline
122 posts
since Oct 2008
May 14th, 2009
0

Re: ->ToLower() (Mixing letters and numbers)

Judging by the fact that you got the expected output, and not an error, it seems like a safe assumption, doesn't it? If you're concerned about it, run some tests on varying inputs. You'll probably find that it works fine. My guess is that the toLower() function uses the ASCII table to verify that something is a letter and acts appropriately (there are plenty of symbols that aren't letters OR numbers). Also, are you sure you can't look at the function's code yourself, by looking in some standard library?
Reputation Points: 874
Solved Threads: 352
Posting Maven
BestJewSinceJC is offline Offline
2,758 posts
since Sep 2008
May 15th, 2009
0

Re: ->ToLower() (Mixing letters and numbers)

See also ToLowerInvariant() function:
http://msdn.microsoft.com/en-us/libr...invariant.aspx.
MS recommends ToLowerInvariant for OS identifiers (file names, registry keys etc)...
Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008
May 15th, 2009
0

Re: ->ToLower() (Mixing letters and numbers)

thank you ArkM, I thought of that perheps can be a scenario that I haven´t thought about. I red about the ToLowerInvariant() and it seems to be the right approach for this purpose.

Click to Expand / Collapse  Quote originally posted by ArkM ...
See also ToLowerInvariant() function:
http://msdn.microsoft.com/en-us/libr...invariant.aspx.
MS recommends ToLowerInvariant for OS identifiers (file names, registry keys etc)...
Reputation Points: 33
Solved Threads: 6
Junior Poster
Liszt is offline Offline
122 posts
since Oct 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Input stream for Point class
Next Thread in C++ Forum Timeline: Looking for best practices and naming conventions





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC