Created
April 18, 2017 03:03
-
-
Save akirattii/bac11aec1ff308d6abcd68faa919b637 to your computer and use it in GitHub Desktop.
文字コードを指定してURLエンコードするサンプル
This file contains hidden or 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
| // npm install encoding-japanese | |
| const encoding = require('encoding-japanese'); | |
| urlEncode("餅", "EUCJP"); // "%CC%DF" | |
| function urlEncode(str, charset) { | |
| let eucArray = encoding.convert(Encoding.stringToCode(str), charset); | |
| return encoding.urlEncode(eucArray); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment