conversion of string to all lower case

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DJ

    conversion of string to all lower case

    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


  • DJ

    #2
    Re: conversion of string to all lower case

    Or perhaps even better a compare that ignores case.

    thanks

    "DJ" <chopin3@earthl ink.net> wrote in message
    news:vVAfd.3379 $kM.1729@newsre ad3.news.pas.ea rthlink.net...[color=blue]
    > Can someone tell me the library call that converts strings to lower case[/color]
    or[color=blue]
    > retrns a new string that is lower case of the original, thanks
    >
    > im using <string>
    >
    > David
    >
    >[/color]


    Comment

    • Julie

      #3
      Re: conversion of string to all lower case

      DJ wrote:[color=blue]
      >
      > Or perhaps even better a compare that ignores case.
      >
      > thanks
      >
      > "DJ" <chopin3@earthl ink.net> wrote in message
      > news:vVAfd.3379 $kM.1729@newsre ad3.news.pas.ea rthlink.net...[color=green]
      > > Can someone tell me the library call that converts strings to lower case[/color]
      > or[color=green]
      > > retrns a new string that is lower case of the original, thanks
      > >
      > > im using <string>
      > >
      > > David
      > >
      > >[/color][/color]

      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/internationaliz ed solutions.

      Comment

      • Ioannis Vranos

        #4
        Re: conversion of string to all lower case

        Julie wrote:
        [color=blue]
        > 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/internationaliz ed solutions.[/color]


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



        --
        Ioannis Vranos


        Comment

        • Ioannis Vranos

          #5
          Re: conversion of string to all lower case

          DJ wrote:[color=blue]
          > 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[/color]


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



          --
          Ioannis Vranos


          Comment

          • Rolf Magnus

            #6
            Re: conversion of string to all lower case

            Ioannis Vranos wrote:
            [color=blue]
            > Julie wrote:
            >[color=green]
            >> 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/internationaliz ed solutions.[/color]
            >
            > I am confused by your terminology "internatio nal" here. What do you mean?[/color]

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

            Comment

            • Ioannis Vranos

              #7
              Re: conversion of string to all lower case

              Rolf Magnus wrote:
              [color=blue]
              > One example is the german character ß that doesn't have a single uppercase
              > equivalent. 'Fuß' would need to compare equal to 'FUSS'.[/color]


              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


              Comment

              • Rolf Magnus

                #8
                Re: conversion of string to all lower case

                Ioannis Vranos wrote:
                [color=blue]
                > Rolf Magnus wrote:
                >[color=green]
                >> One example is the german character ß that doesn't have a single
                >> uppercase equivalent. 'Fuß' would need to compare equal to 'FUSS'.[/color]
                >
                >
                > 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.[/color]

                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.

                Comment

                • Ioannis Vranos

                  #9
                  Re: conversion of string to all lower case

                  Rolf Magnus wrote:
                  [color=blue]
                  > 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.[/color]




                  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


                  Comment

                  • Julie

                    #10
                    Re: conversion of string to all lower case

                    Ioannis Vranos wrote:[color=blue]
                    >
                    > Julie wrote:
                    >[color=green]
                    > > 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/internationaliz ed solutions.[/color]
                    >
                    > I am confused by your terminology "internatio nal" here. What do you mean?[/color]

                    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.

                    Comment

                    • Ioannis Vranos

                      #11
                      Re: conversion of string to all lower case

                      Julie wrote:
                      [color=blue]
                      > 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.[/color]


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



                      --
                      Ioannis Vranos


                      Comment

                      • Julie

                        #12
                        Re: conversion of string to all lower case

                        Ioannis Vranos wrote:[color=blue]
                        >
                        > Julie wrote:
                        >[color=green]
                        > > 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.[/color]
                        >
                        > However the OP was talking about std::string and not std::wstring.[/color]

                        OP:

                        "im using <string>"

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

                        Comment

                        • Ioannis Vranos

                          #13
                          Re: conversion of string to all lower case

                          Julie wrote:
                          [color=blue][color=green]
                          >>However the OP was talking about std::string and not std::wstring.[/color]
                          >
                          >
                          > OP:
                          >
                          > "im using <string>"
                          >
                          > No further information was provided about specific type or locale dependence,
                          > therefore not assumed in my responses.[/color]


                          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


                          Comment

                          • Julie

                            #14
                            Re: conversion of string to all lower case

                            Ioannis Vranos wrote:[color=blue]
                            >
                            > Julie wrote:
                            >[color=green][color=darkred]
                            > >>However the OP was talking about std::string and not std::wstring.[/color]
                            > >
                            > >
                            > > OP:
                            > >
                            > > "im using <string>"
                            > >
                            > > No further information was provided about specific type or locale dependence,
                            > > therefore not assumed in my responses.[/color]
                            >
                            > 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.[/color]

                            Right -- and I gave the usual answer.

                            nfc

                            Comment

                            • Ioannis Vranos

                              #15
                              Re: conversion of string to all lower case

                              Julie wrote:
                              [color=blue][color=green]
                              >>it looks like he is asking about the usual stuff.[/color]
                              >
                              >
                              > Right -- and I gave the usual answer.[/color]


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



                              --
                              Ioannis Vranos


                              Comment

                              Working...