Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * 将路径编码为 Windows 合法路径。
- * @param {string} path 路径字符串。
- * @param {string} replaced 不合法字符的替换字符。
- */
- function EncodeWindowsPath(path, replaced = ' ') {
- const reserved = ['<', ':', '"', '/', '\\', '|', '?', '*'];
- let encodedPath = '';
- for (let char of path) {
- encodedPath += char in reserved ? replaced : char;
- }
- return encodedPath;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement