472,805 Members | 1,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

conversion of string to all lower case

DJ
Can someone tell me the library call that converts strings to lower case or
retrns a new string that is lower case of the original, thanks

im using <string>

David
Jul 22 '05 #1
22 6359
DJ
Or perhaps even better a compare that ignores case.

thanks

"DJ" <ch*****@earthlink.net> wrote in message
news:vV****************@newsread3.news.pas.earthli nk.net...
Can someone tell me the library call that converts strings to lower case or retrns a new string that is lower case of the original, thanks

im using <string>

David

Jul 22 '05 #2
DJ wrote:

Or perhaps even better a compare that ignores case.

thanks

"DJ" <ch*****@earthlink.net> wrote in message
news:vV****************@newsread3.news.pas.earthli nk.net...
Can someone tell me the library call that converts strings to lower case

or
retrns a new string that is lower case of the original, thanks

im using <string>

David


The discussion regarding the (international) caveats of lower/upper case and
case-insensitive *word* comparisons comes up monthly. Check the Google Groups
archives for more blather than you want to read, as well as a couple of
(somewhat) portable/internationalized solutions.
Jul 22 '05 #3
Julie wrote:
The discussion regarding the (international) caveats of lower/upper case and
case-insensitive *word* comparisons comes up monthly. Check the Google Groups
archives for more blather than you want to read, as well as a couple of
(somewhat) portable/internationalized solutions.

I am confused by your terminology "international" here. What do you mean?

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #4
DJ wrote:
Can someone tell me the library call that converts strings to lower case or
retrns a new string that is lower case of the original, thanks

im using <string>

David

Check std::toupper() and std::tolower() functions of <cctype>.

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #5
Ioannis Vranos wrote:
Julie wrote:
The discussion regarding the (international) caveats of lower/upper case
and case-insensitive *word* comparisons comes up monthly.
Check the Google Groups archives for more blather than you want to read,
as well as a couple of (somewhat) portable/internationalized solutions.


I am confused by your terminology "international" here. What do you mean?


One example is the german character ß that doesn't have a single uppercase
equivalent. 'Fuß' would need to compare equal to 'FUSS'.

Jul 22 '05 #6
Rolf Magnus wrote:
One example is the german character ß that doesn't have a single uppercase
equivalent. 'Fuß' would need to compare equal to 'FUSS'.

This is not the case here, since we are talking about std::string.

About multilingual characters, one should use wchar_t, std::wstring and
the std::towlower(), std::towupper() of <cwctype>, all guaranteed to work.
C++98:

"Type wchar_t is a distinct type whose values can represent distinct
codes for all members of the largest extended character set specified
among the supported locales (22.1.1). Type wchar_t shall have the same
size, signedness, and alignment requirements (3.9) as one of the other
integral types, called its underlying type."


--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #7
Ioannis Vranos wrote:
Rolf Magnus wrote:
One example is the german character ß that doesn't have a single
uppercase equivalent. 'Fuß' would need to compare equal to 'FUSS'.

This is not the case here, since we are talking about std::string.

About multilingual characters, one should use wchar_t, std::wstring and
the std::towlower(), std::towupper() of <cwctype>, all guaranteed to work.


How do those handle such a conversion? The main point here is that the
number of characters in the uppercase version and in the lowercase version
are not equal. Character-based toupper and tolower can't handle that.

Jul 22 '05 #8
Rolf Magnus wrote:
How do those handle such a conversion? The main point here is that the
number of characters in the uppercase version and in the lowercase version
are not equal. Character-based toupper and tolower can't handle that.



However they work for Greek and English and I assume all languages with
one to one, lower-case to upper-case correspondence, so I guess it is
for such languages and up to the programmer to take this decision.

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #9
Ioannis Vranos wrote:

Julie wrote:
The discussion regarding the (international) caveats of lower/upper case and
case-insensitive *word* comparisons comes up monthly. Check the Google Groups
archives for more blather than you want to read, as well as a couple of
(somewhat) portable/internationalized solutions.


I am confused by your terminology "international" here. What do you mean?


I mean that there are languages that apparently do not have a 1-1
correspondence between upper and lower case words (and characters).

For English, u/l case comparisons are trivial. For German, there are issues.

This is what I mean about 'international' -- if the OP is writing a
locale-independent application (assumed to be the case unless indicated
otherwise), they will have to contend w/ such 'international' issues.
Jul 22 '05 #10
Julie wrote:
I mean that there are languages that apparently do not have a 1-1
correspondence between upper and lower case words (and characters).

For English, u/l case comparisons are trivial. For German, there are issues.

This is what I mean about 'international' -- if the OP is writing a
locale-independent application (assumed to be the case unless indicated
otherwise), they will have to contend w/ such 'international' issues.

However the OP was talking about std::string and not std::wstring.

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #11
Ioannis Vranos wrote:

Julie wrote:
I mean that there are languages that apparently do not have a 1-1
correspondence between upper and lower case words (and characters).

For English, u/l case comparisons are trivial. For German, there are issues.

This is what I mean about 'international' -- if the OP is writing a
locale-independent application (assumed to be the case unless indicated
otherwise), they will have to contend w/ such 'international' issues.


However the OP was talking about std::string and not std::wstring.


OP:

"im using <string>"

No further information was provided about specific type or locale dependence,
therefore not assumed in my responses.
Jul 22 '05 #12
Julie wrote:
However the OP was talking about std::string and not std::wstring.

OP:

"im using <string>"

No further information was provided about specific type or locale dependence,
therefore not assumed in my responses.

From the subject "conversion of string to all lower case" and the question

"Can someone tell me the library call that converts strings to lower
case or retrns a new string that is lower case of the original, thanks

im using <string>"
it looks like he is asking about the usual stuff.

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #13
Ioannis Vranos wrote:

Julie wrote:
However the OP was talking about std::string and not std::wstring.

OP:

"im using <string>"

No further information was provided about specific type or locale dependence,
therefore not assumed in my responses.


From the subject "conversion of string to all lower case" and the question

"Can someone tell me the library call that converts strings to lower
case or retrns a new string that is lower case of the original, thanks

im using <string>"

it looks like he is asking about the usual stuff.


Right -- and I gave the usual answer.

nfc
Jul 22 '05 #14
Julie wrote:
it looks like he is asking about the usual stuff.

Right -- and I gave the usual answer.

I don't think so. In simple words, he is talking about chars and you
about wchar_ts.

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #15

"Ioannis Vranos" <iv*@guesswh.at.grad.com> wrote in message
news:1098928197.123403@athnrd02...
Julie wrote:
it looks like he is asking about the usual stuff.

Right -- and I gave the usual answer.

I don't think so. In simple words, he is talking about chars and you about
wchar_ts.

--
Ioannis Vranos

http://www23.brinkster.com/noicys


Is the header <string> or the class <string>?

Catalin
Jul 22 '05 #16
In message <1098928197.123403@athnrd02>, Ioannis Vranos
<iv*@guesswh.at.grad.com> writes
Julie wrote:
it looks like he is asking about the usual stuff.

Right -- and I gave the usual answer.

I don't think so. In simple words, he is talking about chars and you
about wchar_ts.


German is part of ISO8859-1, which is commonly stored in char, not
wchar_t.

--
Richard Herring
Jul 22 '05 #17
Richard Herring wrote:
I don't think so. In simple words, he is talking about chars and you
about wchar_ts.

German is part of ISO8859-1, which is commonly stored in char, not
wchar_t.

Nope.
TC++PL says it well:

"A char variable is of the natural size to hold a character on a given
machine (typically a byte)".

"A type wchar_t is provided to hold characters of a larger character set
such as Unicode. It is a distinct type. The size of wchar_t is
implementation-defined and large enough to hold the largest character
set supported by the implementations locale (see 21.7, C.3.3)."
To give an example, in Windows GUI applications, char is guaranteed to
work only for English characters, for any other language you should use
wchar_t.

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #18
Ioannis Vranos wrote:
Richard Herring wrote:
I don't think so. In simple words, he is talking about chars and you
about wchar_ts.

German ß is part of ISO8859-1, which is commonly stored in char, not
wchar_t.

Nope.


Yup.
TC++PL says it well:

"A char variable is of the natural size to hold a character on a given
machine (typically a byte)".
Right. Nothing here forbids non-ASCII characters.
"A type wchar_t is provided to hold characters of a larger character set
such as Unicode. It is a distinct type. The size of wchar_t is
implementation-defined and large enough to hold the largest character
set supported by the implementation’s locale (see 21.7, C.3.3)."
And what does that have to do with ISO-8895-1? It's neither a unicode
character set, not a multibyte character set. It's an 8bit character set,
so each character of it will always fit into a byte. So char is perfect for
holding it.
To give an example, in Windows GUI applications, char is guaranteed to
work only for English characters, for any other language you should use
wchar_t.


Is that so?

Jul 22 '05 #19
Rolf Magnus wrote:
TC++PL says it well:

"A char variable is of the natural size to hold a character on a given
machine (typically a byte)".

Right. Nothing here forbids non-ASCII characters.

This discussion can't reach a reasonable conclusion. Just give more
thought on the subject.


