SHARE
TWEET

Untitled

a guest May 24th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * 将路径编码为 Windows 合法路径。
  3.  * @param {string} path 路径字符串。
  4.  * @param {string} replaced 不合法字符的替换字符。
  5.  */
  6. function EncodeWindowsPath(path, replaced = ' ') {
  7.     const reserved = ['<', ':', '"', '/', '\\', '|', '?', '*'];
  8.     let encodedPath = '';
  9.  
  10.     for (let char of path) {
  11.         encodedPath += char in reserved ? replaced : char;
  12.     }
  13.  
  14.     return encodedPath;
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top