encode static method
Helper method to encode the specified path in Modified UTF7 encoding.
Note that any path separators will be encoded as well, so you might have to separate and reassemble path element manually
Implementation
static String encode(String path, String pathSeparator) {
final pathSeparatorIndex = path.lastIndexOf(pathSeparator);
if (pathSeparatorIndex == -1) {
return _modifiedUtf7Codec.encodeText(path);
} else {
final start = path.substring(0, pathSeparatorIndex);
final end = _modifiedUtf7Codec.encodeText(
path.substring(pathSeparatorIndex + pathSeparator.length),
);
return '$start$pathSeparator$end';
}
}