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

Method wc_str

src/String.cpp:1760–1796  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1758
1759
1760const char16_t * String::wc_str(hx::IStringAlloc *inBuffer, int *outCharLength) const
1761{
1762 #ifdef HX_SMART_STRINGS
1763 if (isUTF16Encoded()) {
1764 if (outCharLength != 0) {
1765 *outCharLength = length;
1766 }
1767 return __w;
1768 }
1769 #endif
1770
1771 int char16Count = 0;
1772 const unsigned char *ptr = (const unsigned char *)__s;
1773 const unsigned char *u = ptr;
1774 const unsigned char *end = u + length;
1775 while(u<end)
1776 {
1777 int code = DecodeAdvanceUTF8(u,end);
1778 char16Count += UTF16BytesCheck(code);
1779 }
1780
1781 char16_t *str = inBuffer ? (char16_t *)inBuffer->allocBytes(2*(char16Count+1)) :
1782 (char16_t *)NewGCPrivate(0,2*(char16Count+1));
1783
1784 u = ptr;
1785 char16_t *o = str;
1786 while(u<end)
1787 {
1788 int code = DecodeAdvanceUTF8(u,end);
1789 Char16AdvanceSet(o,code);
1790 }
1791 *o = 0;
1792 if (outCharLength != 0) {
1793 *outCharLength = char16Count;
1794 }
1795 return str;
1796}
1797
1798bool String::wc_str(::cpp::marshal::View<char16_t> buffer, int* outCharLength) const
1799{

Callers 3

hxs_utf16Function · 0.80
runMethod · 0.80

Calls 7

isUTF16EncodedFunction · 0.85
DecodeAdvanceUTF8Function · 0.85
UTF16BytesCheckFunction · 0.85
NewGCPrivateFunction · 0.85
Char16AdvanceSetFunction · 0.85
memcpyFunction · 0.85
allocBytesMethod · 0.45

Tested by

no test coverage detected