Node.js Punycode29 Aug 2024 | 2 min read What is PunycodePunycode is an encoding syntax which is used to convert Unicode (UTF-8) string of characters to basic ASCII string of characters. Since host names only understand ASCII characters so Punycode is used. It is used as an internationalized domain name (IDN or IDNA). Let's understand it with an example: Assume if you search for mañana.com in your browser so your browser (which is IDNA enabled) first convert this to punycode xn--maana-pta.com because the character ñ is not allowed in regular domain name. It is not supported in older versions. Punycode in Node.jsPunycode.js is bundled with Node.js v0.6.2 and later versions. If you want to use it with other Node.js versions then use npm to install punycode module first. You have to use require ('punycode') to access it. Syntax: punycode.decode(string)It is used to convert a Punycode string of ASCII symbols to a string of Unicode symbols. File: punycode_example1.js Output: ![]() punycode.encode(string)It is used to convert a string of Unicode symbols to a Punycode string of ASCII symbols. File: punycode_example2.js Output: ![]() punycode.toASCII(domain)It is used to convert a Unicode string representing a domain name to Punycode. Only the non-ASCII part of the domain name is converted. File: punycode_example3.js Output: ![]() punycode.toUnicode(domain)It is used to convert a Punycode string representing a domain name to Unicode. Only the Punycoded part of the domain name is converted. File: punycode_example4.js Output: ![]() Next TopicNode.js TTY |
The provides methods to deal with query string. It can be used to convert query string into JSON object and vice-versa. To use query string module, you need to use require('querystring'). Methods The utility has four methods. The two important methods are given below. Method Description querystring.parse(str[, sep][, eq][,...
1 min read
What is TLS/SSL TLS stands for Transport Layer Security. It is the successor to Secure Sockets Layer (SSL). TLS along with SSL is used for cryptographic protocols to secure communication over the web. TLS uses public-key cryptography to encrypt messages. It encrypts communication generally on the TCP...
2 min read
The module supports cryptography. It provides cryptographic functionality that includes a set of wrappers for open SSL's hash HMAC, cipher, decipher, sign and verify functions. What is Hash A hash is a fixed-length string of bits i.e. procedurally and deterministically generated from some arbitrary block of...
1 min read
Callback is an asynchronous equivalent for a function. It is called at the completion of each task. In Node.js, callbacks are generally used. All APIs of Node are written in a way to supports callbacks. For example: when a function start reading file, it returns the...
2 min read
Install Node.js on Windows To install and setup an environment for Node.js, you need the following two softwares available on your computer: Text Editor. Node.js Binary installable Text Editor: The text editor is used to type your program. For example: Notepad is used in Windows, vim or vi...
1 min read
The term REPL stands for Read Eval Print and Loop. It specifies a computer environment like a window console or a Unix/Linux shell where you can enter the commands and the system responds with an output in an interactive mode. REPL Environment The Node.js or node come...
2 min read
Node.js Tutorial Node.js tutorial provides basic and advanced concepts of Node.js. Our Node.js tutorial is designed for beginners and professionals both. Node.js is a cross-platform environment and library for running JavaScript applications which is used to create networking and server-side applications. Our Node.js tutorial includes all topics of Node.js such...
3 min read
Testing The Node.js Assert is the most elementary way to write tests. It provides no feedback when running your test unless one fails. The assert module provides a simple set of assertion tests that can be used to test invariants. The module is intended for internal...
1 min read
The Node.js path module is used to handle and transform files paths. This module can be imported by using the following syntax: Syntax: var path = require ("path") Methods Let's see the list of methods used in path module: Index Method Description 1. path.normalize(p) It is used to normalize a string path, taking care...
2 min read
The module contains methods to get information of given hostname. Let's see the list of commonly used DNS functions: dns.getServers() dns.setServers(servers) dns.lookup(hostname[, options], callback) dns.lookupService(address, port, callback) dns.resolve(hostname[, rrtype], callback) dns.resolve4(hostname, callback) dns.resolve6(hostname, callback) dns.resolveCname(hostname, callback) dns.resolveMx(hostname, callback) dns.resolveNs(hostname, callback) dns.resolveSoa(hostname, callback) dns.resolveSrv(hostname, callback) dns.resolvePtr(hostname, callback) dns.resolveTxt(hostname, callback) dns.reverse(ip, callback) Example 1 Let's see the example of dns.lookup() function. File: dns_example1.js const dns...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India