We've got a lot of questions asking how to count the bytes in different situations. This question is here to put them all in one spot.

General questions

How to count "interactive" answers and flags (revised to: Let's solve the flag problem once and for all)
How to count REPLs
How to count multiple files
How to count lambdas
How to count whitespace
How to count shebangs
How to count "expanded text"
How to count encodings
How to count language-switch flags

Language/feature-specific questions

Box 256
Lego WeDo
PHP -r/-R/-F
VBA immediate Window
VB.NET auto-includes

Return to FAQ index

  • 18
    \$\begingroup\$ Thanks for this. I think this is incredibly helpful and will be a great place to point new users to. \$\endgroup\$
    – Alex A.
    Commented Sep 22, 2016 at 20:28
  • \$\begingroup\$ @AlexA. For some reason, there is no FAQ section on the right side. \$\endgroup\$ Commented Sep 24, 2016 at 7:10
  • \$\begingroup\$ PHP GET is actually a standard accepted input method: meta.codegolf.stackexchange.com/a/7591/14732 (current score: +14 -5). Also, POST would fall in the same category as GET. \$\endgroup\$ Commented Sep 28, 2016 at 14:27
  • \$\begingroup\$ @IsmaelMiguel Ok? This question isn't about what is/isn't allowed, but rather how we count the bytes. The PHP GET question about is specifically how we count the bytes with PHP GETs. \$\endgroup\$ Commented Sep 28, 2016 at 14:36
  • \$\begingroup\$ @NathanMerrill The accepted answer in the PHP GET link, in short, says that PHP GET isn't an accepted input method and that the question doesn't make sense. \$\endgroup\$ Commented Sep 28, 2016 at 14:50
  • \$\begingroup\$ @IsmaelMiguel the question is still valid, but the answer is out of date. I'd post a comment (or a new answer). \$\endgroup\$ Commented Sep 28, 2016 at 14:51
  • \$\begingroup\$ @NathanMerrill That's where I was trying to get, The answer is old and (now) is wrong as well. \$\endgroup\$ Commented Sep 28, 2016 at 15:30
  • \$\begingroup\$ How do you count poyglots for languages that normally use different encodings? \$\endgroup\$
    – Pavel
    Commented Dec 7, 2016 at 19:37
  • 2
    \$\begingroup\$ @ГригорийПерельман: You find a sequence of bytes that works in all the programs, and then take the number of bytes. The various languages may well interpret each interpret this sequence as a different sequence of characters (so typically you'd present one of the programs as the "main" one and then say what the other languages see in your explanation). \$\endgroup\$
    – user62131
    Commented Mar 26, 2017 at 15:09
  • \$\begingroup\$ Surprisingly, there is no answer linked from this FAQ for the most basic case: when a single piece of code is posted as codegolf answer. Most answers and codegolf.stackexchange.com/tags/code-golf/info talk about byte size, but those answers are posted as Unicode strings, without an explicit encoding, so there is no obvious an unambiguous way to determine the byte size. Are there any relevant guidelines here? \$\endgroup\$
    – pts
    Commented Feb 28, 2023 at 11:46
  • \$\begingroup\$ "How to count encodings" would be the general guideline for that. \$\endgroup\$ Commented Feb 28, 2023 at 17:15


You must log in to answer this question.

Browse other questions tagged .