Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7905441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:28:31+00:00 2026-06-03T10:28:31+00:00

I found this strange JavaScript I cannot understand. The for cycle has a strange

  • 0

I found this strange JavaScript I cannot understand. The for cycle has a strange syntax (many parameters), can you explain me how it is intended to work? Thanks

decode: function(s){
        for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
            ((a = s[i][c](0)) & 0x80) &&
            (s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
            o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "")
        );
        return s.join("");
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T10:28:34+00:00Added an answer on June 3, 2026 at 10:28 am

    interesting function, apparently trans-coding a certain set of chars, kind of esoteric and will only work with an ASCII code but here’s the breakdown:

        for (var i = 0; i < s.length; i++) {
            var a = s.charCodeAt(i);
    
            if (a & 0x80) { // (a >= 128) if extended ascii
    
                var b = s.charCodeAt(i + 1);
    
                var specialA = (a & 0xfc) === 0xc0; // a IS [À, Á, Â or Ã] essentially [192, 193, 194, 195]
                var specialB = (b & 0xc0) === 0x80; // b >= 128 & b <= 191 eg. b is not a special Latin Ascii Letter
    
                if (specialA && specialB) {
    
                    var txA = (a & 0x03) << 6; // [0, 64, 128, 192]
                    var txB = b & 0x3f; // 0 - 63
    
                    s[i] = String.fromCharCode(txA + txB);
    
                } else {
                    s[i] = String.fromCharCode(128);
                    s[++i] = "";
                }
            }
        }
    

    hope this helps, either way i found the decoding interesting, reminds of reading raw assembler, lol -ck

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In code example of Intel DPDK i have found this strange syntactical construction. Can
Found this rather strange bug in IE8; element.style.top is limited to 1342177 pixels. Even
Edited: SOLUTION FOUND. This is strange and not the best solution, but I just
found this regex: insert every 10 characters: $text = preg_replace(|(.{10})|u, \${1}. , $text); can
When debugging Magento, I found this strange warning. Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for
Strange question, I know. Allow me to explain. I have a JavaScript/jQuery function that
I found this strange behaviour in .NET and even after looking into CLR via
I was just studying OCPJP questions and I found this strange code: public static
I found this strange thing. XCode instruments tell me that this line return (SDZPerson*)[[[SDZPerson
I was working with some javascript and found a strange user agent with my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.