EncodeEscapedSQLIdent writes the identifier in s to buf. The identifier is always quoted. Double quotes inside the identifier are escaped.
(buf *bytes.Buffer, s string)
| 161 | // identifier is always quoted. Double quotes inside the identifier |
| 162 | // are escaped. |
| 163 | func EncodeEscapedSQLIdent(buf *bytes.Buffer, s string) { |
| 164 | buf.WriteByte('"') |
| 165 | start := 0 |
| 166 | for i, n := 0, len(s); i < n; i++ { |
| 167 | ch := s[i] |
| 168 | // The only character that requires escaping is a double quote. |
| 169 | if ch == '"' { |
| 170 | if start != i { |
| 171 | buf.WriteString(s[start:i]) |
| 172 | } |
| 173 | start = i + 1 |
| 174 | buf.WriteByte(ch) |
| 175 | buf.WriteByte(ch) // add extra copy of ch |
| 176 | } |
| 177 | } |
| 178 | if start < len(s) { |
| 179 | buf.WriteString(s[start:]) |
| 180 | } |
| 181 | buf.WriteByte('"') |
| 182 | } |
| 183 | |
| 184 | // EncodeLocaleName writes the locale identifier in s to buf. Any dash |
| 185 | // characters are mapped to underscore characters. Underscore characters do not |
no outgoing calls
no test coverage detected
searching dependent graphs…