I got tired of typing:

php -r 'echo strlen("<PASTE>");'
So I made this site.

strlen is a standardised computer programming function commonly used to determine the length of a string. The term length of a string is used in C to describe the number of bytes preceding the zero byte. It is important to note that a string uses one more unit of memory than this length, in order to store the null value that ends the string.


Word Count:

0 words

Strlen:

0 characters


Programming Examples

PHP

$s = 'This string contains exactly 42 characters';
echo strlen($s);
Result: 42

Python

s = "This string contains exactly 42 characters"
print len(s)
Result: 42

Javascript

var s = "This string contains exactly 42 characters";
document.write s.length;
Result: 42

Perl

$s = "This string contains exactly 42 characters";
print length($s);
Result: 42

C

#include <stdio.h>
#include <string.h>

int main ()
{
  char s[] = "This string contains exactly 42 characters";
  printf ("%u", (unsigned)strlen(s));
  return 0;
}
Result: 42

Java

public class strlen {
  public static void main (String[] args) {
    String s="This string contains exactly 42 characters"
    System.out.println(s.length());
  }
}
Result: 42

LUA

s = 'This string contains exactly 42 characters'
print (string.len(s))
Result: 42

Ruby

s = "This string contains exactly 42 characters"
puts s.length
Result: 42

TCL

set s [string length "This string contains exactly 42 characters"]
puts $s
Result: 42

Unix-like Shell

From matja:
echo -n "This string contains exactly 42 characters" | wc -c
Result: 42

AWK

From pcpnut:
awk 'BEGIN{print length("This string contains exactly 42 characters")}'
Result: 42

dd

From pcpnut:
printf "This string contains exactly 42 characters" | dd of=/dev/null bs=1 2>&1 | grep in | cut -d "+" -f 1
Result: 42