const escapeJsonUnicode = (jsonString) => {
  if (typeof jsonString !== 'string') return '';
  return jsonString.replace(/[\u0080-\uFFFF]/g, (ch) => {
    const code = ch.charCodeAt(0).toString(16).padStart(4, '0');
    return `\\u${code}`;
  });
};

const jsonStringifyUnicode = (data) => escapeJsonUnicode(JSON.stringify(data));

module.exports = { escapeJsonUnicode, jsonStringifyUnicode };

