kanaco

package module
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 3 Imported by: 0

README

KanaCo

Overview

KanaCo is the kana character converter inspired by the function mb_convert_kana in PHP.

Install

# go get github.com/tsukinoha/kanaco

Mode

Mode Description
r Convert zenkaku alphabets to hankaku
R Convert hankaku alphabets to zenkaku
n Convert zenkaku numbers to hankaku
N Convert hankaku numbers to zenkaku
a Convert zenkaku alphabets and numbers to hankaku (U+0021 - U+007E excluding U+0022, U+0027, U+005C, U+007E)
A Convert hankaku alphabets and numbers to zenkaku (U+0021 - U+007E excluding U+0022, U+0027, U+005C, U+007E)
s Convert zenkaku space to hankaku (U+3000 -> U+0020)
S Convert hankaku space to zenkaku (U+0020 -> U+3000)
k Convert zenkaku katakana to hankaku katakana
K Convert hankaku katakana to zenkaku katakana
h Convert zenkaku hiragana to hankaku katakana
H Convert hankaku katakana to zenkaku hiragana
c Convert zenkaku katakana to zenkaku hiragana
C Convert zenkaku hiragana to zenkaku katakana

Usage

package main
	
import (
    "io"
    "io/ioutil"
    "github.com/tsukinoha/kanaco"
)

func main () {

    // String Style
    in1 := "123abcABC 123abcABC"
    out1 := kanaco.String(in1, "a")
    println(out1) // 123abcABC 123abcABC

    // Byte Style
    in2 := []byte("123abcABC 123abcABC")
    out2 := kanaco.Byte(in2, "RS")
    println(out2) // 123abcABC 123abcABC

    // Reader Style
    ioutil.WriteFile("example.txt", []byte("カナコ コンバーター Ver1"), 0644)
    f, _ := os.Open("example.txt")
    reader := kanaco.NewReader(f, "Kas")
    for {
        buf := make([]byte, 4096)
        _, err := reader.Read(buf)
        if err == io.EOF {
            break
        }
        println(string(buf)) // カナコ コンバーター Ver1
    }
}

License

KanaCo is distributed under The MIT License.
https://opensource.org/licenses/mit-license.php

Documentation

Index

Constants

View Source
const (
	BufChars    int = 6
	FLT_ASIS    int = 0
	FLT_LOWER_R int = 1 << 0
	FLT_UPPER_R int = 1 << 1
	FLT_LOWER_N int = 1 << 2
	FLT_UPPER_N int = 1 << 3
	FLT_LOWER_A int = 1 << 4
	FLT_UPPER_A int = 1 << 5
	FLT_LOWER_S int = 1 << 6
	FLT_UPPER_S int = 1 << 7
	FLT_LOWER_K int = 1 << 8
	FLT_UPPER_K int = 1 << 9
	FLT_LOWER_H int = 1 << 10
	FLT_UPPER_H int = 1 << 11
	FLT_LOWER_C int = 1 << 12
	FLT_UPPER_C int = 1 << 13
)

Variables

This section is empty.

Functions

func Byte

func Byte(b []byte, mode string) []byte

func String

func String(str, mode string) string

Types

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

func NewReader

func NewReader(r io.Reader, mode string) *Reader

func (*Reader) Read

func (r *Reader) Read(p []byte) (int, error)

Jump to

Keyboard shortcuts

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