encode

Summary

Encodes a string of text using UTF-8 encoding.

Usage

public static byte[] encode(string text)

Returns

A byte sequence representing the input text encoded with UTF-8.

Parameters

text

The text to encode.

Description

Encodes a string of text using UTF-8 encoding.

Examples

Basic Usage
1
2
3
4
5
6
7
8
9
10
11
import System;
import System.Encoding;
  
byte[] encoded = UTF8.encode("�");
  
string toHex = "";
foreach(byte b in encoded) {
    toHex += "\\x" + b.toHex().toUpperCase();
}
  
Console.log(toHex); // "\xE2\x82\xAC"

Share

HTML | BBCode | Direct Link