本文整理匯總了Golang中github.com/dropbox/godropbox/encoding2.BinaryWriter.Write方法的典型用法代碼示例。如果您正苦於以下問題:Golang BinaryWriter.Write方法的具體用法?Golang BinaryWriter.Write怎麽用?Golang BinaryWriter.Write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/dropbox/godropbox/encoding2.BinaryWriter
的用法示例。
在下文中一共展示了BinaryWriter.Write方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: encodeSql
func (s String) encodeSql(b encoding2.BinaryWriter) {
if s.isUtf8 {
writebyte(b, '\'')
rawBytes := s.raw()
for i, ch := range rawBytes {
if encodedChar := SqlEncodeMap[ch]; encodedChar == DONTESCAPE {
writebyte(b, ch)
} else if i < len(rawBytes)-1 && '\\' == ch && ('%' == rawBytes[i+1] || '_' == rawBytes[i+1]) {
// Don't escape '\' specifically in the constructions '\%' or
// '\_', because those are special to how the RHS of LIKE
// clauses are escaped. See the notes following table 9.1 in
// http://dev.mysql.com/doc/refman/5.7/en/string-literals.html
writebyte(b, ch)
} else {
writebyte(b, '\\')
writebyte(b, encodedChar)
}
}
writebyte(b, '\'')
} else {
b.Write([]byte("X'"))
encoding2.HexEncodeToWriter(b, s.raw())
writebyte(b, '\'')
}
}
示例2: EncodeSql
// EncodeSql encodes the value into an SQL statement. Can be binary.
func (v Value) EncodeSql(b encoding2.BinaryWriter) {
if v.Inner == nil {
if _, err := b.Write(nullstr); err != nil {
panic(err)
}
} else {
v.Inner.encodeSql(b)
}
}
示例3: encodeSql
func (s String) encodeSql(b encoding2.BinaryWriter) {
if s.isUtf8 {
writebyte(b, '\'')
for _, ch := range s.raw() {
if encodedChar := SqlEncodeMap[ch]; encodedChar == DONTESCAPE {
writebyte(b, ch)
} else {
writebyte(b, '\\')
writebyte(b, encodedChar)
}
}
writebyte(b, '\'')
} else {
b.Write([]byte("X'"))
encoding2.HexEncodeToWriter(b, s.raw())
writebyte(b, '\'')
}
}
示例4: encodeAscii
func (f Fractional) encodeAscii(b encoding2.BinaryWriter) {
if _, err := b.Write(f.raw()); err != nil {
panic(err)
}
}