utfdecode

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2020 License: MIT Imports: 4 Imported by: 0

README

utfdecode

travis go report card coverage godocs

I wanted to convert text containing escaped UTF-16 and/or UTF-32 codes to just UTF-16. This library helps do that. It rejexes for unicde strings and then converts them to UTF-16 using the standard formula. The code is small enough that you might just consider copy and pasting :)

For example, the following Go code:

jsonData := `{"text":"utf-16:\u2764\u1F47D\u1F680 utf-32:\u2764\ud83d\udc7d\ud83d\ude80"}`
fmt.Println(utfdecode.Decode(jsonData))

will print

{"text":"utf-16:❤👽🚀 utf-32:❤👽🚀"}

Contributing

Pull requests are welcome. Feel free to...

  • Revise documentation
  • Add new features
  • Fix bugs
  • Suggest improvements

License

MIT

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(str string) string

Decode takes any string with escaped UTF-32 / UTF-16 and prints it out as un-escaped (decoded) UTF-16.

Example
jsonData := `{"text":"utf-16:\u2764\u1F47D\u1F680 utf-32:\u2764\ud83d\udc7d\ud83d\ude80"}`
fmt.Println(Decode(jsonData))
Output:

{"text":"utf-16:❤👽🚀 utf-32:❤👽🚀"}

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL