Isu encoding di XML Blogspot

Adzril MediaOne

Ada 1 isu klasik yang selalu menghantui vibe code ni bila icon yang terpapar berbentuk nombor contohnya ✅. Kenapa ini terjadi?

NOTA: Projek ini dihost di Blogger (Blogspot). 

Blogger akan auto-encode sebarang karakter bukan-ASCII dalam tag <script> kepada HTML entities.

Contoh: "✅" bertukar kepada "&#9989;", "★" bertukar kepada "&#9733;", "∞" bertukar kepada "&#8734;".


JADI:

1. JANGAN guna emoji direct dalam string JavaScript (cth: "✅ Gagal")

2. JANGAN guna Unicode escape \uXXXX (cth: "\u2705") — Blogger tetap encode

3. GUNA String.fromCodePoint(0xXXXX) — ini TIDAK akan di-encode

4. Kalau nak inject ke DOM, guna .innerHTML = String.fromCodePoint(...) + 'teks'

5. Kalau nak guna dalam alert(), guna alert(String.fromCodePoint(...) + 'teks')


SIMPAN CONSTANT DI ATAS:

const ICON_OK = String.fromCodePoint(0x2705);     // ✅

const ICON_ERR = String.fromCodePoint(0x274C);    // ❌

const ICON_WARN = String.fromCodePoint(0x26A0);   // ⚠️

const ICON_STAR = String.fromCodePoint(0x2605);   // ★

const ICON_SPARK = String.fromCodePoint(0x2726);  // ✦

const ICON_INFINITY = String.fromCodePoint(0x221E); // ∞


Guna constant ni dalam semua tempat instead of emoji direct atau \u escape.

Boleh guna ayat atas ni sebagai prompt kepada AI untuk halang