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

Function __hxcpp_bytes_of_string

src/String.cpp:1484–1526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1482}
1483
1484void __hxcpp_bytes_of_string(Array<unsigned char> &outBytes,const String &inString)
1485{
1486 if (!inString.length)
1487 return;
1488
1489 #ifdef HX_SMART_STRINGS
1490 if (inString.isUTF16Encoded())
1491 {
1492 const char16_t *src = inString.raw_wptr();
1493 const char16_t *end = src + inString.length;
1494 while(src<end)
1495 {
1496 int c = Char16Advance(src);
1497
1498 if( c <= 0x7F )
1499 outBytes->push(c);
1500 else if( c <= 0x7FF )
1501 {
1502 outBytes->push( 0xC0 | (c >> 6) );
1503 outBytes->push( 0x80 | (c & 63) );
1504 }
1505 else if( c <= 0xFFFF )
1506 {
1507 outBytes->push( 0xE0 | (c >> 12) );
1508 outBytes->push( 0x80 | ((c >> 6) & 63) );
1509 outBytes->push( 0x80 | (c & 63) );
1510 }
1511 else
1512 {
1513 outBytes->push( 0xF0 | (c >> 18) );
1514 outBytes->push( 0x80 | ((c >> 12) & 63) );
1515 outBytes->push( 0x80 | ((c >> 6) & 63) );
1516 outBytes->push( 0x80 | (c & 63) );
1517 }
1518 }
1519 }
1520 else
1521 #endif
1522 {
1523 outBytes->__SetSize(inString.length);
1524 memcpy(outBytes->GetBase(), inString.raw_ptr(),inString.length);
1525 }
1526}
1527
1528#ifdef HX_SMART_STRINGS
1529String _hx_utf8_to_utf16(const unsigned char *ptr, int inUtf8Len, bool addHash)

Callers 2

__URLEncodeMethod · 0.85
_hx_ssl_key_from_pemFunction · 0.85

Calls 3

Char16AdvanceFunction · 0.85
memcpyFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected