euc-kr-editor-sanitizer
v1.0.0
Published
Sanitize SmartEditor and HTML editor content for EUC-KR environments by dropping unsupported Hangul and preserving emoji as numeric character references.
Maintainers
Readme
euc-kr-editor-sanitizer
Sanitize SmartEditor and HTML editor content for EUC-KR environments.
It keeps ordinary EUC-KR Hangul, converts emoji-like Unicode code points to HTML numeric character references, and drops Hangul syllables/jamo that commonly break legacy EUC-KR pipelines.
Install
npm install euc-kr-editor-sanitizerUsage
import { sanitizeForEucKrEditor } from "euc-kr-editor-sanitizer";
sanitizeForEucKrEditor("<p>가나다 👍 뷁</p>");
// "<p>가나다 👍 </p>"SmartEditor2 Submit Hook
<script src="https://unpkg.com/euc-kr-editor-sanitizer/dist/browser.global.js"></script>
<script>
function submitContents(elClickedObj) {
oEditors.getById["ir1"].exec("UPDATE_CONTENTS_FIELD", []);
var textarea = document.getElementById("ir1");
textarea.value = EucKrEditorSanitizer.sanitizeForEucKrEditor(textarea.value);
elClickedObj.form.submit();
}
</script>API
sanitizeForEucKrEditor(input: unknown): string
isEmojiLike(codePoint: number): boolean
isEucKrHangulSyllable(codePoint: number): boolean
shouldDropForEucKr(codePoint: number): boolean
toNumericCharacterReference(codePoint: number): stringNotes
This package uses the KS X 1001 two-byte Hangul syllable set as the allowed Hangul syllable list. Modern Hangul syllables outside that set are removed to avoid broken EUC-KR submissions.
