存儲(chǔ)時(shí),使用 encodeURIComponent
進(jìn)行轉(zhuǎn)換:
例如:“國(guó)際標(biāo)準(zhǔn)萬(wàn)國(guó)碼已編bai制有如du??、??、??、??、??等等千余個(gè)表情符號(hào)”
content = encodeURIComponent(content);
轉(zhuǎn)換后的內(nèi)容:
%E5%9B%BD%E9%99%85%E6%A0%87%E5%87%86%E4%B8%87%E5%9B%BD%E7%A0%81%E5%B7%B2%E7%BC%96bai%E5%88%B6%E6%9C%89%E5%A6%82du%F0%9F%98%80%E3%80%81%F0%9F%91%A4%E3%80%81%F0%9F%90%89%E3%80%81%F0%9F%90%95%E3%80%81%F0%9F%90%B1%E7%AD%89%E7%AD%89%E5%8D%83%E4%BD%99%E4%B8%AA%E8%A1%A8%E6%83%85%E7%AC%A6%E5%8F%B7
回顯時(shí),使用 decodeURIComponent
解析:
content = decodeURIComponent(content);
解析后,即可完整還原顯示:
screenshot-localhost_8088-2020.06.png