mysqlUTF8: github.com/joshuaprunier/mysqlUTF8 Index | Examples | Files

package mysqlUTF8

import "github.com/joshuaprunier/mysqlUTF8"

Index

Examples

Package Files

mysqlUTF8.go

func EncodeFilename Uses

func EncodeFilename(s string) string

EncodeFilename returns an encoded string based on MySQL encoding rules found in ../strings/ctype-utf8.c of the MySQL source code.

Code:

fmt.Println(EncodeFilename("test"))
fmt.Println(EncodeFilename("¿"))
fmt.Println(EncodeFilename("(╯°□°)╯︵ ┻━┻"))

Output:

test
@00bf
@0028@256f@00b0@25a1@00b0@0029@256f@fe35@0020@253b@2501@253b

func NeedsEncoding Uses

func NeedsEncoding(s string) bool

NeedsEncoding reports if a string requires MySQL encoding.

Code:

fmt.Println(NeedsEncoding("test"))
fmt.Println(NeedsEncoding("¿"))
fmt.Println(NeedsEncoding("¢ent"))

Output:

false
true
true

Package mysqlUTF8 is imported by 1 packages. Updated 2016-07-21. Refresh now. Tools for package owners.