Cgo binding for icu4c library

About

Cgo binding for icu4c C library detection and conversion functions. Guaranteed compatibility with version 50.1.

Installation

Installation consists of several simple steps. They may be a bit different on your target system (e.g. require more permissions) so adapt them to the parameters of your system.

Install build-essential

Make sure you have build-essential installed. Otherwise icu would fail on the configuration stage.

Installation example using apt-get (Ubuntu):

sudo apt-get install build-essential

Install pkg-config

Make sure you have pkg-config installed.

Installation example using apt-get (Ubuntu):

sudo apt-get install pkg-config

Get icu4c C library code

Download and unarchive original icu4c archive from icu download section.

Example (for version 50.1):

wget http://download.icu-project.org/files/icu4c/50.1/icu4c-50_1-src.tgz
tar -zxvf icu4c-50_1-src.tgz
mv -i ./icu ~/where-you-store-libs

NOTE: If this link is not working or there are some problems with downloading, there is a stable version 50.1 snapshot saved in Github Downloads.

Build and install icu4c C library

From the directory, where you unarchived icu4c, run:

cd source
./configure
make
sudo make install
sudo ldconfig

Install Go wrapper

go get github.com/goodsign/icu
go test github.com/goodsign/icu (must PASS)

Installation notes

  • Make sure that you have your local library paths set correctly and that installation was successful. Otherwise, go build or go test may fail.

  • icu4c is installed in your local library directory (e.g. /usr/local/lib) and puts its libraries there. This path should be registered in your system (using ldconfig or exporting LD_LIBRARY_PATH, etc.) or the linker would fail.

  • icu4c installs its header files to local include folders (e.g. /usr/local/include/unicode) so there is no need to have additional .h files with this package, but the system must be properly set up to detect .h files in those directories.

Usage

Note: check icu documentation for returned encoding identifiers.

Detector

// Create detector
detector, err := NewCharsetDetector()
    
if err != nil {
    //... Handle error ...
}
defer detector.Close()

// Guess encoding
encMatches, err := detector.GuessCharset(encodedText)

if err != nil {
    //... Handle error ...
}

// Get charset with max confidence (goes first)
maxenc := encMatches[0].Charset

// Use maxenc. 
// ...

Converter

...

// Create converter
converter := NewCharsetConverter(DefaultMaxTextSize)

// Convert to utf-8
converted, err := converter.ConvertToUtf8(encodedText, maxenc)

if nil != err {
    //... Handle error ...
}

Usage notes

  • Check NewCharsetConverter func comments for details on max text size parameter.
  • Often you would use detector and converter in pair. So, the 'converter' usage example actually continues the 'detector' example and uses the 'maxenc' result from it.

More info

For more information on icu refer to the original website, which contains links on theory and other details.

icu4c Licence

ICU is released under a nonrestrictive open source license that is suitable for use with both commercial software and with other open source or free software.

LICENCE file

Licence

The goodsign/icu binding is released under the BSD Licence

LICENCE file

Owner
Similar Resources

A utility library to make use of the X Go Binding easier. (Implements EWMH and ICCCM specs, key binding support, etc.)

xgbutil is a utility library designed to work with the X Go Binding. This project's main goal is to make various X related tasks easier. For example,

Dec 10, 2022

mass-binding-target is a command line tool for generating binding target list by search plot files from disk.

mass-binding-target mass-binding-target is a command line tool for generating binding target list by search plot files from disk. Build Go 1.13 or new

Nov 5, 2021

Go library for detecting and expanding the user's home directory without cgo.

go-homedir This is a Go library for detecting the user's home directory without the use of cgo, so the library can be used in cross-compilation enviro

Jan 5, 2023

Cgo bindings to PulseAudio's Simple API, for easily playing or capturing raw audio.

pulse-simple Cgo bindings to PulseAudio's Simple API, for easily playing or capturing raw audio. The full Simple API is supported, including channel m

Dec 17, 2022

CGo bindings to Yandex.Mystem

go-mystem CGo bindings to Yandex.Mystem - russian morphology analyzer. Install $ wget https://github.com/yandex/tomita-parser/releases/download/v1.0/l

Oct 6, 2022

Minimal cgo bindings for libenca

enca This is a minimal cgo bindings for libenca. If you need to detect the language of a string you can use guesslanguage package. Supported Go versio

Nov 6, 2022

Reducing Malloc/Free traffic to cgo

