MCPcopy Create free account
hub / github.com/ablab/spades / columnWidthUTF8

Function columnWidthUTF8

ext/src/llvm/Unicode.cpp:342–361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

340}
341
342int columnWidthUTF8(StringRef Text) {
343 unsigned ColumnWidth = 0;
344 unsigned Length;
345 for (size_t i = 0, e = Text.size(); i < e; i += Length) {
346 Length = getNumBytesForUTF8(Text[i]);
347 if (Length <= 0 || i + Length > Text.size())
348 return ErrorInvalidUTF8;
349 UTF32 buf[1];
350 const UTF8 *Start = reinterpret_cast<const UTF8 *>(Text.data() + i);
351 UTF32 *Target = &buf[0];
352 if (conversionOK != ConvertUTF8toUTF32(&Start, Start + Length, &Target,
353 Target + 1, strictConversion))
354 return ErrorInvalidUTF8;
355 int Width = charWidth(buf[0]);
356 if (Width < 0)
357 return ErrorNonPrintableCharacter;
358 ColumnWidth += Width;
359 }
360 return ColumnWidth;
361}
362
363} // namespace unicode
364} // namespace sys

Callers 1

columnWidthFunction · 0.85

Calls 5

getNumBytesForUTF8Function · 0.85
ConvertUTF8toUTF32Function · 0.85
charWidthFunction · 0.85
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected