šŸš€ DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

utfu

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

utfu

Replaces busted characters carried over from legacy text encodings with the proper UTF-8 characters.

latest
Source
npmnpm
Version
0.3.1
Version published
Maintainers
1
Created
Source

Ć¼Å§āØĆ» āžž utfu

npm npm License: MIT Twitter: @selfagency_llc

Replaces busted characters carried over from legacy text encodings with the proper UTF-8 characters.

Install

yarn add utfu || npm install utfu

Usage

Say you've got a string that looks like this:

There’s no way I’m paying Ć¢ā€šĀ¬30 for that!

Pass it to either method, hex, htx, or txt, and you'll hopefully get back:

There’s no way I’m paying €30 for that!

  • hex substitutes unicode hex values (ie., \u20ac)

  • htx substitutes the HTML escape sequence (ie., €)

  • txt substitutes the actual character (ie., €)

  • See substitution chart here for mappings, more or less

import { hex, htx, txt } from 'utfu'

const dirty = 'On a certain level, itļæ½s like shouting ļæ½fireļæ½ in a crowded theater.'

const cleanHex = hex(dirty)
// --> 'On a certain level, it\u2019s like shouting \u201Cfire\u201D in a crowded theater.'

const cleanHTML = htx(dirty)
// --> 'On a certain level, it’s like shouting “fire” in a crowded theater.'

const cleanTxt = txt(dirty)
// --> 'On a certain level, it’s like shouting ā€œfireā€ in a crowded theater.'

Run tests

yarn test

Author

šŸ‘¤ Daniel Sieradski hello@self.agency

Acknowledgements

Gracious thanks to Mathias Bynens, upon whose he and windows-1252 packages this project depends.

Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ā­ļø if this project helped you!

Keywords

utf

FAQs

Package last updated on 28 Feb 2021

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