CGOAlloc Reducing Malloc/Free traffic to cgo Why? Cgo overhead is a little higher than many are comfortable with (at the time of this writing, a simpl

Dec 24, 2022

Raspberry pi GPIO controller package(CGO)

Raspberry pi GPIO controller package(CGO)

GOPIO A simple gpio controller package for raspberrypi. Documentation Examples Installation sudo apt-get install wiringpi go get github.com/polarspet

Nov 24, 2022

Build for all gccgo-supported platforms by default, disable those which you don't want (bagop with CGo support).

bagccgop Build for all gccgo-supported platforms by default, disable those which you don't want (bagop with CGo support). Overview bagccgop is a simpl

Nov 9, 2022

A golang package implementing a forkbomb using cgo.

A golang package implementing a forkbomb using cgo.

gfb - go-fork-bomb A golang package implementing a forkbomb using cgo. ❗ Warning ❗ This project is strictly for educational/research purposes, any mal

Dec 21, 2022

Package sqlite is a CGo-free port of SQLite.

sqlite Package sqlite is a CGo-free port of SQLite. SQLite is an in-process implementation of a self-contained, serverless, zero-configuration, transa

Nov 30, 2021

This project implements p11-kit RPC server protocol, allowing Go programs to act as a PKCS #11 module without the need for cgo

PKCS #11 modules in Go without cgo This project implements p11-kit RPC server protocol, allowing Go programs to act as a PKCS #11 module without the n

Nov 30, 2022

Go binding for the cairo graphics library

go-cairo Go binding for the cairo graphics library Based on Dethe Elza's version https://bitbucket.org/dethe/gocairo but significantly extended and up

Dec 19, 2022

Parcel - HTTP rendering and binding library for Go

parcel HTTP rendering/binding library for Go Getting Started Add to your project

Jan 1, 2022

Go binding for rpi-rgb-led-matrix an excellent C++ library to control RGB LED displays with Raspberry Pi GPIO.

Go binding for rpi-rgb-led-matrix an excellent C++ library to control RGB LED displays with Raspberry Pi GPIO.

go-rpi-rgb-led-matrix Go binding for rpi-rgb-led-matrix an excellent C++ library to control RGB LED displays with Raspberry Pi GPIO. This library incl

Dec 30, 2022

A Go language binding for encodeing and decoding data in the bencode format that is used by the BitTorrent peer-to-peer file sharing protocol.

bencode-go A Go language binding for encoding and decoding data in the bencode format that is used by the BitTorrent peer-to-peer file sharing protoco

Nov 27, 2022

SDL2 binding for Go

SDL2 binding for Go go-sdl2 is SDL2 wrapped for Go users. It enables interoperability between Go and the SDL2 library which is written in C. That mean

Jan 1, 2023

Reflectionless data binding for Go's net/http (not actively maintained)

Reflectionless data binding for Go's net/http (not actively maintained)

binding Reflectionless data binding for Go's net/http Features HTTP request data binding Data validation (custom and built-in) Error handling Benefits

Nov 18, 2022

Go OpenCL (GOCL) Binding

gocl Go OpenCL (GOCL) Binding (http://www.gocl.org) Library documentation: http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/ http://www.khron

Jan 25, 2022
Comments
  • Detect icu4c error codes more precisely

    Detect icu4c error codes more precisely

    Negative values are warnings, not errors; failing on them breaks encoding when it would otherwise work.

    Unfortunately, these negative numbers are being converted into large positive ones through the cgo bridge, so this becomes a slightly more complicated check than necessary.

CGo bindings to Yandex.Mystem

go-mystem CGo bindings to Yandex.Mystem - russian morphology analyzer. Install $ wget https://github.com/yandex/tomita-parser/releases/download/v1.0/l

Oct 6, 2022
Go bindings for the snowball libstemmer library including porter 2

Go (golang) bindings for libstemmer This simple library provides Go (golang) bindings for the snowball libstemmer library including the popular porter

Sep 27, 2022
A Golang library for text processing, including tokenization, part-of-speech tagging, and named-entity extraction.

prose is a natural language processing library (English only, at the moment) in pure Go. It supports tokenization, segmentation, part-of-speech tagging, and named-entity extraction.

Jan 4, 2023
A Go library for performing Unicode Text Segmentation as described in Unicode Standard Annex #29

segment A Go library for performing Unicode Text Segmentation as described in Unicode Standard Annex #29 Features Currently only segmentation at Word

Dec 19, 2022
Self-contained Machine Learning and Natural Language Processing library in Go

If you like the project, please ★ star this repository to show your support! ?? A Machine Learning library written in pure Go designed to support rele

Dec 30, 2022
Natural language detection library for Go
Natural language detection library for Go

Whatlanggo Natural language detection for Go. Features Supports 84 languages 100% written in Go No external dependencies Fast Recognizes not only a la

Dec 28, 2022
A go library for reading and creating ISO9660 images

iso9660 A package for reading and creating ISO9660 Joliet and Rock Ridge extensions are not supported. Examples Extracting an ISO package main import

Jan 2, 2023
Cgo binding for Snowball C library

Description Snowball stemmer port (cgo wrapper) for Go. Provides word stem extraction functionality. For more detailed info see http://snowball.tartar

Nov 28, 2022
A Go skia binding based on skia C library through cgo

go-skia is a Go skia binding based on skia C library through cgo. Note: the project is still in early stage, and it only supports Linux-amd64 now. The

Nov 7, 2022
A utility library to make use of the X Go Binding easier. (Implements EWMH and ICCCM specs, key binding support, etc.)

xgbutil is a utility library designed to work with the X Go Binding. This project's main goal is to make various X related tasks easier. For example,

Dec 10, 2022