mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-21 14:23:03 +01:00
Cleanup.
This commit is contained in:
@@ -556,6 +556,22 @@ namespace bx
|
||||
return strLTrimSpace(strRTrimSpace(_str) );
|
||||
}
|
||||
|
||||
// If offset in UTF-8 string doesn't land on rune, walk back until first byte of rune is reached.
|
||||
static const char* fixPtrToRune(const char* _strBegin, const char* _curr)
|
||||
{
|
||||
for (; _curr > _strBegin && (*_curr & 0xc0) == 0x80; --_curr);
|
||||
|
||||
return _curr;
|
||||
}
|
||||
|
||||
StringView strTail(const StringView _str, uint32_t _num)
|
||||
{
|
||||
return StringView(
|
||||
fixPtrToRune(_str.getPtr(), _str.getTerm() - min(_num, _str.getLength() ) )
|
||||
, _str.getTerm()
|
||||
);
|
||||
}
|
||||
|
||||
constexpr uint32_t kFindStep = 1024;
|
||||
|
||||
StringView strFindNl(const StringView& _str)
|
||||
|
||||
Reference in New Issue
Block a user