| 1615 | } |
| 1616 | |
| 1617 | const char *String::ascii_substr(hx::IStringAlloc *inBuffer,int start, int length) const |
| 1618 | { |
| 1619 | #ifdef HX_SMART_STRINGS |
| 1620 | if (isUTF16Encoded()) |
| 1621 | { |
| 1622 | const char16_t *p0 = __w + start; |
| 1623 | const char16_t *p = p0; |
| 1624 | const char16_t *limit = p+length; |
| 1625 | while(p<limit) |
| 1626 | { |
| 1627 | if (*p<=0 || *p>=127) |
| 1628 | break; |
| 1629 | p++; |
| 1630 | } |
| 1631 | int validLen = (int)(p-p0); |
| 1632 | char *result = (char *)inBuffer->allocBytes(validLen+1); |
| 1633 | for(int i=0;i<validLen;i++) |
| 1634 | result[i] = p0[i]; |
| 1635 | result[validLen] = 0; |
| 1636 | return result; |
| 1637 | } |
| 1638 | #endif |
| 1639 | if (__s[start+length]=='\0') |
| 1640 | return __s+start; |
| 1641 | char *result = (char *)inBuffer->allocBytes(length+1); |
| 1642 | memcpy(result,__s+start,length); |
| 1643 | result[length] = '\0'; |
| 1644 | |
| 1645 | return result; |
| 1646 | } |
| 1647 | |
| 1648 | #ifdef HX_SMART_STRINGS |
| 1649 |
no test coverage detected