當前位置: 首頁>>代碼示例>>Golang>>正文


Golang encoding2.BinaryWriter類代碼示例

本文整理匯總了Golang中github.com/dropbox/godropbox/encoding2.BinaryWriter的典型用法代碼示例。如果您正苦於以下問題:Golang BinaryWriter類的具體用法?Golang BinaryWriter怎麽用?Golang BinaryWriter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了BinaryWriter類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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, '\'')
	}
}
開發者ID:Charlesdong,項目名稱:godropbox,代碼行數:25,代碼來源:sqltypes.go

示例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)
	}
}
開發者ID:4578395263256,項目名稱:godropbox,代碼行數:10,代碼來源:sqltypes.go

示例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, '\'')
	}
}
開發者ID:4578395263256,項目名稱:godropbox,代碼行數:18,代碼來源:sqltypes.go

示例4: writebyte

func writebyte(b encoding2.BinaryWriter, c byte) {
	if err := b.WriteByte(c); err != nil {
		panic(err)
	}
}
開發者ID:4578395263256,項目名稱:godropbox,代碼行數:5,代碼來源:sqltypes.go

示例5: encodeAscii

func (f Fractional) encodeAscii(b encoding2.BinaryWriter) {
	if _, err := b.Write(f.raw()); err != nil {
		panic(err)
	}
}
開發者ID:4578395263256,項目名稱:godropbox,代碼行數:5,代碼來源:sqltypes.go


注:本文中的github.com/dropbox/godropbox/encoding2.BinaryWriter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。