jptools

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package jptools provides a few simple functions for dealing with text in Japanese.

Index

Constants

This section is empty.

Variables

View Source
var Utf8of map[string]string

Utf8of maps JIS X 0213:2004 codepoints to Unicode codepoints.

Functions

func Convert

func Convert(mkt string) (s string, err error)

Convert returns the unicode string corresponding to the JIS codepoint in the 面-区-点 (men-ku-ten) format. mkt needs to be formatetted as a string of the form "d-dd-dd". err is nil if conversion succeeds.

func IsHiragana

func IsHiragana(r rune) bool

IsHiragana checkes if r is hiragana,

func IsKatakana

func IsKatakana(r rune) bool

IsKatakana checkes if r is katakana.

func MktToJis

func MktToJis(mkt string) (s string, err error)

MktToJis returns the JIS code point corresponding to the provided 面-区-点 (men-ku-ten) codepoint. mkt needs to be formatetted as a string of the form "d-dd-dd".

func ToHiragana

func ToHiragana(r rune) rune

ToHiragana converts r to hiragana (iff. r is katakana)

func ToKatakana

func ToKatakana(r rune) rune

ToKatakana convers r to katakana (iff. r is hiragana).

func UnicodeOf

func UnicodeOf(mkt string) (s string, err error)

UnicodeOf returns the Unicode point as an ASCII escaped Go string. mkt must be provided in the 面-区-点 (men-ku-ten) format as an ASCII encoded string. mkt needs to be formatetted as a string of the form "d-dd-dd".

Types

type CharTypeID

type CharTypeID int

CharTypeID represents character types.

const (
	Symbol CharTypeID = 1 << iota //Symbol captures everything that isn't captured by the other categories.
	KanNum
	ArabNumF
	ArabNum
	Hiragana
	Katakana
	KatakanaH
	Kanji
	LatinF
	Latin
)

Define charater types.

func CharType

func CharType(r rune) CharTypeID

CharType returns the character type of r according to the above classification. The Kanji numerals are identified both as Kanji and KanNum using the bitmask KanNum | Kanji.

func (CharTypeID) Name

func (c CharTypeID) Name() string

Name retunrs the character type of c as a string. E.g. "Katakana" if c is katakana.

Jump to

Keyboard shortcuts

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