Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. while (*s++ = ((*t & 0x60) == 0x40 ? *t ^ 0x20 : *t)) t++;

while (*s++ = ((*t & 0x60) == 0x40 ? *t ^ 0x20 : *t)) t++;

Scheduled Pinned Locked Moved The Lounge
rubyquestion
40 Posts 27 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Jonas Hammarberg

    Copying string, turning upper case into lower case...

    R Offline
    R Offline
    Rosenne
    wrote on last edited by
    #30

    Only in America... I mean, only for US ASCII. :thumbsdown:

    J 1 Reply Last reply
    0
    • P Pete OHanlon

      Rob Philpott wrote:

      Any takers for what this gem does?

      Why that's obvious. It makes you hate the coder who spewed it into your source.

      I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

      My blog | My articles | MoXAML PowerToys | Onyx

      Y Offline
      Y Offline
      yoni at jefco
      wrote on last edited by
      #31

      I was going to say "Hopefully get someone sacked". Maybe a bit harsh on my part.

      1 Reply Last reply
      0
      • L Larry G Grimes

        It definitely returns a string with all lowercase characters.

        M Offline
        M Offline
        Matthew Barnett
        wrote on last edited by
        #32

        Larry G. Grimes wrote:

        It definitely returns a string with all lowercase characters.

        It'll change other characters too, such as '@' to '`'!

        1 Reply Last reply
        0
        • R Rosenne

          Only in America... I mean, only for US ASCII. :thumbsdown:

          J Offline
          J Offline
          Jonas Hammarberg
          wrote on last edited by
          #33

          Worked for ANSI to, albeit only the lower parts :rolleyes:

          R 1 Reply Last reply
          0
          • R Rob Philpott

            It's turning into one of 'those' Friday afternoons. Any takers for what this gem does?

            Regards, Rob Philpott.

            L Offline
            L Offline
            Lev Vayner
            wrote on last edited by
            #34

            maybe the author should start writing normal code.. in c#, this would be done with s.ToLower() yeah.. thats it.. no non-sense pointer code with an inline loop referencing hex values

            1 Reply Last reply
            0
            • J Jonas Hammarberg

              Worked for ANSI to, albeit only the lower parts :rolleyes:

              R Offline
              R Offline
              Rosenne
              wrote on last edited by
              #35

              I the context of software, only as well as but generally mean a bug.

              1 Reply Last reply
              0
              • R Rob Philpott

                It's turning into one of 'those' Friday afternoons. Any takers for what this gem does?

                Regards, Rob Philpott.

                S Offline
                S Offline
                stevee1984
                wrote on last edited by
                #36

                Maybe something like this would work better, then we can use the code for email addresses etc. while (*s++ = (*t >='A' && *t <= 'Z' ? *t ^ 0x20 : *t) ) t++;

                1 Reply Last reply
                0
                • R Rob Philpott

                  ..just for fun really. It's nearly the weekend..

                  Regards, Rob Philpott.

                  D Offline
                  D Offline
                  DominLondon
                  wrote on last edited by
                  #37

                  Robbo!

                  R 1 Reply Last reply
                  0
                  • D DominLondon

                    Robbo!

                    R Offline
                    R Offline
                    Rob Philpott
                    wrote on last edited by
                    #38

                    Dude!

                    Regards, Rob Philpott.

                    1 Reply Last reply
                    0
                    • R Rob Philpott

                      It's turning into one of 'those' Friday afternoons. Any takers for what this gem does?

                      Regards, Rob Philpott.

                      L Offline
                      L Offline
                      leonej_dt
                      wrote on last edited by
                      #39

                      I will assume both s and t are char*. *t & 0x60: Filters all but two bits of *t. I will call those bits xy (the most significant one first). (*t & 0x60) == 0x40: Tests whether xy is 10. (*t & 0x60) == 0x40 ? *t ^0x20 : *t: If xy is 10, it returns a new character equal to *t, but with xy equal to 11. Otherwise, it returns the original character. The whole loop iterates through a C string starting at s and copies it to another C string starting at t, but characters from 0x40 to 0x5F are converted into characters from 0x60 to 07F. The original string is left untouched, unless s equals t. (If t points to another character actually inside the C string pointed by s or vice versa, the program goes crazy.) To the end user, this means the following: Uppercase characters are converted into lowercase characters, square brackets are converted into braces, the backslash is converted into a vertical line character, the French circumflex accent character is converted into the tilde character, and the underline character is converted into a DEL character.

                      If you can play The Dance of Eternity (Dream Theater), then we shall make a band.

                      1 Reply Last reply
                      0
                      • R Rob Philpott

                        It's turning into one of 'those' Friday afternoons. Any takers for what this gem does?

                        Regards, Rob Philpott.

                        A Offline
                        A Offline
                        Atanas Palavrov
                        wrote on last edited by
                        #40

                        This is trivial ToLover() ... well, if you know ASCII. This is better: while (*s++ = ((*t & ~0x1F) == 0x40 ? *t ^ 0x20 : *t)) t++; And this is more clear: #define mask (~('a'-'B')) while (*s++ = ((*t & mask == ('A' & mask) ? *t ^ ('a'-'A') : *t)) t++;

                        www.codigi.net .NET touch screen GUI components suite

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups