Discover Packages
github.com/schollz/utfdecode
package
module
Version:
v1.0.2
Opens a new window with list of versions in this module.
Published: Jul 6, 2020
License: MIT
Opens a new window with license information.
Imports: 4
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
README
¶
utfdecode
I wanted to convert UTF-32 codes to UTF-16, often encoded in some JSON. 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":"Cool! \u1F47D \u2764\ufe0f\ud83d\udc7d\ud83d\ude80"}`
fmt.Println(utfdecode.Decode(jsonData))
will print
{"text":"Cool! 👽 ❤️👽🚀"}
Contributing
Pull requests are welcome. Feel free to...
Revise documentation
Add new features
Fix bugs
Suggest improvements
License
MIT
Expand ▾
Collapse ▴
Documentation
¶
Decode takes any string with escaped UTF-32 / UTF-16 and prints it out
as un-escaped (decoded) UTF-16.
jsonData := `{"text":"Cool! \u1F47D \u2764\ufe0f\ud83d\udc7d\ud83d\ude80"}`
fmt.Println(jsonData)
fmt.Println(Decode(jsonData))
Output:
{"text":"Cool! \u1F47D \u2764\ufe0f\ud83d\udc7d\ud83d\ude80"}
{"text":"Cool! 👽 ❤️👽🚀"}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.