-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
398 lines (365 loc) · 21.1 KB
/
Copy pathindex.html
File metadata and controls
398 lines (365 loc) · 21.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>URL Encode / Decode — Online URL Encoder & Decoder</title>
<meta name="description" content="Percent-encode text for use in URLs and decode URL-encoded strings back to plain text. Component or full-URI mode, UTF-8 safe. Runs entirely in your browser.">
<link rel="canonical" href="https://tagmachan.com/url-encoder.tagox">
<style>
:root { --accent: #38bdf8; }
* { box-sizing: border-box; }
body {
margin: 0; background: #040404; color: #e6edf3;
font-family: 'Ubuntu Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
-webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
.sa-bar {
display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
padding: 0.7rem 1rem; border-bottom: 1px solid #1e1e1e; background: #0b0e13;
}
.sa-bar .sa-title { font-weight: 700; color: #f0f0f0; display: flex; align-items: center; gap: 0.5rem; }
.sa-bar .sa-spacer { flex: 1; }
.sa-bar a.sa-demo {
text-decoration: none; font-size: 0.8rem; font-weight: 600;
border: 1px solid #30363d; border-radius: 6px; padding: 4px 12px; color: var(--accent);
}
.sa-bar a.sa-demo:hover { border-color: var(--accent); }
.sa-lang { display: flex; align-items: center; gap: 0.4rem; font-size: 0.72rem; color: #8b949e; }
.sa-lang input { display: none; }
.sa-lang label { cursor: pointer; width: 40px; height: 20px; border-radius: 999px; background: #30363d; position: relative; transition: background 0.2s; }
.sa-lang label::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #e6edf3; transition: transform 0.2s; }
.sa-lang input:checked + label { background: var(--accent); }
.sa-lang input:checked + label::after { transform: translateX(20px); }
body:not(.lang-tr) .lang-tr { display: none !important; }
body.lang-tr .lang-en { display: none !important; }
.sa-foot { text-align: center; padding: 1.5rem 1rem 2rem; color: #555; font-size: 0.78rem; }
.sa-foot a { color: #8b949e; text-decoration: none; }
.sa-foot a:hover { color: var(--accent); }
</style>
</head>
<body>
<div class="sa-bar">
<span class="sa-title">🔗 URL Encode / Decode</span>
<span class="sa-spacer"></span>
<a class="sa-demo" href="https://tagmachan.com/url-encoder.tagox" target="_blank" rel="noopener"><span class="lang-en">Live version ↗</span><span class="lang-tr">Canlı sürüm ↗</span></a>
<span class="sa-lang">
<span>EN</span>
<input type="checkbox" id="lang-toggle-checkbox">
<label for="lang-toggle-checkbox" aria-label="Toggle language"></label>
<span>TR</span>
</span>
</div>
<main id="main">
<section class="section section-show" style="padding-top: 3rem; padding-bottom: 4rem;">
<div class="container">
<div style="text-align: center; margin-bottom: 2.5rem;">
<span style="display: inline-block; background: rgba(56,189,248,0.12); color: #38bdf8; border: 1px solid rgba(56,189,248,0.25); border-radius: 6px; padding: 4px 14px; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 1rem;" data-lang-tr="Araç">Tool</span>
<h1 style="font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 700; color: #f8f8f8; margin-bottom: 1rem; font-family: 'Ubuntu Mono', monospace;">URL Encode / Decode</h1>
<p style="color: #a0a0a0; font-size: 1rem; max-width: 640px; margin: 0 auto;">
<span class="lang-en">Percent-encode text for URLs and decode URL-encoded strings back to plain text — UTF-8 safe. Everything runs locally in your browser.</span><span class="lang-tr" style="display:none">Metni URL'ler için percent-encode edin ve URL-encoded dizeleri düz metne geri çözün — UTF-8 uyumlu. Her şey tarayıcınızda çalışır.</span>
</p>
</div>
<div class="edc-wrap">
<div class="edc-panel" data-panel="url">
<div class="edc-modes">
<button type="button" class="edc-mode active" data-mode="encode" data-lang-tr="Encode">Encode</button>
<button type="button" class="edc-mode" data-mode="decode" data-lang-tr="Decode">Decode</button>
</div>
<div class="edc-optrow edc-opt-encode">
<label class="edc-optlabel" data-lang-tr="Kapsam">Scope</label>
<select class="edc-scope">
<option value="component"><span>Component (encodeURIComponent)</span></option>
<option value="full">Full URI (encodeURI)</option>
</select>
</div>
<div class="edc-io">
<div class="edc-col">
<label class="edc-label" data-lang-tr="Girdi">Input</label>
<textarea class="edc-input" spellcheck="false" placeholder="a b&c=/?#" ></textarea>
</div>
<div class="edc-col">
<div class="edc-out-head">
<label class="edc-label" data-lang-tr="Çıktı">Output</label>
<button type="button" class="edc-copy" data-lang-tr="Kopyala">Copy</button>
</div>
<textarea class="edc-output" readonly spellcheck="false"></textarea>
</div>
</div>
<p class="edc-note">
<span class="lang-en"><em>Component</em> encodes everything except unreserved characters (best for a single query value). <em>Full URI</em> leaves URL structure like <code>:/?#</code> intact. Decoding also treats <code>+</code> as a space.</span><span class="lang-tr" style="display:none"><em>Component</em>, ayrılmamış karakterler dışında her şeyi encode eder (tek bir query değeri için idealdir). <em>Full URI</em>, <code>:/?#</code> gibi URL yapısını korur. Çözme işlemi <code>+</code> karakterini de boşluk olarak kabul eder.</span>
</p>
<div class="edc-error" style="display:none"></div>
</div>
</div>
<div class="edc-related">
<p style="color: #555; font-size: 0.82rem;" data-lang-tr="İlgili araçlar →">Related tools →</p>
<div style="display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; margin-top: 0.75rem;">
<a href="https://tagmachan.com/base64.tagox">Base64</a>
<a href="https://tagmachan.com/hex.tagox">Hex</a>
<a href="https://tagmachan.com/html-entities.tagox">HTML Entities</a>
<a href="https://tagmachan.com/tools.tagox">~/tools</a>
</div>
</div>
</div>
<div class="container">
</div>
</section>
<style>
.edc-wrap { max-width: 1000px; margin: 0 auto; }
.edc-modes { display: flex; gap: 0.4rem; margin-bottom: 1rem; }
.edc-mode {
background: #0d1117; border: 1px solid #30363d; color: #8b949e;
border-radius: 999px; padding: 5px 16px; font-size: 0.8rem; font-weight: 600;
cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.edc-mode:hover { border-color: #58a6ff; color: #c9d1d9; }
.edc-mode.active { background: rgba(56,189,248,0.15); border-color: #38bdf8; color: #38bdf8; }
.edc-optrow { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }
.edc-optlabel { color: #8b949e; font-size: 0.76rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.edc-sep, .edc-format {
background: #0d1117; border: 1px solid #30363d; color: #e6edf3;
border-radius: 6px; padding: 6px 10px; font-family: 'Ubuntu Mono', monospace;
font-size: 0.82rem; outline: none; cursor: pointer;
}
.edc-sep:focus, .edc-format:focus { border-color: #38bdf8; }
.edc-check { color: #8b949e; font-size: 0.82rem; display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.edc-check input { accent-color: #38bdf8; cursor: pointer; }
.edc-io { display: flex; gap: 1.25rem; }
.edc-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.edc-out-head { display: flex; align-items: center; justify-content: space-between; }
.edc-label { color: #8b949e; font-size: 0.76rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.edc-input, .edc-output {
background: #0d1117; border: 1px solid #30363d; color: #e6edf3;
border-radius: 8px; padding: 12px 14px; min-height: 220px;
font-family: 'Ubuntu Mono', monospace; font-size: 0.86rem; line-height: 1.5;
resize: vertical; outline: none; width: 100%; transition: border-color 0.15s;
word-break: break-all;
}
.edc-input:focus { border-color: #38bdf8; }
.edc-output { background: #0b0e13; color: #7ee787; }
.edc-copy {
background: #0d1117; border: 1px solid #30363d; color: #8b949e;
border-radius: 6px; padding: 3px 12px; font-size: 0.72rem; font-weight: 600;
cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.edc-copy:hover { border-color: #38bdf8; color: #38bdf8; }
.edc-error { color: #f87171; font-size: 0.82rem; margin-top: 0.9rem; }
.edc-note { color: #666; font-size: 0.8rem; line-height: 1.5; margin: 1rem 0 0; }
.edc-note em { color: #999; font-style: normal; font-weight: 600; }
.edc-related { max-width: 1000px; margin: 3rem auto 0; text-align: center; }
.edc-related a {
color: #a0a0a0; font-size: 0.82rem; text-decoration: none;
border: 1px solid #2a2a2a; border-radius: 6px; padding: 5px 14px; transition: all 0.2s;
}
.edc-related a:hover { border-color: #38bdf8; color: #38bdf8; }
@media (max-width: 640px) {
.edc-io { flex-direction: column; }
}
</style>
<script>
/**
* Encoder / Decoder — Base64, Hex and HTML-entity converters.
* Everything runs locally in the browser; no input ever leaves the page.
* Each .edc-panel is wired generically: read direction + options, transform, write output.
*/
(function () {
'use strict';
function isTR() { return document.body.classList.contains('lang-tr'); }
// ───────────────────────── Base64 ─────────────────────────
function utf8Bytes(str) { return new TextEncoder().encode(str); }
function bytesToBinary(bytes) {
var s = '';
for (var i = 0; i < bytes.length; i++) s += String.fromCharCode(bytes[i]);
return s;
}
function base64Encode(str) { return btoa(bytesToBinary(utf8Bytes(str))); }
function base64Decode(str) {
var clean = str.replace(/\s+/g, '');
var binary = atob(clean); // throws on invalid input
var bytes = Uint8Array.from(binary, function (c) { return c.charCodeAt(0); });
return new TextDecoder().decode(bytes);
}
// ───────────────────────── Hex ─────────────────────────
function hex2(n) { return (n < 16 ? '0' : '') + n.toString(16); }
function textToHex(str, sep) {
var bytes = utf8Bytes(str), parts = [];
for (var i = 0; i < bytes.length; i++) parts.push(hex2(bytes[i]));
switch (sep) {
case 'none': return parts.join('');
case 'colon': return parts.join(':');
case 'slashx': return parts.length ? '\\x' + parts.join('\\x') : '';
default: return parts.join(' '); // space
}
}
function hexToText(str) {
var clean = str.replace(/0x/gi, '').replace(/\\x/gi, '').replace(/[^0-9a-fA-F]/g, '');
if (clean.length % 2 !== 0) throw new Error('odd');
var bytes = new Uint8Array(clean.length / 2);
for (var i = 0; i < clean.length; i += 2) bytes[i / 2] = parseInt(clean.substr(i, 2), 16);
return new TextDecoder().decode(bytes);
}
// ───────────────────────── HTML entities ─────────────────────────
var NAMED = {
'&': 'amp', '<': 'lt', '>': 'gt', '"': 'quot', "'": 'apos', ' ': 'nbsp',
'¢': 'cent', '£': 'pound', '¤': 'curren', '¥': 'yen',
'€': 'euro', '©': 'copy', '®': 'reg', '™': 'trade',
'°': 'deg', '±': 'plusmn', '×': 'times', '÷': 'divide',
'§': 'sect', '¶': 'para', '·': 'middot', '•': 'bull',
'…': 'hellip', '–': 'ndash', '—': 'mdash',
'‘': 'lsquo', '’': 'rsquo', '“': 'ldquo', '”': 'rdquo',
'«': 'laquo', '»': 'raquo', '†': 'dagger', '‡': 'Dagger',
'‰': 'permil', '′': 'prime', '″': 'Prime', ' ': 'nbsp'
};
function htmlEncode(str, format, encodeAll) {
var out = '';
Array.from(str).forEach(function (ch) {
var code = ch.codePointAt(0);
var passthrough = !encodeAll && (/[A-Za-z0-9]/.test(ch) || ch === ' ' || ch === '\n' || ch === '\r' || ch === '\t');
if (passthrough) { out += ch; return; }
if (format === 'named' && NAMED[ch]) { out += '&' + NAMED[ch] + ';'; return; }
if (format === 'hex') { out += '&#x' + code.toString(16).toUpperCase() + ';'; return; }
var dec = String(code);
while (dec.length < 4) dec = '0' + dec; // zero-pad to 4 digits → <
out += '&#' + dec + ';';
});
return out;
}
var decoderTA = document.createElement('textarea');
function htmlDecode(str) {
// Detached <textarea> decodes named + numeric entities without executing markup.
decoderTA.innerHTML = str;
return decoderTA.value;
}
// ───────────────────────── URL ─────────────────────────
function urlEncode(str, scope) { return scope === 'full' ? encodeURI(str) : encodeURIComponent(str); }
function urlDecode(str) { return decodeURIComponent(str.replace(/\+/g, '%20')); } // throws on bad % sequence
// ───────────────────────── dispatcher ─────────────────────────
function convert(tab, dir, text, opts) {
if (!text) return { out: '' };
try {
if (tab === 'base64') return { out: dir === 'encode' ? base64Encode(text) : base64Decode(text) };
if (tab === 'hex') return { out: dir === 'encode' ? textToHex(text, opts.sep) : hexToText(text) };
if (tab === 'html') return { out: dir === 'encode' ? htmlEncode(text, opts.format, opts.encodeAll) : htmlDecode(text) };
if (tab === 'url') return { out: dir === 'encode' ? urlEncode(text, opts.urlScope) : urlDecode(text) };
} catch (e) {
var msg = {
base64: { en: 'Not valid Base64 — check for stray characters or wrong padding.', tr: 'Geçerli Base64 değil — hatalı karakter veya yanlış dolgu (padding) olabilir.' },
hex: { en: 'Not valid hex — needs an even number of hex digits (0-9, a-f).', tr: 'Geçerli hex değil — çift sayıda hex basamağı gerekir (0-9, a-f).' },
url: { en: 'Not valid URL-encoded text — check for a malformed % sequence.', tr: 'Geçerli URL-encoded metin değil — hatalı bir % dizisi olabilir.' }
}[tab] || { en: 'Could not convert this input.', tr: 'Bu girdi dönüştürülemedi.' };
return { out: '', error: isTR() ? msg.tr : msg.en };
}
return { out: '' };
}
// ───────────────────────── wiring ─────────────────────────
function setupPanel(panel) {
var tab = panel.getAttribute('data-panel');
var input = panel.querySelector('.edc-input');
var output = panel.querySelector('.edc-output');
var errorEl = panel.querySelector('.edc-error');
var modeBtns = Array.prototype.slice.call(panel.querySelectorAll('.edc-mode'));
var sepSel = panel.querySelector('.edc-sep');
var formatSel = panel.querySelector('.edc-format');
var scopeSel = panel.querySelector('.edc-scope');
var encodeAllChk = panel.querySelector('.edc-encode-all');
var encodeOpts = Array.prototype.slice.call(panel.querySelectorAll('.edc-opt-encode'));
var state = { dir: 'encode' };
function run() {
var opts = {
sep: sepSel ? sepSel.value : 'space',
format: formatSel ? formatSel.value : 'dec',
encodeAll: encodeAllChk ? encodeAllChk.checked : false,
urlScope: scopeSel ? scopeSel.value : 'component'
};
var res = convert(tab, state.dir, input.value, opts);
output.value = res.out;
if (res.error) { errorEl.textContent = res.error; errorEl.style.display = 'block'; }
else { errorEl.textContent = ''; errorEl.style.display = 'none'; }
}
function syncOptVisibility() {
encodeOpts.forEach(function (el) { el.style.display = state.dir === 'encode' ? '' : 'none'; });
}
modeBtns.forEach(function (btn) {
btn.addEventListener('click', function () {
modeBtns.forEach(function (b) { b.classList.remove('active'); });
btn.classList.add('active');
state.dir = btn.getAttribute('data-mode');
syncOptVisibility();
run();
});
});
input.addEventListener('input', run);
if (sepSel) sepSel.addEventListener('change', run);
if (formatSel) formatSel.addEventListener('change', run);
if (scopeSel) scopeSel.addEventListener('change', run);
if (encodeAllChk) encodeAllChk.addEventListener('change', run);
syncOptVisibility();
run();
}
document.addEventListener('DOMContentLoaded', function () {
var panels = Array.prototype.slice.call(document.querySelectorAll('.edc-panel'));
if (!panels.length) return;
panels.forEach(setupPanel);
// Top tab switching.
var tabs = Array.prototype.slice.call(document.querySelectorAll('.edc-toptab'));
tabs.forEach(function (btn) {
btn.addEventListener('click', function () {
if (btn.classList.contains('active')) return;
var target = btn.getAttribute('data-tab');
tabs.forEach(function (b) { b.classList.remove('active'); });
btn.classList.add('active');
panels.forEach(function (p) { p.style.display = p.getAttribute('data-panel') === target ? '' : 'none'; });
});
});
// Copy buttons for output textareas.
Array.prototype.slice.call(document.querySelectorAll('.edc-copy')).forEach(function (btn) {
btn.addEventListener('click', function () {
var ta = btn.closest('.edc-col').querySelector('.edc-output');
if (!ta || !ta.value) return;
navigator.clipboard.writeText(ta.value).then(function () {
var old = btn.textContent;
btn.textContent = isTR() ? 'Kopyalandı ✓' : 'Copied ✓';
setTimeout(function () { btn.textContent = old; }, 1400);
});
});
});
// Re-render error/label language on toggle (outputs stay valid).
var langCheckbox = document.getElementById('lang-toggle-checkbox');
if (langCheckbox) {
langCheckbox.addEventListener('change', function () {
panels.forEach(function (p) { var i = p.querySelector('.edc-input'); if (i) i.dispatchEvent(new Event('input')); });
});
}
});
})();
</script>
</main>
<div class="sa-foot">
<span class="lang-en">A free, browser-local tool by</span><span class="lang-tr">Ücretsiz, tarayıcıda çalışan bir araç —</span>
<a href="https://tagmachan.com/url-encoder.tagox" target="_blank" rel="noopener">tagmachan.com</a> ·
<span class="lang-en">nothing you type ever leaves this page.</span><span class="lang-tr">yazdığınız hiçbir şey bu sayfadan çıkmaz.</span>
</div>
<script>
// Minimal standalone EN/TR toggle mirroring the site's data-lang-tr contract.
(function () {
var cb = document.getElementById('lang-toggle-checkbox');
function apply(tr) {
document.body.classList.toggle('lang-tr', tr);
document.querySelectorAll('[data-lang-tr]').forEach(function (el) {
if (el.getAttribute('data-lang-en-orig') === null || el.getAttribute('data-lang-en-orig') === undefined) {
el.setAttribute('data-lang-en-orig', el.innerHTML);
}
el.innerHTML = tr ? el.getAttribute('data-lang-tr') : el.getAttribute('data-lang-en-orig');
});
document.querySelectorAll('[data-lang-tr-placeholder]').forEach(function (el) {
if (!el.getAttribute('data-lang-en-ph')) el.setAttribute('data-lang-en-ph', el.getAttribute('placeholder') || '');
el.setAttribute('placeholder', tr ? el.getAttribute('data-lang-tr-placeholder') : el.getAttribute('data-lang-en-ph'));
});
}
cb.addEventListener('change', function () { apply(cb.checked); });
})();
</script>
</body>
</html>