--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #20
In message <1098969343.609953@athnrd02>, Ioannis Vranos
<iv*@guesswh.at.grad.com> writes
Richard Herring wrote:
I don't think so. In simple words, he is talking about chars and you
about wchar_ts. German ß is part of ISO8859-1, which is commonly stored in char,
not wchar_t.


Nope.


Yes, actually. German sz ligature is code point 223 in ISO8859-1,
better known as the Latin-1 character set, and was for example the
standard character set and encoding for HTML up to 3.2.
TC++PL says it well:

"A char variable is of the natural size to hold a character on a given
machine (typically a byte)".
And how many C++ implementations do you know of where char is less than
8 bits? ISO8859-1 has only 256 code points and can happily be
accommodated in 8-bit chars.

ISO/IEC 14882 says it better:
"Objects declared as characters (char) shall be large enough to store
any member of the implementation's basic character set."

.... and it's quite possible that that basic character set *is*
ISO8859-1.
"A type wchar_t is provided to hold characters of a larger character
set such as Unicode.
Yes. So what? ISO8859-1 is not Unicode, and wchar_t is not necessary to
hold it.
It is a distinct type. The size of wchar_t is implementation-defined
and large enough to hold the largest character set supported by the
implementation’s locale (see 21.7, C.3.3)."
To give an example, in Windows GUI applications, char is guaranteed to
work only for English characters, for any other language you should use
wchar_t.


Even if that were true (it isn't - there's an API for messing with
"code pages"), what does the Windows GUI have to do with standard C++?

--
Richard Herring
Jul 22 '05 #21
In message <1098972077.25470@athnrd02>, Ioannis Vranos
<iv*@guesswh.at.grad.com> writes
Rolf Magnus wrote:
TC++PL says it well:

"A char variable is of the natural size to hold a character on a given
machine (typically a byte)".

Right. Nothing here forbids non-ASCII characters.

This discussion can't reach a reasonable conclusion. Just give more
thought on the subject.


There is a perfectly reasonable conclusion, which had already been
stated before you tried to contradict it. That is, that there is an
insoluble problem with applying character-by-character toupper() to some
alphabets, which is present whether you use char or wchar_t.

--
Richard Herring
Jul 22 '05 #22
Richard Herring wrote:
There is a perfectly reasonable conclusion, which had already been
stated before you tried to contradict it. That is, that there is an
insoluble problem with applying character-by-character toupper() to some
alphabets, which is present whether you use char or wchar_t.


OK I can accept this. In any case toupper(), tolower() of <cctype>, and
towupper(), towlower() of <cwctype>, are all guaranteed to work for
languages with one to one, lower-case to upper-case correspondence, that
fit in the supported characters, and is up to the programmer to take
this decision.
Even if Greek is provided in the extended ASCII character set, and char
implementation is unsigned in my platform, when I use Greek or some
language other than English, I am using wchar_t which is Unicode in my
system and fits it 100% (wchar_t is the largest character set supported
by any platform).
So for languages with one to one correspondence of lower-case to
upper-case characters, these facilities are guaranteed to work.
In any case, I am 100% certain the OP was talking about English anyway.

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #23

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Senthoorkumaran Punniamoorthy | last post by:
I am printing these information. print string.lower(info_res) print string.lower(md5sum(f_md5)) print len(string.lower(info_res)) print len(string.lower(md5sum(f_md5))) print...
0
by: Tumurbaatar S. | last post by:
Hi, I'm running MySQL 3.23.55 on WinXP and have some problem using non latin charset. I've added these 2 lines under group of my.ini: character-sets-dir = c:/mysql/share/charsets/...
3
by: Claude Schneegans | last post by:
Hi, I'trying to use a regExp in Javascript to replace any all upper case word in a string by the same word having only its first letter in upper case. This expression detects the words: /()(+)/g...
16
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. ...
19
by: Randy Yates | last post by:
Consider the following code: #include "dsptypes.h" /* definitions */ #define VECTOR_LENGTH 64 /* local variables */
9
by: Girish | last post by:
Im trying to understand implicit type conversions from object -> string and vice versa. I have two classes, one Driver and one called StringWrapper. These are just test classes that try and...
9
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to...
9
by: B Williams | last post by:
I have written some code that will take in a string and print out the reverse, but I also want it to check for upper and lower case and swap them. Will someone assist me? include <iostream>...
14
by: fniles | last post by:
In VB.NET 2005 can I check if a letter in a string is upper case or lower case ? For example: I have the following 2 lines: NQ,Z2003,11/11/2003,1416.5,1420,1402,1411.5...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.