File: collation.go

package info (click to toggle)
golang-github-denisenkom-go-mssqldb 0.0~git20170717.0.8fccfc8-5
  • links: PTS, VCS
  • area: main
  • in suites: buster, buster-backports
  • size: 3,232 kB
  • sloc: makefile: 5
file content (39 lines) | stat: -rw-r--r-- 764 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package mssql

import (
	"encoding/binary"
	"io"
)

// http://msdn.microsoft.com/en-us/library/dd340437.aspx

type collation struct {
	lcidAndFlags uint32
	sortId       uint8
}

func (c collation) getLcid() uint32 {
	return c.lcidAndFlags & 0x000fffff
}

func (c collation) getFlags() uint32 {
	return (c.lcidAndFlags & 0x0ff00000) >> 20
}

func (c collation) getVersion() uint32 {
	return (c.lcidAndFlags & 0xf0000000) >> 28
}

func readCollation(r *tdsBuffer) (res collation) {
	res.lcidAndFlags = r.uint32()
	res.sortId = r.byte()
	return
}

func writeCollation(w io.Writer, col collation) (err error) {
	if err = binary.Write(w, binary.LittleEndian, col.lcidAndFlags); err != nil {
		return
	}
	err = binary.Write(w, binary.LittleEndian, col.sortId)
	return
}