Files
P4RS3LT0NGV3/js/utils/escapeParser.js
Dustin Farley dc10a90851 refactor: migrate to modular tool-based architecture
- Implement tool registry system with individual tool modules
- Reorganize transformers into categorized source modules
- Remove emojiLibrary.js, consolidate into EmojiUtils and emojiData
- Fix mobile close button and tooltip functionality
- Add build system for transforms and emoji data
- Migrate from Python backend to pure JavaScript
- Add comprehensive documentation and testing
- Improve code organization and maintainability
- Ignore generated files (transforms-bundle.js, emojiData.js)
2025-12-02 20:26:32 -08:00

41 lines
1.2 KiB
JavaScript

window.EscapeParser = {
parseEscapeSequence(str) {
if (!str || typeof str !== 'string') {
return str;
}
const escapeMap = {
'\\u200B': '\u200B', // Zero Width Space
'\\u200C': '\u200C', // Zero Width Non-Joiner
'\\u200D': '\u200D', // Zero Width Joiner
'\\u2060': '\u2060', // Word Joiner
'\\uFE0E': '\uFE0E', // Variation Selector-15
'\\uFE0F': '\uFE0F', // Variation Selector-16
'\\n': '\n',
'\\r': '\r',
'\\t': '\t',
'\\0': '\0',
'\\\'': '\'',
'\\"': '"',
'\\\\': '\\'
};
if (escapeMap[str] !== undefined) {
return escapeMap[str];
}
const unicodeMatch = str.match(/^\\u([0-9A-Fa-f]{4})$/);
if (unicodeMatch) {
return String.fromCharCode(parseInt(unicodeMatch[1], 16));
}
const hexMatch = str.match(/^\\x([0-9A-Fa-f]{2})$/);
if (hexMatch) {
return String.fromCharCode(parseInt(hexMatch[1], 16));
}
return str;
}
};