MCPcopy Create free account
hub / github.com/apache/arrow / SkipUTF8BOM

Function SkipUTF8BOM

cpp/src/arrow/util/utf8.cc:103–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101static const uint8_t kBOM[] = {0xEF, 0xBB, 0xBF};
102
103Result<const uint8_t*> SkipUTF8BOM(const uint8_t* data, int64_t size) {
104 int64_t i;
105 for (i = 0; i < static_cast<int64_t>(sizeof(kBOM)); ++i) {
106 if (size == 0) {
107 if (i == 0) {
108 // Empty string
109 return data;
110 } else {
111 return Status::Invalid("UTF8 string too short (truncated byte order mark?)");
112 }
113 }
114 if (data[i] != kBOM[i]) {
115 // BOM not found
116 return data;
117 }
118 --size;
119 }
120 // BOM found
121 return data + i;
122}
123
124namespace {
125

Callers 1

TESTFunction · 0.85

Calls 1

InvalidFunction · 0.50

Tested by 1

TESTFunction · 0.68