Created
December 4, 2020 16:33
-
-
Save wannyk/42c76bc3cf3431c21e41ff53706cace8 to your computer and use it in GitHub Desktop.
encode utf8 string to euc-kr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const iconv = require('iconv-lite'); | |
const assert = require('assert'); | |
const urlencode = input => input.replace(/[^A-Za-z0-9-_.!~*'()]/g, c => c==' ' ? '+' : [...iconv.encode(c, "EUC-KR")].map(b => '%'+b.toString(16).toUpperCase()).join('')); | |
assert(urlencode('2013_16_방파제축조공사 추가절차 공사비 청구.pdf')=='2013_16_%B9%E6%C6%C4%C1%A6%C3%E0%C1%B6%B0%F8%BB%E7+%C3%DF%B0%A1%C0%FD%C2%F7+%B0%F8%BB%E7%BA%F1+%C3%BB%B1%B8.pdf') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment