| 1758 | |
| 1759 | |
| 1760 | const 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 | |
| 1798 | bool String::wc_str(::cpp::marshal::View<char16_t> buffer, int* outCharLength) const |
| 1799 | { |
no test coverage detected