This language bar is your friend. Select your favorite languages!
Select your favorite languages :
  • Or search :

Idiom #287 Number of bytes of a string

Assign to n the number of bytes in the string s.

This can be different from the number of characters. If n includes more bytes than the characters per se (trailing zero, length field, etc.) then explain it. One byte is 8 bits.

import 'dart:convert';
var n = utf8.encode(s).length;
n := len(s)
$n = strlen($s);
n := length(s);
n = len(s.encode('utf8'))
n = s.bytesize
let n = s.len();

New implementation...