11cb0ef41Sopenharmony_ci'use strict' 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci// When writing files on Windows, translate the characters to their 41cb0ef41Sopenharmony_ci// 0xf000 higher-encoded versions. 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst raw = [ 71cb0ef41Sopenharmony_ci '|', 81cb0ef41Sopenharmony_ci '<', 91cb0ef41Sopenharmony_ci '>', 101cb0ef41Sopenharmony_ci '?', 111cb0ef41Sopenharmony_ci ':', 121cb0ef41Sopenharmony_ci] 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst win = raw.map(char => 151cb0ef41Sopenharmony_ci String.fromCharCode(0xf000 + char.charCodeAt(0))) 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ciconst toWin = new Map(raw.map((char, i) => [char, win[i]])) 181cb0ef41Sopenharmony_ciconst toRaw = new Map(win.map((char, i) => [char, raw[i]])) 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_cimodule.exports = { 211cb0ef41Sopenharmony_ci encode: s => raw.reduce((s, c) => s.split(c).join(toWin.get(c)), s), 221cb0ef41Sopenharmony_ci decode: s => win.reduce((s, c) => s.split(c).join(toRaw.get(c)), s), 231cb0ef41Sopenharmony_ci} 24