Socket
Socket
Sign inDemoInstall

unicode-escapes

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    unicode-escapes

Encode and decode Unicode escapes in a string


Version published
Weekly downloads
3
decreased by-40%
Maintainers
1
Install size
4.81 kB
Created
Weekly downloads
 

Readme

Source

unicode-escapes

Encode and decode Unicode escapes in a string

Can be useful when a tool or service returns text with encoded Unicode characters.

Install

npm install unicode-escapes

Usage

import {encodeUnicodeEscapes, decodeUnicodeEscapes} from 'unicode-escapes';

console.log(encodeUnicodeEscapes('Hello, โลก'));
//=> 'Hello, \u{e42}\u{e25}\u{e01}'

console.log(decodeUnicodeEscapes('Hello, \\u{e42}\\u{e25}\\u{e01}'));
//=> 'Hello, โลก'

API

encodeUnicodeEscapes(string)

Encode Unicode characters in a string to Unicode escapes.

decodeUnicodeEscapes(string)

Decode Unicode escapes in a string to Unicode characters.

Use-cases

  • Debugging and logging: Encoding and decoding Unicode escapes can be valuable in debugging scenarios, where you might need to inspect strings with non-visible or special characters. It can assist in displaying logs, traces, or debug outputs that are human-readable.
  • Data serialization and deserialization: Ensuring consistent representation of Unicode characters when saving and reading data, particularly in formats that may have special handling for certain escape sequences.
  • Source code analysis and manipulation: For tooling that analyzes or manipulates source code, such as linters or code transformation tools, where representing characters in escape sequences might be necessary.
  • Interoperability with legacy systems: When interacting with systems that expect a particular escape syntax for Unicode characters.

Keywords

FAQs

Last updated on 25 Aug 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc