Skip to content

v1.0.0 - Initial Release

Latest

Choose a tag to compare

@R167 R167 released this 17 Aug 21:32

stringy v1.0.0 - Initial Release

Unicode string encoding handling for Go. Provides helpers for working with UTF-8, UTF-16, and UTF-32 string representations, including code unit and code point counting.

Features

  • UTF-16 Support: Utf16 type with proper surrogate pair handling
  • UTF-32 Support: Utf32 type for Unicode code point manipulation
  • UTF-8 Support: Utf8 wrapper with enhanced functionality
  • Unified Interface: All types implement the String interface with CodeUnits() and CodePoints() methods
  • io.Writer Support: UTF-16 and UTF-32 types implement io.Writer and io.StringWriter
  • Correct Code Point Counting: Handles characters outside the Basic Multilingual Plane (BMP)

Why This Library?

Prior to Go 1.23, there was no built-in way to count UTF-16 code units in a string. This is important for interoperability with systems and protocols (such as JavaScript, Windows APIs, and some network protocols) that use UTF-16 as their string encoding.

Installation

go get github.com/R167/stringy@v1.0.0

Quick Example

import "github.com/R167/stringy"

var s stringy.Utf16
s.WriteString("hello 𝄞 world")
fmt.Println(s.String())      // prints: hello 𝄞 world
fmt.Println(s.CodeUnits())   // prints: number of UTF-16 code units
fmt.Println(s.CodePoints())  // prints: number of Unicode code points