()
| 33 | } else { |
| 34 | setOutput(decodeURIComponent(input)); |
| 35 | } |
| 36 | } catch { setOutput(""); } |
| 37 | }, [input, tab, fullUrl]); |
| 38 | |
| 39 | const handleEncode = () => { |
| 40 | if (!input.trim()) { toast.error(t("pleaseEnterInput")); return; } |
| 41 | try { |
| 42 | setOutput(fullUrl ? encodeURI(input) : encodeURIComponent(input)); |
| 43 | toast.success(t("encodedSuccessfully")); |
| 44 | } catch (e) { toast.error(t("encodingFailed", { msg: e instanceof Error ? e.message : String(e) })); } |