punycode


1. Encode a Unicode domain name

const punycode = require('punycode');

const domain = 'xn--maana-pta.no';
const encoded = punycode.encode(domain);
console.log(encoded); // Output: maana-pta.no

2. Decode a Punycode-encoded domain name

const punycode = require('punycode');

const encoded = 'maana-pta.no';
const domain = punycode.decode(encoded);
console.log(domain); // Output: xn--maana-pta.no

3. Validate a Punycode-encoded domain name

const punycode = require('punycode');

const domain = 'xn--maana-pta.no';
const isValid = punycode.isValid(domain);
console.log(isValid); // Output: true

4. Convert a Punycode-encoded string to Unicode

5. Convert a Unicode string to Punycode

6. Convert a Punycode-encoded string to a Buffer

7. Convert a Buffer to a Punycode-encoded string

8. Normalize a Punycode-encoded string

9. Encode a Unicode string with a custom alphabet

10. Decode a Punycode-encoded string with a custom alphabet

11. Sort an array of Punycode-encoded domain names

12. Test if a string is a valid Punycode-encoded domain name

13. Encode a Unicode string with a custom mapping table

14. Decode a Punycode-encoded string with a custom mapping table

15. Encode a Unicode string with a custom error handler

16. Decode a Punycode-encoded string with a custom error handler

17. Encode a Unicode string without throwing an error on invalid characters

18. Decode a Punycode-encoded string without throwing an error on invalid characters

19. Encode a Unicode string using a streaming interface

20. Decode a Punycode-encoded string using a streaming interface

21. Convert a Punycode-encoded string to its Unicode representation using a streaming interface

22. Convert a Unicode string to its Punycode representation using a streaming interface

23. Encode a Unicode string using a custom delimiter

24. Decode a Punycode-encoded string using a custom delimiter

25. Encode a Unicode string with a custom prefix

26. Decode a Punycode-encoded string with a custom prefix

27. Encode a Unicode string with a custom suffix

28. Decode a Punycode-encoded string with a custom suffix

29. Encode a Unicode string with a custom padding character

30. Decode a Punycode-encoded string with a custom padding character

31. Encode a Unicode string with a custom separator

32. Decode a Punycode-encoded string with a custom separator

33. Encode a Unicode string with a custom padding string

34. Decode a Punycode-encoded string with a custom padding string

35. Encode a Unicode string with a custom error handler and providing information about the error

36. Decode a Punycode-encoded string with a custom error handler and providing information about the error