MCPcopy Index your code
hub / github.com/coder/coder / truncateUTF8Bytes

Function truncateUTF8Bytes

coderd/x/chatfiles/mime.go:238–254  ·  view source on GitHub ↗
(value string, maxBytes int)

Source from the content-addressed store, hash-verified

236}
237
238func truncateUTF8Bytes(value string, maxBytes int) string {
239 if maxBytes <= 0 || value == "" {
240 return ""
241 }
242 if len(value) <= maxBytes {
243 return value
244 }
245
246 cut := 0
247 for idx := range value {
248 if idx > maxBytes {
249 break
250 }
251 cut = idx
252 }
253 return value[:cut]
254}

Callers 1

NormalizeStoredFileNameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected