"use client"; import { useState } from "react"; import { Braces, Copy, Trash2, ArrowUpDown } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Textarea } from "@/components/ui/textarea"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { toast } from "sonner"; export default function HtmlEscapePage() { const [input, setInput] = useState(""); const copyToClipboard = async (text: string) => { if (!text) return; try { await navigator.clipboard.writeText(text); toast.success("已复制到剪贴板"); } catch { toast.error("复制失败"); } }; const escapeHtml = () => { const div = document.createElement('div'); div.textContent = input; setInput(div.innerHTML); toast.success("转义成功"); }; const unescapeHtml = () => { const div = document.createElement('div'); div.innerHTML = input; setInput(div.textContent || ""); toast.success("反转义成功"); }; const clearAll = () => setInput(""); return (
{/* Page Header */}

HTML 转义

对 HTML 实体字符进行编码和解码转换

输入/输出文本