strrev: 4d63.com/strrev Index | Examples | Files

package strrev

import "4d63.com/strrev"

Package strrev exports functions for reversing strings.

To reverse a string:

strrev.Reverse(...)

To reverse a string containing unicode combining characters where you wish to maintain the ordering of combining characters so that the character the follow is still displayed correctly:

strrev.ReverseCombining(...)

For more information about unicode combining characters, see: http://unicode.org/faq/char_combmark.html

Index

Examples

Package Files

strrev.go

func Reverse Uses

func Reverse(s string) string

Reverse reverses the given string, maintaining the bytes within any multibyte unicode characters in their existing order so that the characters are still rendered correctly.

Code:

r := strrev.Reverse("abcde丂g")

fmt.Println(r)

Output:

g丂edcba

func ReverseBytes Uses

func ReverseBytes(b []byte) []byte

ReverseBytes reverses the given byte slice, maintaining the bytes within any multibyte unicode characters in their existing order so that the characters are still rendered correctly.

func ReverseCombining Uses

func ReverseCombining(s string) string

ReverseCombining reverses the given string, maintaining the bytes within any multibyte and combining unicode characters in their existing order so that the characters are still rendered correctly.

Code:

r := strrev.ReverseCombining("abcdef\u0301\u031dg")

fmt.Println(r)

Output:

gf̝́edcba

func ReverseCombiningBytes Uses

func ReverseCombiningBytes(b []byte) []byte

ReverseCombiningBytes reverses the given byte slice, maintaining the bytes within any multibyte and combining unicode characters in their existing order so that the characters are still rendered correctly.

Package strrev imports 2 packages (graph). Updated 2017-10-26. Refresh now. Tools for package owners.