Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

README.md

mysqlUTF8

Build Status Coverage GoDoc license

mysqlUTF8 is a small library for handling MySQL UTF8 filename encoding. Database and table names with special characters are encoded on disk as detailed in the MySQL documentation.

For example if you create a database named Ω the directory @7P will be created in the MySQL data directory. The NeedsEncoding() function determines if a string requires encoding and the EncodeFilename() function will return an encoded string.

func NeedsEncoding(s string) bool

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

// Output:
// false
// true
// true
func EncodeFilename(s string) string

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

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

About

A small library for handing MySQL UTF8 filename encoding

Resources

License

Releases

No releases published

Languages

You can’t perform that action at this time.