function drupal_truncate_bytes

Truncates a UTF-8-encoded string safely to a number of bytes.

Parameters

string $string: The string to truncate.

int $len: An upper limit on the returned string length.

Return value

string The truncated string.

See also

\Drupal\Component\Utility\Unicode::truncateBytes().

File

drupal/core/includes/unicode.inc, line 153
Provides Unicode-related conversions and operations.

Code

function drupal_truncate_bytes($string, $len) {
  return Unicode::truncateBytes($string, $len);
}