newline

package
v0.7.7 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(formName string, writer io.Writer, txt io.Reader) error

Convert function convert newline in the text stream.

Example
package main

import (
	"bytes"
	"fmt"
	"os"
	"strings"

	"github.com/goark/gnkf/dump"
	"github.com/goark/gnkf/newline"
)

var text = `こんにちは
世界!`

func main() {
	buf := &bytes.Buffer{}
	if err := newline.Convert("crlf", buf, strings.NewReader(text)); err != nil {
		fmt.Fprintln(os.Stderr, err)
		return
	}
	if err := dump.UnicodePoint(os.Stdout, buf); err != nil {
		fmt.Fprintln(os.Stderr, err)
		return
	}
}

/* Copyright 2020 Spiegel
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * 	http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
Output:

0x3053, 0x3093, 0x306b, 0x3061, 0x306f, 0x000d, 0x000a, 0x4e16, 0x754c, 0xff01

func FormList

func FormList() []string

FormList returns list of newline form

func NewReplacer

func NewReplacer(frm Form) *strings.Replacer

NewReplacer returns strings.Replacer instance for translating newline

Types

type Form

type Form int

Form is type of newline form

const (
	LF   Form = iota //newline is '\n' only
	CR               //newline is '\r' only
	CRLF             //newline is '\r'+'\n'
)

func FormOf

func FormOf(name string) (Form, error)

FormOf returns newline form name string

func (Form) Code

func (f Form) Code() string

Code returns newline code string

Jump to

Keyboard shortcuts

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