decode static method
Implementation
static String decode(String text) {
var codes = <int>[];
var bytes = <int>[];
var len = text.length;
for (var i = 0; i < len; i++) {
var codeUnit = text.codeUnitAt(i);
if (codeUnit == _PERCENT) {
if (i + 3 > text.length) {
bytes.add(_PERCENT);
continue;
}
var hexdecoded = _hexCharPairToByte(text, i + 1);
if (hexdecoded > 0) {
bytes.add(hexdecoded);
i += 2;
} else {
bytes.add(_PERCENT);
}
} else {
if (bytes.isNotEmpty) {
codes.addAll(
const Utf8Decoder(allowMalformed: true).convert(bytes).codeUnits,
);
bytes.clear();
}
if (codeUnit == _PLUS) {
codes.add(_SPACE);
} else {
codes.add(codeUnit);
}
}
}
if (bytes.isNotEmpty) {
codes.addAll(const Utf8Decoder().convert(bytes).codeUnits);
bytes.clear();
}
return String.fromCharCodes(codes);
}