Giter Site home page Giter Site logo

encoding-tools's Introduction

encoding-tools

A small collection of tools I like to use for re-encoding text.

Installation

This only applies to url_encode and fullwidth_encode

  1. Clone this repo:

    https://github.com/4wayhandshake/encoding-tools.git
    cd encoding-tools
  2. Copy url_encode.py and fullwidth_encode.py into ~/.local/share

    cp *_encode.py ~/.local/share/
  3. Copy url_encode and fullwidth_encode into your path somewhere

    cp *_encode ~/.local/bin/

url_encode

Usage:

Provide the text as an argument:

url_encode 'hello newline \n'
# hello+newline+%0A

Alternatively, pipe it in:

echo -n 'hello newline \n' | url_encode
# hello+newline+%0A

Pipe it twice to double-encode:

echo -n 'hello newline \n' | url_encode | url_encode
# hello%2Bnewline%2B%250A%0A

fullwidth_encode

Please see this wikipedia page for a description of fullwidth characters.

It's used for turning this strings like 4wayhandshake into 4wayhandshake

Usage:

Provide the text as an argument:

fullwidth_encode 'fullwidth!'
# fullwidth!

Alternatively, pipe it in:

echo 'fullwidth!' | fullwidth_encode
# fullwidth!

Hex using Bash

Simple enough, but here's an example:

# encoding as hex
echo -n 'this is utf-8 text' | xxd -p
# decoding it
echo -n '74686973206973207574662d382074657874' | xxd -r -p

Remember to use -n with echo to suppress the line ending character.

Unicode Encoding

To convert ascii text into UTF-8 unicode:

echo -n 'Special ch@r5 :)' | xxd -p | sed 's/../\\u&/g'
# \u53\u70\u65\u63\u69\u61\u6c\u20\u63\u68\u40\u72\u35\u20\u3a\u29

It's sometimes more useful to have UTF-16 unicode:

echo -n "Special ch@r5 :)" | iconv -t UTF-16LE | xxd -p -c 2 | sed 's/\(..\)\(..\)/\\u\2\1/g' | tr -d '\n'
#\u0053\u0070\u0065\u0063\u0069\u0061\u006c\u0020\u0063\u0068\u0040\u0072\u0035\u0020\u003a\u0029

encoding-tools's People

Contributors

4wayhandshake avatar

Watchers

 avatar

Forkers

al3fbet

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.