text

package
v0.0.0-...-52d6a69 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2019 License: Apache-2.0, BSD-3-Clause Imports: 0 Imported by: 0

README

Go Text

This repository holds supplementary Go libraries for text processing, many involving Unicode.

Semantic Versioning

This repo uses Semantic versioning (http://semver.org/), so

  1. MAJOR version when you make incompatible API changes,
  2. MINOR version when you add functionality in a backwards-compatible manner, and
  3. PATCH version when you make backwards-compatible bug fixes.

Until version 1.0.0 of x/text is reached, the minor version is considered a major version. So going from 0.1.0 to 0.2.0 is considered to be a major version bump.

A major new CLDR version is mapped to a minor version increase in x/text. Any other new CLDR version is mapped to a patch version increase in x/text.

It is important that the Unicode version used in x/text matches the one used by your Go compiler. The x/text repository supports multiple versions of Unicode and will match the version of Unicode to that of the Go compiler. At the moment this is supported for Go compilers from version 1.7.

Download/Install

The easiest way to install is to run go get -u golang.org/x/text. You can also manually git clone the repository to $GOPATH/src/golang.org/x/text.

Contribute

To submit changes to this repository, see http://golang.org/doc/contribute.html.

To generate the tables in this repository (except for the encoding tables), run go generate from this directory. By default tables are generated for the Unicode version in core and the CLDR version defined in golang.org/x/text/unicode/cldr.

Running go generate will as a side effect create a DATA subdirectory in this directory, which holds all files that are used as a source for generating the tables. This directory will also serve as a cache.

Testing

Run

go test ./...

from this directory to run all tests. Add the "-tags icu" flag to also run ICU conformance tests (if available). This requires that you have the correct ICU version installed on your system.

TODO:

  • updating unversioned source files.

Generating Tables

To generate the tables in this repository (except for the encoding tables), run go generate from this directory. By default tables are generated for the Unicode version in core and the CLDR version defined in golang.org/x/text/unicode/cldr.

Running go generate will as a side effect create a DATA subdirectory in this directory which holds all files that are used as a source for generating the tables. This directory will also serve as a cache.

Versions

To update a Unicode version run

UNICODE_VERSION=x.x.x go generate

where x.x.x must correspond to a directory in http://www.unicode.org/Public/. If this version is newer than the version in core it will also update the relevant packages there. The idna package in x/net will always be updated.

To update a CLDR version run

CLDR_VERSION=version go generate

where version must correspond to a directory in http://www.unicode.org/Public/cldr/.

Note that the code gets adapted over time to changes in the data and that backwards compatibility is not maintained. So updating to a different version may not work.

The files in DATA/{iana|icu|w3|whatwg} are currently not versioned.

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://golang.org/doc/contribute.html.

The main issue tracker for the image repository is located at https://github.com/golang/go/issues. Prefix your issue with "x/image:" in the subject line, so it is easy to find.

Documentation

Overview

text is a repository of text-related packages related to internationalization (i18n) and localization (l10n), such as character encodings, text transformations, and locale-specific text handling.

There is a 30 minute video, recorded on 2017-11-30, on the "State of golang.org/x/text" at https://www.youtube.com/watch?v=uYrDrMEGu58

Directories

Path Synopsis
Package cases provides general and language-specific case mappers.
Package cases provides general and language-specific case mappers.
cmd
gotext
gotext is a tool for managing text in Go source code.
gotext is a tool for managing text in Go source code.
Package collate contains types for comparing and sorting Unicode strings according to a given collation order.
Package collate contains types for comparing and sorting Unicode strings according to a given collation order.
Package currency contains currency-related functionality.
Package currency contains currency-related functionality.
Package encoding defines an interface for character encodings, such as Shift JIS and Windows 1252, that can convert to and from UTF-8.
Package encoding defines an interface for character encodings, such as Shift JIS and Windows 1252, that can convert to and from UTF-8.
charmap
Package charmap provides simple character encodings such as IBM Code Page 437 and Windows 1252.
Package charmap provides simple character encodings such as IBM Code Page 437 and Windows 1252.
htmlindex
Package htmlindex maps character set encoding names to Encodings as recommended by the W3C for use in HTML 5.
Package htmlindex maps character set encoding names to Encodings as recommended by the W3C for use in HTML 5.
ianaindex
Package ianaindex maps names to Encodings as specified by the IANA registry.
Package ianaindex maps names to Encodings as specified by the IANA registry.
internal
Package internal contains code that is shared among encoding implementations.
Package internal contains code that is shared among encoding implementations.
internal/identifier
Package identifier defines the contract between implementations of Encoding and Index by defining identifiers that uniquely identify standardized coded character sets (CCS) and character encoding schemes (CES), which we will together refer to as encodings, for which Encoding implementations provide converters to and from UTF-8.
Package identifier defines the contract between implementations of Encoding and Index by defining identifiers that uniquely identify standardized coded character sets (CCS) and character encoding schemes (CES), which we will together refer to as encodings, for which Encoding implementations provide converters to and from UTF-8.
japanese
Package japanese provides Japanese encodings such as EUC-JP and Shift JIS.
Package japanese provides Japanese encodings such as EUC-JP and Shift JIS.
korean
Package korean provides Korean encodings such as EUC-KR.
Package korean provides Korean encodings such as EUC-KR.
simplifiedchinese
Package simplifiedchinese provides Simplified Chinese encodings such as GBK.
Package simplifiedchinese provides Simplified Chinese encodings such as GBK.
traditionalchinese
Package traditionalchinese provides Traditional Chinese encodings such as Big5.
Package traditionalchinese provides Traditional Chinese encodings such as Big5.
unicode
Package unicode provides Unicode encodings such as UTF-16.
Package unicode provides Unicode encodings such as UTF-16.
unicode/utf32
Package utf32 provides the UTF-32 Unicode encoding.
Package utf32 provides the UTF-32 Unicode encoding.
feature
plural
Package plural provides utilities for handling linguistic plurals in text.
Package plural provides utilities for handling linguistic plurals in text.
Package internal contains non-exported functionality that are used by packages in the text repository.
Package internal contains non-exported functionality that are used by packages in the text repository.
catmsg
Package catmsg contains support types for package x/text/message/catalog.
Package catmsg contains support types for package x/text/message/catalog.
cldrtree
Package cldrtree builds and generates a CLDR index file, including all inheritance.
Package cldrtree builds and generates a CLDR index file, including all inheritance.
colltab
Package colltab contains functionality related to collation tables.
Package colltab contains functionality related to collation tables.
export/idna
Package idna implements IDNA2008 using the compatibility processing defined by UTS (Unicode Technical Standard) #46, which defines a standard to deal with the transition from IDNA2003.
Package idna implements IDNA2008 using the compatibility processing defined by UTS (Unicode Technical Standard) #46, which defines a standard to deal with the transition from IDNA2003.
format
Package format contains types for defining language-specific formatting of values.
Package format contains types for defining language-specific formatting of values.
gen
Package gen contains common code for the various code generation tools in the text repository.
Package gen contains common code for the various code generation tools in the text repository.
gen/bitfield
Package bitfield converts annotated structs into integer values.
Package bitfield converts annotated structs into integer values.
language/compact
Package compact defines a compact representation of language tags.
Package compact defines a compact representation of language tags.
number
Package number contains tools and data for formatting numbers.
Package number contains tools and data for formatting numbers.
stringset
Package stringset provides a way to represent a collection of strings compactly.
Package stringset provides a way to represent a collection of strings compactly.
tag
Package tag contains functionality handling tags and related data.
Package tag contains functionality handling tags and related data.
testtext
Package testtext contains test data that is of common use to the text repository.
Package testtext contains test data that is of common use to the text repository.
triegen
Package triegen implements a code generator for a trie for associating unsigned integer values with UTF-8 encoded runes.
Package triegen implements a code generator for a trie for associating unsigned integer values with UTF-8 encoded runes.
ucd
Package ucd provides a parser for Unicode Character Database files, the format of which is defined in http://www.unicode.org/reports/tr44/.
Package ucd provides a parser for Unicode Character Database files, the format of which is defined in http://www.unicode.org/reports/tr44/.
utf8internal
Package utf8internal contains low-level utf8-related constants, tables, etc.
Package utf8internal contains low-level utf8-related constants, tables, etc.
Package language implements BCP 47 language tags and related functionality.
Package language implements BCP 47 language tags and related functionality.
display
Package display provides display names for languages, scripts and regions in a requested language.
Package display provides display names for languages, scripts and regions in a requested language.
Package message implements formatted I/O for localized strings with functions analogous to the fmt's print functions.
Package message implements formatted I/O for localized strings with functions analogous to the fmt's print functions.
catalog
Package catalog defines collections of translated format strings.
Package catalog defines collections of translated format strings.
pipeline
Package pipeline provides tools for creating translation pipelines.
Package pipeline provides tools for creating translation pipelines.
Package number formats numbers according to the customs of different locales.
Package number formats numbers according to the customs of different locales.
Package runes provide transforms for UTF-8 encoded text.
Package runes provide transforms for UTF-8 encoded text.
Package search provides language-specific search and string matching.
Package search provides language-specific search and string matching.
secure is a repository of text security related packages.
secure is a repository of text security related packages.
bidirule
Package bidirule implements the Bidi Rule defined by RFC 5893.
Package bidirule implements the Bidi Rule defined by RFC 5893.
precis
Package precis contains types and functions for the preparation, enforcement, and comparison of internationalized strings ("PRECIS") as defined in RFC 8264.
Package precis contains types and functions for the preparation, enforcement, and comparison of internationalized strings ("PRECIS") as defined in RFC 8264.
Package transform provides reader and writer wrappers that transform the bytes passing through as well as various transformations.
Package transform provides reader and writer wrappers that transform the bytes passing through as well as various transformations.
unicode holds packages with implementations of Unicode standards that are mostly used as building blocks for other packages in golang.org/x/text, layout engines, or are otherwise more low-level in nature.
unicode holds packages with implementations of Unicode standards that are mostly used as building blocks for other packages in golang.org/x/text, layout engines, or are otherwise more low-level in nature.
bidi
Package bidi contains functionality for bidirectional text support.
Package bidi contains functionality for bidirectional text support.
cldr
Package cldr provides a parser for LDML and related XML formats.
Package cldr provides a parser for LDML and related XML formats.
norm
Package norm contains types and functions for normalizing Unicode strings.
Package norm contains types and functions for normalizing Unicode strings.
rangetable
Package rangetable provides utilities for creating and inspecting unicode.RangeTables.
Package rangetable provides utilities for creating and inspecting unicode.RangeTables.
runenames
Package runenames provides rune names from the Unicode Character Database.
Package runenames provides rune names from the Unicode Character Database.
Package width provides functionality for handling different widths in text.
Package width provides functionality for handling different widths in text.

Jump to

Keyboard shortcuts

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