Skip to content
FutureBlitz

    Install

    Import std.text.encoding

    Encode

    std.text.encoding

    function

    Public Function Encode(text: String, encoding: TextEncoding, bom: Bool = False): UInt8[]?

    text in encoding, after the encoding's BOM when bom says and it has one, or Null when a character of the text isn't in the encoding: ASCII has U+0000 to U+007F, Latin-1 U+0000 to U+00FF, and Windows-1252 Latin-1's but U+0080 to U+009F, where it has others, like "€".

    Examples

    Expect(Encode("hé", TextEncoding.UTF16_LE) == [0x68, 0x00, 0xE9, 0x00] As UInt8[])
    Expect(Encode("hé", TextEncoding.ASCII) == Null)
    Expect(Decode([0xE9] As UInt8[], TextEncoding.LATIN1) == "é")

    std/text/encoding.fb, line 128

    Report an issue with this page or with FutureBlitz on GitHub.