encoding
Generated by tinox doc
Character/byte and HTML entity conversions: char code <-> String, UTF-8 byte list <-> String round-tripping, and htmlEncode/htmlDecode for safely embedding user text in HTML.
Html escaping
import tinox.core.encoding;
class Main
{
fnc main() -> Int32
{
let comment: String = "<script>alert('hi')</script> & more";
let safe: String = Encoding::htmlEncode(comment);
println(safe);
let restored: String = Encoding::htmlDecode(safe);
println(restored);
let bytes: List<Int64> = Encoding::toUtf8("hi");
println(Encoding::fromUtf8(bytes));
return 0;
}
}
fn tinoxBytesToString(bytes: List<Int64>) → String
class Encoding
Methods
fn toCharCode(s: String) → Int64
fn fromCharCode(code: Int64) → String
fn toUtf8(s: String) → List<Int64>
fn fromUtf8(codes: List<Int64>) → String
fn htmlEncode(s: String) → String
fn htmlDecode(s: String) → String