chore: extract utils escapeUnicode

This commit is contained in:
Abdelkader Boudih
2025-03-21 22:30:34 +00:00
parent 3488bdb613
commit af44efb236
5 changed files with 46 additions and 17 deletions

View File

@@ -16,23 +16,7 @@ import {
import { AlertCircle, Send } from "lucide-react";
import { useEffect, useState } from "react";
import ListPane from "./ListPane";
// Utility function to escape Unicode characters
function escapeUnicode(obj: any): string {
return JSON.stringify(
obj,
(_key: string, value) => {
if (typeof value === "string") {
// Replace non-ASCII characters with their Unicode escape sequences
return value.replace(/[^\0-\x7F]/g, (char) => {
return "\\u" + ("0000" + char.charCodeAt(0).toString(16)).slice(-4);
});
}
return value;
},
2,
);
}
import { escapeUnicode } from "@/utils/escapeUnicode";
const ToolsTab = ({
tools,