MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / __hxcpp_string_of_bytes

Function __hxcpp_string_of_bytes

src/String.cpp:1574–1600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1572
1573
1574void __hxcpp_string_of_bytes(Array<unsigned char> &inBytes,String &outString,int pos,int len,bool inCopyPointer)
1575{
1576 if (inCopyPointer)
1577 outString = String( (const char *)inBytes->GetBase(), len);
1578 else if (len==0)
1579 outString = String::emptyString;
1580 else
1581 {
1582 const unsigned char *p0 = (const unsigned char *)inBytes->GetBase();
1583#ifdef HX_SMART_STRINGS
1584 bool hasWChar = false;
1585 const unsigned char *p = p0 + pos;
1586 for(int i=0;i<len;i++)
1587 if (p[i]>127)
1588 {
1589 hasWChar = true;
1590 break;
1591 }
1592 if (hasWChar)
1593 {
1594 outString = _hx_utf8_to_utf16(p0+pos,len,true);
1595 }
1596 else
1597#endif
1598 outString = String( GCStringDup((const char *)p0+pos, len, 0), len);
1599 }
1600}
1601
1602
1603

Callers

nothing calls this directly

Calls 3

_hx_utf8_to_utf16Function · 0.85
GCStringDupFunction · 0.85
StringClass · 0.50

Tested by

no test coverage detected