MCPcopy
hub / github.com/larksuite/cli / stripUTF8BOM

Function stripUTF8BOM

shortcuts/common/runner.go:1040–1042  ·  view source on GitHub ↗

stripUTF8BOM removes a leading UTF-8 byte-order mark from content read from a file or stdin. A BOM that survives into a CSV cell corrupts the first value (e.g. "\ufeffNorth", which then makes a MAXIFS/lookup miss it), and a BOM at the head of a JSON payload makes json.Unmarshal fail with "invalid ch

(s string)

Source from the content-addressed store, hash-verified

1038// Some editors and exporters add it silently. Only a leading BOM is removed; interior
1039// occurrences are left untouched.
1040func stripUTF8BOM(s string) string {
1041 return strings.TrimPrefix(s, "\uFEFF")
1042}
1043
1044// resolveInputFlags resolves @file and - (stdin) for flags with Input sources.
1045// Must be called before Validate/DryRun/Execute so that runtime.Str() returns resolved content.

Callers 2

resolveInputFlagsFunction · 0.85
TestStripUTF8BOMFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestStripUTF8BOMFunction · 0.68