Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

iconv-urlencode

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iconv-urlencode

Node ackage to encode and decode url-encoded strings from/to every possible encoding

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

iconv-urlencode

Node package to encode and decode url-encoded strings from/to every possible encoding

This package uses iconv-lite for the encoding from/to different character sets. Therefore all encodings supported by this package can be used here.

The converted string is than url-encoded according to the HTML5 specification. The decoding works too - first url-decoded and than converted from the desired charset with iconv-lite.

Usage

convert given utf8 string to an url encoded ucs-2 string

var conv = require('iconv-urlencode');
var str = 'Oh du fröhliche...';
var urlStr = conv.encode(str, 'ucs-2');

convert an string used in an url with utf-7 encoding to local utf-8

var conv = require('iconv-urlencode');
var urlStr = 'Oh+du+fr%2BAPY-hliche...';
var str = conv.decode(urlStr, 'utf-7');

As Express, Request and Request-Promise packages insist of using utf-8 as the encoding for urls this package must be used to manually create the url params for some strange web services that do not adhere to the W3C sugessted utf-8 encoding.

var conv = require('iconv-urlencode');
var request = require('request');

var urlStr = 'https://example.org/test';
urlStr = urlStr + '?param1=' + conv.encode('bläh', 'win1252') 
         + '&param2=' + conv.encode('blüb', 'win1252');
         
request.get(urlStr).then(function(response) {
  // ... process get response here
});

License

MIT License

Keywords

FAQs

Package last updated on 14 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc