script

package
v0.23.5 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package script tells which writing system text is in, as the translation checks (transcheck) and the apps' text code need it: the scripts written without spaces between words, word characters, the script most of a text's letters are in, and the script a language is written in.

Script names here are coarse, one per writing system the checks tell apart (Han, Japanese, Hangul, Cyrillic, Arabic, Hebrew, Thai, Devanagari, Greek, Latin), not ISO 15924 codes: Japanese is kana with or without Han, and every other script counts as Latin.

Index

Constants

View Source
const (
	Han        = "Han"
	Japanese   = "Japanese"
	Hangul     = "Hangul"
	Cyrillic   = "Cyrillic"
	Arabic     = "Arabic"
	Hebrew     = "Hebrew"
	Thai       = "Thai"
	Devanagari = "Devanagari"
	Greek      = "Greek"
	Latin      = "Latin"
)

The script names Dominant, Has and Of use.

Variables

This section is empty.

Functions

func Dominant

func Dominant(s string) string

Dominant is the script most letters of s are in, "" when s has fewer than two letters. Kana weigh double, and Han with any kana is Japanese; a tie goes to the name first in alphabetical order.

func Has

func Has(s, script string) bool

Has reports whether s has a letter of script (one of the names above; Japanese takes kana or Han, an unknown name Latin).

func IsUnspaced

func IsUnspaced(r rune) bool

IsUnspaced reports whether r belongs to a script written without spaces between words (Han, kana, Thai, Lao, Khmer, Myanmar, Tibetan, Bopomofo, CJK punctuation and full-width forms), where a term may match anywhere instead of only at word boundaries. Hangul is spaced and is not included.

func IsWordRune

func IsWordRune(r rune) bool

IsWordRune reports whether r is part of a word: a letter, a digit or a combining mark.

func Of

func Of(l lang.Tag) string

Of is the script a language is written in, as Dominant names it: Serbian in Latin script (sr-Latn) is Latin, a language not listed is Latin.

Types

This section is empty.

Jump to

Keyboard shortcuts

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