decode-hex-lib
Version:
Library to decode hexadecimal encoded strings
40 lines (30 loc) • 921 B
Markdown
into UTF-8 characters.
This library provides a function to decode strings containing hexadecimal codes preceded by % (e.g., %F3) into their respective UTF-8 characters.
Link to Latin-1 character table: https://en.wikipedia.org/wiki/ISO/IEC_8859-1
```bash
npm install decode-hex-lib
```
```javascript
import { decodeHex } from 'decode-hex-lib';
const encodedString = "S%E3o%20Paulo";
const decodedString = decodeHex(encodedString);
console.log(decodedString); // Output: São Paulo
```
decodeHex(encodedString: string): string
Decodes a hexadecimal string to a UTF-8 string.
encodedString: The string to be decoded.
Returns: The decoded string.
```javascript
decodeHex("Gest%E3o"); // Retorna: Gestão
decodeHex("%C9poca"); // Retorna: Época
```
To run the tests, use:
```bash
npm test
```
Library to decode hexadecimal strings