| Extracted from Pike v7.8 release 866 at 2018-07-18.

[Top]

# Method string_to_utf8()

Method string_to_utf8

  `string string_to_utf8(string s)`
  `string string_to_utf8(string s, int extended)`

Description

  Converts a string into an UTF-8 compliant byte-stream.

Note

  Throws an error if characters not valid in an UTF-8 stream are encountered. Valid characters are in the ranges `0x00000000-0x0000d7ff` and `0x0000e000-0x0010ffff`.

  If extended is 1 then characters outside the valid ranges are accepted too and encoded using the same algorithm. Such encoded characters are however not UTF-8 compliant.

See also

  Locale.Charset.encoder() , string_to_unicode() , unicode_to_string() , utf8_to_string()